linux-stable/fs/nilfs2
Pan Bian bb61224f6a nilfs2: fix potential use after free in nilfs_gccache_submit_read_data()
commit 7ee29facd8 upstream.

In nilfs_gccache_submit_read_data(), brelse(bh) is called to drop the
reference count of bh when the call to nilfs_dat_translate() fails.  If
the reference count hits 0 and its owner page gets unlocked, bh may be
freed.  However, bh->b_page is dereferenced to put the page after that,
which may result in a use-after-free bug.  This patch moves the release
operation after unlocking and putting the page.

NOTE: The function in question is only called in GC, and in combination
with current userland tools, address translation using DAT does not occur
in that function, so the code path that causes this issue will not be
executed.  However, it is possible to run that code path by intentionally
modifying the userland GC library or by calling the GC ioctl directly.

[konishi.ryusuke@gmail.com: NOTE added to the commit log]
Link: https://lkml.kernel.org/r/1543201709-53191-1-git-send-email-bianpan2016@163.com
Link: https://lkml.kernel.org/r/20230921141731.10073-1-konishi.ryusuke@gmail.com
Fixes: a3d93f709e ("nilfs2: block cache for garbage collection")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reported-by: Ferry Meng <mengferry@linux.alibaba.com>
Closes: https://lkml.kernel.org/r/20230818092022.111054-1-mengferry@linux.alibaba.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-10 21:44:59 +02:00
..
alloc.c nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse 2023-09-23 10:47:57 +02:00
alloc.h
bmap.c nilfs2: fix infinite loop in nilfs_mdt_get_block() 2023-05-17 11:13:20 +02:00
bmap.h
btnode.c nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key() 2023-06-21 15:39:57 +02:00
btnode.h nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
btree.c nilfs2: fix general protection fault in nilfs_btree_insert() 2023-01-24 07:11:49 +01:00
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() 2022-12-08 11:18:33 +01:00
dat.h
dir.c
direct.c
direct.h
export.h
file.c
gcinode.c nilfs2: fix potential use after free in nilfs_gccache_submit_read_data() 2023-10-10 21:44:59 +02:00
ifile.c
ifile.h
inode.c nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse 2023-09-23 10:47:57 +02:00
ioctl.c nilfs2: fix kernel-infoleak in nilfs_ioctl_wrap_copy() 2023-04-05 11:15:37 +02:00
Kconfig
Makefile
mdt.c nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:10:37 +02:00
mdt.h nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:10:37 +02:00
namei.c
nilfs.h nilfs2: fix incorrect masking of permission flags for symlinks 2022-07-21 21:09:26 +02:00
page.c nilfs2: prevent general protection fault in nilfs_clear_dirty_page() 2023-06-28 10:15:28 +02:00
page.h
recovery.c
segbuf.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:15:28 +02:00
segbuf.h
segment.c nilfs2: fix general protection fault in nilfs_lookup_dirty_data_buffers() 2023-09-23 10:47:57 +02:00
segment.h
sufile.c nilfs2: fix possible out-of-bounds segment allocation in resize ioctl 2023-06-21 15:39:57 +02:00
sufile.h
super.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:15:28 +02:00
sysfs.c nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group 2021-09-26 13:39:49 +02:00
sysfs.h
the_nilfs.c nilfs2: reject devices with insufficient block count 2023-06-28 10:15:27 +02:00
the_nilfs.h nilfs2: fix use-after-free of nilfs_root in dirtying inodes via iput 2023-08-16 18:13:00 +02:00