public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3)
@ 2024-09-17  4:59 syzbot
  2024-09-17  5:58 ` [PATCH] erofs: ensure regular inodes for file-backed mounts Gao Xiang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: syzbot @ 2024-09-17  4:59 UTC (permalink / raw)
  To: chao, dhavale, huyue2, jefflexu, linux-erofs, linux-kernel,
	linux-mm, syzkaller-bugs, xiang

Hello,

syzbot found the following issue on:

HEAD commit:    a430d95c5efa Merge tag 'lsm-pr-20240911' of git://git.kern..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=118e68a9980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1653f803fffa3848
dashboard link: https://syzkaller.appspot.com/bug?extid=001306cd9c92ce0df23f
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1452dc07980000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=158e68a9980000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7bc7510fe41f/non_bootable_disk-a430d95c.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/66a65abf87c4/vmlinux-a430d95c.xz
kernel image: https://storage.googleapis.com/syzbot-assets/09c88015f9aa/bzImage-a430d95c.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/00e0bb849690/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com

loop0: detected capacity change from 0 to 256
vfat: Unknown parameter 's'
./file1: Can't lookup blockdev
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 127b0067 P4D 127b0067 PUD 127b1067 PMD 0 
Oops: Oops: 0010 [#1] PREEMPT SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5096 Comm: syz-executor418 Not tainted 6.11.0-syzkaller-02574-ga430d95c5efa #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
RSP: 0018:ffffc90002d7f9f8 EFLAGS: 00010293
RAX: ffffffff81cb4ee0 RBX: 0000000000000000 RCX: ffff88801e428000
RDX: 0000000000000000 RSI: ffffea00004bfec0 RDI: 0000000000000000
RBP: ffffc90002d7fac0 R08: ffffea00004bfec7 R09: 1ffffd4000097fd8
R10: dffffc0000000000 R11: 0000000000000000 R12: ffffea00004bfec0
R13: 1ffffd4000097fd9 R14: 0000000000000000 R15: ffffea00004bfec8
FS:  000055558992f380(0000) GS:ffff88801fe00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 0000000011be2000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 filemap_read_folio+0x1a0/0x790 mm/filemap.c:2355
 do_read_cache_folio+0x134/0x820 mm/filemap.c:3796
 read_mapping_folio include/linux/pagemap.h:915 [inline]
 erofs_bread+0x499/0xd40 fs/erofs/data.c:41
 erofs_read_superblock fs/erofs/super.c:277 [inline]
 erofs_fc_fill_super+0x345/0x1770 fs/erofs/super.c:621
 vfs_get_super fs/super.c:1280 [inline]
 get_tree_nodev+0xb7/0x140 fs/super.c:1299
 vfs_get_tree+0x90/0x2b0 fs/super.c:1800
 do_new_mount+0x2be/0xb40 fs/namespace.c:3507
 do_mount fs/namespace.c:3847 [inline]
 __do_sys_mount fs/namespace.c:4055 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4032
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb0eb9a7f59
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffff42b6ec8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 6d616e74726f6873 RCX: 00007fb0eb9a7f59
RDX: 00000000200005c0 RSI: 0000000020000580 RDI: 0000000020000540
RBP: 0031656c69662f2e R08: 0000000000000000 R09: 00005555899304c0
R10: 0000000000200000 R11: 0000000000000246 R12: 74616c785f696e75
R13: 746e6e69773d656d R14: 646578696d3d656d R15: 00007fb0eb9f103b
 </TASK>
Modules linked in:
CR2: 0000000000000000
---[ end trace 0000000000000000 ]---
RIP: 0010:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
RSP: 0018:ffffc90002d7f9f8 EFLAGS: 00010293
RAX: ffffffff81cb4ee0 RBX: 0000000000000000 RCX: ffff88801e428000
RDX: 0000000000000000 RSI: ffffea00004bfec0 RDI: 0000000000000000
RBP: ffffc90002d7fac0 R08: ffffea00004bfec7 R09: 1ffffd4000097fd8
R10: dffffc0000000000 R11: 0000000000000000 R12: ffffea00004bfec0
R13: 1ffffd4000097fd9 R14: 0000000000000000 R15: ffffea00004bfec8
FS:  000055558992f380(0000) GS:ffff88801fe00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 0000000011be2000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] erofs: ensure regular inodes for file-backed mounts
  2024-09-17  4:59 [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) syzbot
@ 2024-09-17  5:58 ` Gao Xiang
  2024-09-17  6:39 ` [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) Gao Xiang
  2024-09-17 13:08 ` [PATCH v2] erofs: ensure regular inodes for file-backed mounts Gao Xiang
  2 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2024-09-17  5:58 UTC (permalink / raw)
  To: linux-erofs; +Cc: LKML, Gao Xiang, syzbot+001306cd9c92ce0df23f

Only regular inodes are allowed for file-backed mounts, not directories
(as seen in the original syzbot case) or special inodes.

Also ensure that .read_folio() is implemented on the underlying fs.

Fixes: fb176750266a ("erofs: add file-backed mount support")
Reported-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/r/00000000000011bdde0622498ee3@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 fs/erofs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 666873f745da..7c3467dcc5b4 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -714,7 +714,10 @@ static int erofs_fc_get_tree(struct fs_context *fc)
 		if (IS_ERR(sbi->fdev))
 			return PTR_ERR(sbi->fdev);
 
