Skip to content

Commit 3804e6d

Browse files
Denis Arefevgregkh
authored andcommitted
block: Avoid mounting the bdev pseudo-filesystem in userspace
commit f73aa66 upstream. The bdev pseudo-filesystem is an internal kernel filesystem with which userspace should not interfere. Unregister it so that userspace cannot even attempt to mount it. This fixes a bug [1] that occurs when attempting to access files, because the system call move_mount() uses pointers declared in the inode_operations structure, which for the bdev pseudo-filesystem are always equal to 0. `inode->i_op = &empty_iops;` [1] BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 23380067 P4D 23380067 PUD 23381067 PMD 0 Oops: 0010 [#1] PREEMPT SMP KASAN NOPTI CPU: 2 PID: 17125 Comm: syz-executor.0 Not tainted 6.1.155-syzkaller-00350-g84221fde2681 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:0x0 Call Trace: <TASK> lookup_open.isra.0+0x700/0x1180 fs/namei.c:3460 open_last_lookups fs/namei.c:3550 [inline] path_openat+0x953/0x2700 fs/namei.c:3780 do_filp_open+0x1c5/0x410 fs/namei.c:3810 do_sys_openat2+0x171/0x4d0 fs/open.c:1318 do_sys_open fs/open.c:1334 [inline] __do_sys_openat fs/open.c:1350 [inline] __se_sys_openat fs/open.c:1345 [inline] __x64_sys_openat+0x13c/0x1f0 fs/open.c:1345 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x6e/0xd8 Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 1da177e ("Linux-2.6.12-rc2") Link: https://lore.kernel.org/all/20131010004732.GJ13318@ZenIV.linux.org.uk/T/# Cc: stable@vger.kernel.org Signed-off-by: Denis Arefev <arefev@swemel.ru> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260521072857.5078-1-arefev@swemel.ru Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent db2c5b9 commit 3804e6d

1 file changed

Lines changed: 0 additions & 5 deletions

File tree

block/bdev.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,10 @@ EXPORT_SYMBOL_GPL(blockdev_superblock);
438438

439439
void __init bdev_cache_init(void)
440440
{
441-
int err;
442-
443441
bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
444442
0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
445443
SLAB_ACCOUNT|SLAB_PANIC),
446444
init_once);
447-
err = register_filesystem(&bd_type);
448-
if (err)
449-
panic("Cannot register bdev pseudo-fs");
450445
blockdev_mnt = kern_mount(&bd_type);
451446
if (IS_ERR(blockdev_mnt))
452447
panic("Cannot create bdev pseudo-fs");

0 commit comments

Comments
 (0)