linux-stable/fs
David Howells 189b0ddc24 pipe: Fix missing lock in pipe_resize_ring()
pipe_resize_ring() needs to take the pipe->rd_wait.lock spinlock to
prevent post_one_notification() from trying to insert into the ring
whilst the ring is being replaced.

The occupancy check must be done after the lock is taken, and the lock
must be taken after the new ring is allocated.

The bug can lead to an oops looking something like:

 BUG: KASAN: use-after-free in post_one_notification.isra.0+0x62e/0x840
 Read of size 4 at addr ffff88801cc72a70 by task poc/27196
 ...
 Call Trace:
  post_one_notification.isra.0+0x62e/0x840
  __post_watch_notification+0x3b7/0x650
  key_create_or_update+0xb8b/0xd20
  __do_sys_add_key+0x175/0x340
  __x64_sys_add_key+0xbe/0x140
  do_syscall_64+0x5c/0xc0
  entry_SYSCALL_64_after_hwframe+0x44/0xae

Reported by Selim Enes Karaduman @Enesdex working with Trend Micro Zero
Day Initiative.

Fixes: c73be61ced ("pipe: Add general notification queue support")
Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17291
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-05-27 10:45:59 -07:00
..
9p
adfs
affs
afs Misc hardening changes for 5.19-rc1 2022-05-25 13:56:57 -07:00
autofs
befs
bfs
btrfs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
cachefiles
ceph Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
cifs v5.19 pull request 2022-05-26 21:08:40 -07:00
coda
configfs
cramfs
crypto
debugfs
devpts
dlm
ecryptfs
efivarfs
efs
erofs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
exfat Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
exportfs
ext2 \n 2022-05-25 19:24:06 -07:00
ext4 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
f2fs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
fat Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
freevxfs
fscache
fuse
gfs2 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
hfs
hfsplus
hostfs
hpfs
hugetlbfs Yang Shi has improved the behaviour of khugepaged collapsing of readonly 2022-05-26 12:32:41 -07:00
iomap Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
isofs
jbd2 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
jffs2
jfs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
kernfs
ksmbd
lockd
minix
netfs
nfs Yang Shi has improved the behaviour of khugepaged collapsing of readonly 2022-05-26 12:32:41 -07:00
nfs_common
nfsd NFSD 5.19 Release Notes 2022-05-26 20:52:24 -07:00
nilfs2 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
nls
notify \n 2022-05-25 19:29:54 -07:00
ntfs
ntfs3 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
ocfs2 Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
omfs
openpromfs
orangefs
overlayfs
proc sysctl changes for v5.19-rc1 2022-05-26 16:57:20 -07:00
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
smbfs_common
squashfs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
sysfs
sysv
tracefs
ubifs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
udf Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
ufs
unicode
vboxsf
verity Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
xfs xfs: Changes for 5.19-rc1 2022-05-25 19:34:40 -07:00
zonefs Page cache changes for 5.19 2022-05-24 19:55:07 -07:00
Kconfig
Kconfig.binfmt
Makefile
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_elf_test.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
buffer.c
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c
dcache.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fhandle.c
file.c
file_table.c
filesystems.c
fs-writeback.c \n 2022-05-25 19:24:06 -07:00
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c
inode.c
internal.h
io-wq.c
io-wq.h
io_uring.c
ioctl.c
kernel_read_file.c
libfs.c
locks.c
mbcache.c
mount.h
mpage.c
namei.c
namespace.c
no-block.c
nsfs.c
open.c NFSD 5.19 Release Notes 2022-05-26 20:52:24 -07:00
pipe.c pipe: Fix missing lock in pipe_resize_ring() 2022-05-27 10:45:59 -07:00
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c
super.c
sync.c
sysctls.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c