summaryrefslogtreecommitdiff
path: root/fs/open.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-02-20 12:03:55 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2023-02-20 12:03:55 -0800
commitea5aac6fae94bff4756051b0503f86e31ef6808b (patch)
tree7ceab90282b60a359e27808bcad8c1bebdb34ecc /fs/open.c
parent05e6295f7b5e05f09e369a3eb2882ec5b40fff20 (diff)
parent47d586913f2abec4d240bae33417f537fda987ec (diff)
Merge tag 'fs.v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping
Pull vfs hardening update from Christian Brauner: "Jan pointed out that during shutdown both filp_close() and super block destruction will use basic printk logging when bugs are detected. This causes issues in a few scenarios: - Tools like syzkaller cannot figure out that the logged message indicates a bug. - Users that explicitly opt in to have the kernel bug on data corruption by selecting CONFIG_BUG_ON_DATA_CORRUPTION should see the kernel crash when they did actually select that option. - When there are busy inodes after the superblock is shut down later access to such a busy inodes walks through freed memory. It would be better to cleanly crash instead. All of this can be addressed by using the already existing CHECK_DATA_CORRUPTION() macro in these places when kernel bugs are detected. Its logging improvement is useful for all users. Otherwise this only has a meaningful behavioral effect when users do select CONFIG_BUG_ON_DATA_CORRUPTION which means this is backward compatible for regular users" * tag 'fs.v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping: fs: Use CHECK_DATA_CORRUPTION() when kernel bugs are detected
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/open.c b/fs/open.c
index 68051c1c0579..8038cf652583 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1413,8 +1413,9 @@ int filp_close(struct file *filp, fl_owner_t id)
{
int retval = 0;
- if (!file_count(filp)) {
- printk(KERN_ERR "VFS: Close: file count is 0\n");
+ if (CHECK_DATA_CORRUPTION(file_count(filp) == 0,
+ "VFS: Close: file count is 0 (f_op=%ps)",
+ filp->f_op)) {
return 0;
}