2024-04-01 16:50:41

by syzbot

[permalink] [raw]
Subject: [syzbot] [mtd?] WARNING: zero-size vmalloc in ubi_read_volume_table

Hello,

syzbot found the following issue on:

HEAD commit: fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=10223ae5180000
kernel config: https://syzkaller.appspot.com/x/.config?x=aef2a55903e5791c
dashboard link: https://syzkaller.appspot.com/bug?extid=f516089d7815b10197c9
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13668b21180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10a6e21d180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/089e25869df5/disk-fe46a7dd.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/423b1787914f/vmlinux-fe46a7dd.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4c043e30c07d/bzImage-fe46a7dd.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

ubi0: scanning is finished
ubi0: empty MTD device detected
------------[ cut here ]------------
WARNING: CPU: 0 PID: 5062 at mm/vmalloc.c:3319 __vmalloc_node_range+0x1065/0x1540 mm/vmalloc.c:3319
Modules linked in:
CPU: 0 PID: 5062 Comm: syz-executor167 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:__vmalloc_node_range+0x1065/0x1540 mm/vmalloc.c:3319
Code: 48 8b 7d 08 e8 bc db ff ff 48 39 c5 0f 85 f3 02 00 00 e8 5e 9e b2 ff 48 89 ef e8 26 8f 02 00 e9 c2 f9 ff ff e8 4c 9e b2 ff 90 <0f> 0b 90 31 db e8 41 9e b2 ff 48 b8 00 00 00 00 00 fc ff df 4d 8d
RSP: 0018:ffffc900033df918 EFLAGS: 00010293
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: ffffffff81da4ac2
RDX: ffff88801976da00 RSI: ffffffff81da5a64 RDI: 0000000000000007
RBP: ffffffff85f10bf9 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000000000 R11: ffffffff8ae00126 R12: 0000000000000000
R13: 1ffff9200067bf3e R14: 0000000000000000 R15: ffff88802ef1a600
FS: 000055556b89e380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000045e620 CR3: 0000000022954000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__vmalloc_node mm/vmalloc.c:3457 [inline]
vzalloc+0x6b/0x90 mm/vmalloc.c:3530
create_empty_lvol drivers/mtd/ubi/vtbl.c:490 [inline]
ubi_read_volume_table+0x639/0x2a30 drivers/mtd/ubi/vtbl.c:812
ubi_attach+0x1a2f/0x4af0 drivers/mtd/ubi/attach.c:1601
ubi_attach_mtd_dev+0x1659/0x3950 drivers/mtd/ubi/build.c:1000
ctrl_cdev_ioctl+0x339/0x3d0 drivers/mtd/ubi/cdev.c:1043
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:904 [inline]
__se_sys_ioctl fs/ioctl.c:890 [inline]
__x64_sys_ioctl+0x193/0x220 fs/ioctl.c:890
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7fbab2531369
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 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:00007ffcb56bd0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffcb56bd298 RCX: 00007fbab2531369
RDX: 0000000020000504 RSI: 0000000040186f40 RDI: 0000000000000003
RBP: 00007fbab25a4610 R08: 0000000000000000 R09: 00007ffcb56bd298
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffcb56bd288 R14: 0000000000000001 R15: 0000000000000001
</TASK>


---
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 [email protected].

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


2024-04-02 04:16:19

by Edward Adam Davis

[permalink] [raw]
Subject: Re: [syzbot] [mtd?] WARNING: zero-size vmalloc in ubi_read_volume_table

please test zs in ubi_read_volume_table

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index f700f0e4f2ec..e3b337afdb4f 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -791,7 +791,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
* The number of supported volumes is limited by the eraseblock size
* and by the UBI_MAX_VOLUMES constant.
*/
- ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE;
+ ubi->vtbl_slots = ubi->leb_size > UBI_VTBL_RECORD_SIZE ?
+ ubi->leb_size / UBI_VTBL_RECORD_SIZE : 1;
if (ubi->vtbl_slots > UBI_MAX_VOLUMES)
ubi->vtbl_slots = UBI_MAX_VOLUMES;



2024-04-02 06:15:10

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [mtd?] WARNING: zero-size vmalloc in ubi_read_volume_table

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file drivers/mtd/ubi/vtbl.c
Hunk #1 FAILED at 791.
1 out of 1 hunk FAILED



Tested on:

commit: 026e680b Merge tag 'pwm/for-6.9-rc3-fixes' of git://gi..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
kernel config: https://syzkaller.appspot.com/x/.config?x=aef2a55903e5791c
dashboard link: https://syzkaller.appspot.com/bug?extid=f516089d7815b10197c9
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=1084f5c3180000


