lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAEkJfYMqyx4_13X5-SJYCJ5JnY6MbPR7Bi2mM_n7KG5Ng8-2fA@mail.gmail.com>
Date: Wed, 10 Apr 2024 11:17:14 +0800
From: Sam Sun <samsun1006219@...il.com>
To: linux-kernel@...r.kernel.org, linux-block@...r.kernel.org, axboe@...nel.dk, 
	senozhatsky@...omium.org, minchan@...nel.org
Cc: xrivendell7@...il.com, syzkaller-bugs@...glegroups.com
Subject: [Linux Kernel bug] WARNING: zero-size vmalloc in disksize_store

Dear developers and maintainers,

We encountered a kernel warning in the function disksize_store during
testing using our modified syzkaller. It is tested against the latest
upstream linux (6.9-rc3). C repro and kernel config are attached to
this email. Kernel log is listed below.
```
------------[ cut here ]------------
WARNING: CPU: 1 PID: 8117 at mm/vmalloc.c:3247
__vmalloc_node_range+0x10a0/0x1490 mm/vmalloc.c:3247
Modules linked in:
CPU: 1 PID: 8117 Comm: syz-executor233 Not tainted 6.7.0-rc7 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:__vmalloc_node_range+0x10a0/0x1490 mm/vmalloc.c:3247
Code: 65 48 2b 04 25 28 00 00 00 0f 85 98 02 00 00 48 81 c4 70 01 00
00 4c 89 e0 5b 5d 41 5c 41 5d 41 5e 41 5f c3 e8 e1 47 b7 ff 90 <0f> 0b
90 45 31 e4 eb a1 e8 d3 47 b7 ff 48 8b 4c 24 40 31 f6 45 31
RSP: 0018:ffffc90002a1fa88 EFLAGS: 00010293
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: ffffffff81cdbd54
RDX: ffff88802080a4c0 RSI: ffffffff81cdcd2f RDI: 0000000000000007
RBP: 0000000000000000 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: ffff8880176b2fe8
R13: 0000000000000000 R14: 0000000000000000 R15: ffff88801a85a918
FS:  00005555559e03c0(0000) GS:ffff888135c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000260 CR3: 000000010c948000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
 <TASK>
 __vmalloc_node mm/vmalloc.c:3385 [inline]
 vzalloc+0x6b/0x80 mm/vmalloc.c:3458
 zram_meta_alloc drivers/block/zram/zram_drv.c:1233 [inline]
 disksize_store+0x10a/0x5b0 drivers/block/zram/zram_drv.c:2031
 dev_attr_store+0x54/0x80 drivers/base/core.c:2366
 sysfs_kf_write+0x114/0x170 fs/sysfs/file.c:136
 kernfs_fop_write_iter+0x337/0x500 fs/kernfs/file.c:334
 call_write_iter include/linux/fs.h:2020 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x96a/0xd80 fs/read_write.c:584
 ksys_write+0x122/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f652768bfcd
Code: 28 c3 e8 26 1f 00 00 66 0f 1f 44 00 00 f3 0f 1e fa 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:00007ffed7908618 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007ffed7908818 RCX: 00007f652768bfcd
RDX: 0000000000000015 RSI: 0000000020000280 RDI: 0000000000000003
RBP: 0000000000000001 R08: 0000000000000000 R09: 00007ffed7908818
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffed7908808 R14: 00007f6527709530 R15: 0000000000000001
 </TASK>
```
We analyzed the root cause of this warning. Argument char *buf is a
user controlled string, which could be an arbitrary large number (in
this case is "18446744073709551615", which is -1 in unsigned long
long). Function memparse() in line 2018 calls simple_strtoull() to
convert this string into an unsigned long number, so that disksize
bypass the check in the next line. After the PAGE_ALIGN, disksize is
overflowed and turns to zero. disksize then be passed to
zram_meta_alloc(), causing a zero-size vmalloc.

One possible fix is to lift PAGE_ALIGN right after memparse(), so that
the check would not be bypassed.

If you have any questions, please contact us.
Reported by: Yue Sun <samsun1006219@...il.com>
Reported by: xingwei lee <xrivendell7@...il.com>

Best Regards,
Yue

Download attachment "config" of type "application/octet-stream" (247856 bytes)

View attachment "disksize_store.c" of type "text/x-csrc" (1266 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