[syzbot] [trace?] WARNING in bitmap_parse_user

14 views
Skip to first unread message

syzbot

unread,
Dec 15, 2024, 6:05:23 PM12/15/24
to linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, mathieu....@efficios.com, mhir...@kernel.org, ros...@goodmis.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: f92f4749861b Merge tag 'clk-fixes-for-linus' of git://git...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=179d04f8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=99a5586995ec03b2
dashboard link: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
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=11466cdf980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15466cdf980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b85403132ddc/disk-f92f4749.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/20613d034287/vmlinux-f92f4749.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d1ea80bf7e4e/bzImage-f92f4749.xz

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

------------[ cut here ]------------
WARNING: CPU: 0 PID: 5820 at mm/page_alloc.c:4727 __alloc_pages_noprof+0xeff/0x25b0 mm/page_alloc.c:4727
Modules linked in:
CPU: 0 UID: 0 PID: 5820 Comm: syz-executor318 Not tainted 6.13.0-rc2-syzkaller-00031-gf92f4749861b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:__alloc_pages_noprof+0xeff/0x25b0 mm/page_alloc.c:4727
Code: 24 2c 00 00 00 00 89 cd 0f 84 8b f9 ff ff 8b 34 24 48 89 da 8b 7c 24 08 e8 0e b3 fe ff e9 69 f9 ff ff c6 05 21 45 16 0e 01 90 <0f> 0b 90 31 db e9 9f f3 ff ff 89 14 24 e8 9f a2 0c 00 8b 14 24 e9
RSP: 0018:ffffc90003eef958 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 000000000000000b RDI: 0000000000040cc0
RBP: 0000000000000000 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000000 R12: 000000000000000b
R13: 0000000000040cc0 R14: 1ffff920007ddf3f R15: 00000000ffffffff
FS: 000055558bef6380(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000580 CR3: 000000007d0f0000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
___kmalloc_large_node+0x84/0x1b0 mm/slub.c:4228
__kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:4255
__do_kmalloc_node mm/slub.c:4271 [inline]
__kmalloc_node_track_caller_noprof.cold+0x5/0x5f mm/slub.c:4302
memdup_user_nul+0x2b/0x110 mm/util.c:305
bitmap_parse_user+0x24/0x90 lib/bitmap-str.c:31
cpumask_parse_user include/linux/cpumask.h:876 [inline]
tracing_cpumask_write+0xfc/0x1a0 kernel/trace/trace.c:5231
vfs_write+0x24c/0x1150 fs/read_write.c:677
ksys_write+0x12b/0x250 fs/read_write.c:731
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc57b8672a9
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:00007fffd0ca10e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fffd0ca12c8 RCX: 00007fc57b8672a9
RDX: 000000000040fdef RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007fc57b8da610 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffd0ca12b8 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 syzk...@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

Lizhi Xu

unread,
Dec 15, 2024, 7:55:39 PM12/15/24
to syzbot+0aecfd...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
If either a zero count or a large one is provided, will triger a warning in bitmap_parse_user.

#syz test

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index be62f0ea1814..9e989d97bb78 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5224,6 +5224,8 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
struct trace_array *tr = file_inode(filp)->i_private;
cpumask_var_t tracing_cpumask_new;
int err;
+ if (count == 0 || count > PAGE_SIZE)
+ return -EINVAL;

if (!zalloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
return -ENOMEM;

syzbot

unread,
Dec 15, 2024, 8:15:04 PM12/15/24
to linux-...@vger.kernel.org, lizh...@windriver.com, syzkall...@googlegroups.com
Hello,

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

Reported-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Tested-by: syzbot+0aecfd...@syzkaller.appspotmail.com

Tested on:

commit: 78d4f34e Linux 6.13-rc3
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14521730580000
kernel config: https://syzkaller.appspot.com/x/.config?x=9cac7e24ceea492
dashboard link: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
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=17421730580000

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

Lizhi Xu

unread,
Dec 15, 2024, 8:56:34 PM12/15/24
to syzbot+0aecfd...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
User input a too large count 0x40fdef, it will triger a warning in bitmap_parse_user.

#syz test

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index be62f0ea1814..9e989d97bb78 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5224,6 +5224,8 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
struct trace_array *tr = file_inode(filp)->i_private;
cpumask_var_t tracing_cpumask_new;
int err;
+ if (count == 0 || count << PAGE_SHIFT > MAX_PAGE_ORDER)

syzbot

unread,
Dec 15, 2024, 9:16:03 PM12/15/24
to linux-...@vger.kernel.org, lizh...@windriver.com, syzkall...@googlegroups.com
Hello,

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

Reported-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Tested-by: syzbot+0aecfd...@syzkaller.appspotmail.com

Tested on:

commit: 78d4f34e Linux 6.13-rc3
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1272d4f8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=9cac7e24ceea492
dashboard link: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
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=11ef87e8580000

Lizhi Xu

unread,
Dec 15, 2024, 9:28:12 PM12/15/24
to syzbot+0aecfd...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, mathieu....@efficios.com, mhir...@kernel.org, ros...@goodmis.org, syzkall...@googlegroups.com
If a large count is provided, it will triger a warning in bitmap_parse_user.
Also check zero for it.

Reported-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
Tested-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizh...@windriver.com>
---
kernel/trace/trace.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index be62f0ea1814..109f301549b8 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5225,6 +5225,9 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
cpumask_var_t tracing_cpumask_new;
int err;

+ if (count == 0 || count << PAGE_SHIFT > MAX_PAGE_ORDER)
+ return -EINVAL;
+
if (!zalloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
return -ENOMEM;

--
2.43.0

Lizhi Xu

unread,
Dec 16, 2024, 2:33:15 AM12/16/24
to syzbot+0aecfd...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, mathieu....@efficios.com, mhir...@kernel.org, ros...@goodmis.org, syzkall...@googlegroups.com
If a large count is provided, it will triger a warning in bitmap_parse_user.
Also check zero for it.

Reported-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
Tested-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizh...@windriver.com>
---
V1 -> V2: use KMALLOC_MAX_SIZE

kernel/trace/trace.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index be62f0ea1814..109f301549b8 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5225,6 +5225,9 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
cpumask_var_t tracing_cpumask_new;
int err;

+ if (count == 0 || count > KMALLOC_MAX_SIZE)

Edward Adam Davis

unread,
Dec 16, 2024, 7:29:08 AM12/16/24
to syzbot+0aecfd...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test

diff --git a/mm/util.c b/mm/util.c
index c1c3b06ab4f9..1845d649b171 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -302,7 +302,7 @@ void *memdup_user_nul(const void __user *src, size_t len)
* cause pagefault, which makes it pointless to use GFP_NOFS
* or GFP_ATOMIC.
*/
- p = kmalloc_track_caller(len + 1, GFP_KERNEL);
+ p = kmalloc_track_caller(len + 1, GFP_KERNEL | __GFP_NOWARN);
if (!p)
return ERR_PTR(-ENOMEM);


syzbot

unread,
Dec 16, 2024, 7:49:03 AM12/16/24
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

Reported-by: syzbot+0aecfd...@syzkaller.appspotmail.com
Tested-by: syzbot+0aecfd...@syzkaller.appspotmail.com

Tested on:

commit: 78d4f34e Linux 6.13-rc3
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1713f344580000
kernel config: https://syzkaller.appspot.com/x/.config?x=9cac7e24ceea492
dashboard link: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
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=1003f344580000
Reply all
Reply to author
Forward
0 new messages