2024-04-02 08:28:22

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [mtd?] WARNING: zero-size vmalloc in ubi_read_volume_table

Hello,

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

Reported-and-tested-by: [email protected]

Tested on:

commit: fe46a7dd Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1287dc5e180000
kernel config: https://syzkaller.appspot.com/x/.config?x=aef2a55903e5791c
dashboard link: https://syzkaller.appspot.com/bug?extid=f516089d7815b10197c9
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=16e5b9f9180000

Note: testing is done by a robot and is best-effort only.

2024-04-07 06:31:41

by Zhihao Cheng

[permalink] [raw]
Subject: Re: [syzbot] [mtd?] WARNING: zero-size vmalloc in ubi_read_volume_table

在 2024/4/2 0:50, syzbot 写道:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=10223ae5180000
> kernel config: https://syzkaller.appspot.com/x/.config?x=aef2a55903e5791c
> dashboard link: https://syzkaller.appspot.com/bug?extid=f516089d7815b10197c9
> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13668b21180000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10a6e21d180000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/089e25869df5/disk-fe46a7dd.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/423b1787914f/vmlinux-fe46a7dd.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/4c043e30c07d/bzImage-fe46a7dd.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> ubi0: scanning is finished
> ubi0: empty MTD device detected
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 5062 at mm/vmalloc.c:3319 __vmalloc_node_range+0x1065/0x1540 mm/vmalloc.c:3319
> Modules linked in:
> CPU: 0 PID: 5062 Comm: syz-executor167 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
> RIP: 0010:__vmalloc_node_range+0x1065/0x1540 mm/vmalloc.c:3319
> Code: 48 8b 7d 08 e8 bc db ff ff 48 39 c5 0f 85 f3 02 00 00 e8 5e 9e b2 ff 48 89 ef e8 26 8f 02 00 e9 c2 f9 ff ff e8 4c 9e b2 ff 90 <0f> 0b 90 31 db e8 41 9e b2 ff 48 b8 00 00 00 00 00 fc ff df 4d 8d
> RSP: 0018:ffffc900033df918 EFLAGS: 00010293
> RAX: 0000000000000000 RBX: dffffc0000000000 RCX: ffffffff81da4ac2
> RDX: ffff88801976da00 RSI: ffffffff81da5a64 RDI: 0000000000000007
> RBP: ffffffff85f10bf9 R08: 0000000000000007 R09: 0000000000000000
> R10: 0000000000000000 R11: ffffffff8ae00126 R12: 0000000000000000
> R13: 1ffff9200067bf3e R14: 0000000000000000 R15: ffff88802ef1a600
> FS: 000055556b89e380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000045e620 CR3: 0000000022954000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> __vmalloc_node mm/vmalloc.c:3457 [inline]
> vzalloc+0x6b/0x90 mm/vmalloc.c:3530
> create_empty_lvol drivers/mtd/ubi/vtbl.c:490 [inline]
> ubi_read_volume_table+0x639/0x2a30 drivers/mtd/ubi/vtbl.c:812
> ubi_attach+0x1a2f/0x4af0 drivers/mtd/ubi/attach.c:1601
> ubi_attach_mtd_dev+0x1659/0x3950 drivers/mtd/ubi/build.c:1000
> ctrl_cdev_ioctl+0x339/0x3d0 drivers/mtd/ubi/cdev.c:1043
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:904 [inline]
> __se_sys_ioctl fs/ioctl.c:890 [inline]
> __x64_sys_ioctl+0x193/0x220 fs/ioctl.c:890
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x6d/0x75
> RIP: 0033:0x7fbab2531369
> Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 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:00007ffcb56bd0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00007ffcb56bd298 RCX: 00007fbab2531369
> RDX: 0000000020000504 RSI: 0000000040186f40 RDI: 0000000000000003
> RBP: 00007fbab25a4610 R08: 0000000000000000 R09: 00007ffcb56bd298
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
> R13: 00007ffcb56bd288 R14: 0000000000000001 R15: 0000000000000001
> </TASK>
>
>
> ---
> 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 [email protected].
>
> 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
> .
>

It's weird, commit fe46a7dd189e2("Merge tag 'sound-6.9-rc1' of ..") is
ahead of commit 68a24aba7c593eaf("ubi: Check for too small LEB size in
VTBL code") according to 'git log', but 68a24aba7c593eaf("ubi: Check for
too small LEB size in VTBL code") is not applied after reseting to
fe46a7dd189e2("Merge tag 'sound-6.9-rc1' of ..").
Whatever, the problem has been fixed by 68a24aba7c593eaf("ubi: Check for
too small LEB size in VTBL code").