-		return get_tree_nodev(fc, erofs_fc_fill_super);
+		if (S_ISREG(file_inode(sbi->fdev)->i_mode) &&
+		    sbi->fdev->f_mapping->a_ops->read_folio)
+			return get_tree_nodev(fc, erofs_fc_fill_super);
+		fput(sbi->fdev);
 	}
 #endif
 	return ret;
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3)
  2024-09-17  4:59 [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) syzbot
  2024-09-17  5:58 ` [PATCH] erofs: ensure regular inodes for file-backed mounts Gao Xiang
@ 2024-09-17  6:39 ` Gao Xiang
  2024-09-17  7:02   ` syzbot
  2024-09-17 13:08 ` [PATCH v2] erofs: ensure regular inodes for file-backed mounts Gao Xiang
  2 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2024-09-17  6:39 UTC (permalink / raw)
  To: syzbot, linux-erofs, linux-kernel, linux-mm, syzkaller-bugs,
	xiang

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3)
  2024-09-17  6:39 ` [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) Gao Xiang
@ 2024-09-17  7:02   ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2024-09-17  7:02 UTC (permalink / raw)
  To: hsiangkao, linux-erofs, linux-kernel, linux-mm, syzkaller-bugs,
	xiang

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
Tested-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com

Tested on:

commit:         2830df2e erofs: ensure regular inodes for file-backed ..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
console output: https://syzkaller.appspot.com/x/log.txt?x=11b168a9980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a43f85ec3262ab75
dashboard link: https://syzkaller.appspot.com/bug?extid=001306cd9c92ce0df23f
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] erofs: ensure regular inodes for file-backed mounts
  2024-09-17  4:59 [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) syzbot
  2024-09-17  5:58 ` [PATCH] erofs: ensure regular inodes for file-backed mounts Gao Xiang
  2024-09-17  6:39 ` [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) Gao Xiang
@ 2024-09-17 13:08 ` Gao Xiang
  2024-10-11  3:10   ` Chao Yu
  2 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2024-09-17 13:08 UTC (permalink / raw)
  To: linux-erofs; +Cc: LKML, Gao Xiang, syzbot+001306cd9c92ce0df23f

Only regular inodes are allowed for file-backed mounts, not directories
(as seen in the original syzbot case) or special inodes.

Also ensure that .read_folio() is implemented on the underlying fs
for the primary device.

Fixes: fb176750266a ("erofs: add file-backed mount support")
Reported-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/r/00000000000011bdde0622498ee3@google.com
Tested-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
change since v1:
 - need to handle multi-device/blob cases too.

 fs/erofs/super.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 666873f745da..320d586c3896 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -191,10 +191,14 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
 		if (IS_ERR(file))
 			return PTR_ERR(file);
 
-		dif->file = file;
-		if (!erofs_is_fileio_mode(sbi))
+		if (!erofs_is_fileio_mode(sbi)) {
 			dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file),
 					&dif->dax_part_off, NULL, NULL);
+		} else if (!S_ISREG(file_inode(file)->i_mode)) {
+			fput(file);
+			return -EINVAL;
+		}
+		dif->file = file;
 	}
 
 	dif->blocks = le32_to_cpu(dis->blocks);
@@ -714,7 +718,10 @@ static int erofs_fc_get_tree(struct fs_context *fc)
 		if (IS_ERR(sbi->fdev))
 			return PTR_ERR(sbi->fdev);
 
-		return get_tree_nodev(fc, erofs_fc_fill_super);
+		if (S_ISREG(file_inode(sbi->fdev)->i_mode) &&
+		    sbi->fdev->f_mapping->a_ops->read_folio)
+			return get_tree_nodev(fc, erofs_fc_fill_super);
+		fput(sbi->fdev);
 	}
 #endif
 	return ret;
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] erofs: ensure regular inodes for file-backed mounts
  2024-09-17 13:08 ` [PATCH v2] erofs: ensure regular inodes for file-backed mounts Gao Xiang
@ 2024-10-11  3:10   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2024-10-11  3:10 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: Chao Yu, syzbot+001306cd9c92ce0df23f, LKML

On 2024/9/17 21:08, Gao Xiang wrote:
> Only regular inodes are allowed for file-backed mounts, not directories
> (as seen in the original syzbot case) or special inodes.
> 
> Also ensure that .read_folio() is implemented on the underlying fs
> for the primary device.
> 
> Fixes: fb176750266a ("erofs: add file-backed mount support")
> Reported-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/r/00000000000011bdde0622498ee3@google.com
> Tested-by: syzbot+001306cd9c92ce0df23f@syzkaller.appspotmail.com
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-11  3:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17  4:59 [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) syzbot
2024-09-17  5:58 ` [PATCH] erofs: ensure regular inodes for file-backed mounts Gao Xiang
2024-09-17  6:39 ` [syzbot] [erofs?] [mm?] BUG: unable to handle kernel NULL pointer dereference in filemap_read_folio (3) Gao Xiang
2024-09-17  7:02   ` syzbot
2024-09-17 13:08 ` [PATCH v2] erofs: ensure regular inodes for file-backed mounts Gao Xiang
2024-10-11  3:10   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox