mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
fs.v6.3
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCY+5SogAKCRCRxhvAZXjc orVwAP4jJ1dPZYx1xHip9TfB5fv5xHz3euhvWns6qGJdVYoHzwEAhVxgYUpqWdXX L/+VKRFFujYxsSXP4BbS3xDPUJeQFAI= =ccK2 -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
ea5aac6fae
3 changed files with 23 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
21
fs/super.c
21
fs/super.c
|
@ -491,10 +491,23 @@ void generic_shutdown_super(struct super_block *sb)
|
|||
if (sop->put_super)
|
||||
sop->put_super(sb);
|
||||
|
||||
if (!list_empty(&sb->s_inodes)) {
|
||||
printk("VFS: Busy inodes after unmount of %s. "
|
||||
"Self-destruct in 5 seconds. Have a nice day...\n",
|
||||
sb->s_id);
|
||||
if (CHECK_DATA_CORRUPTION(!list_empty(&sb->s_inodes),
|
||||
"VFS: Busy inodes after unmount of %s (%s)",
|
||||
sb->s_id, sb->s_type->name)) {
|
||||
/*
|
||||
* Adding a proper bailout path here would be hard, but
|
||||
* we can at least make it more likely that a later
|
||||
* iput_final() or such crashes cleanly.
|
||||
*/
|
||||
struct inode *inode;
|
||||
|
||||
spin_lock(&sb->s_inode_list_lock);
|
||||
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
|
||||
inode->i_op = VFS_PTR_POISON;
|
||||
inode->i_sb = VFS_PTR_POISON;
|
||||
inode->i_mapping = VFS_PTR_POISON;
|
||||
}
|
||||
spin_unlock(&sb->s_inode_list_lock);
|
||||
}
|
||||
}
|
||||
spin_lock(&sb_lock);
|
||||
|
|
|
@ -84,4 +84,7 @@
|
|||
/********** kernel/bpf/ **********/
|
||||
#define BPF_PTR_POISON ((void *)(0xeB9FUL + POISON_POINTER_DELTA))
|
||||
|
||||
/********** VFS **********/
|
||||
#define VFS_PTR_POISON ((void *)(0xF5 + POISON_POINTER_DELTA))
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue