WARNING in io_pin_pages (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 83f1454877cc Merge tag 'ext4_for_linus-7.2-rc1' of git://g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1211daae580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fef3a5f0899512 dashboard link: https://syzkaller.appspot.com/bug?extid=f99b00a963915b6b52c6 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=164b12ae580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165bb986580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/87171ffb708f/disk-83f14548.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cf1d27787991/vmlinux-83f14548.xz
kernel image: https://storage.googleapis.com/syzbot-assets/6e9a56090e11/bzImage-83f14548.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
------------[ cut here ]------------ !(flags & __GFP_NOWARN) WARNING: mm/slub.c:6841 at __kvmalloc_node_noprof+0x6f7/0xa60 mm/slub.c:6841, CPU#1: syz.0.17/5823 Modules linked in: CPU: 1 UID: 0 PID: 5823 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 RIP: 0010:__kvmalloc_node_noprof+0x6f7/0xa60 mm/slub.c:6841 Code: c1 e8 5d 0f ff ff 4d 85 f6 0f 85 21 fd ff ff 48 81 fb ff ff ff 7f 0f 86 b8 fc ff ff 41 81 e4 00 20 00 00 0f 85 07 fd ff ff 90 <0f> 0b 90 e9 fe fc ff ff be 43 01 00 00 48 c7 c7 22 f2 f1 8d e8 a0 RSP: 0018:ffffc9000249fa88 EFLAGS: 00010246 RAX: 0000000000000001 RBX: 0000000080000008 RCX: 0000000100000000 RDX: 0000000000000000 RSI: ffffffff8c1d1100 RDI: ffffffff8e1e6928 RBP: 000000d6000000ca R08: 00000000004028c0 R09: 00000000ffffffff R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: 00000000ffffffff R14: 0000000000000000 R15: 00000000004028c0 FS: 000055556bd29500(0000) GS:ffff88812442d000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd3d173e44 CR3: 0000000076c8e000 CR4: 00000000003526f0 Call Trace: <TASK> io_pin_pages+0xc3/0x1e0 io_uring/memmap.c:59 io_sqe_buffer_register+0x1d9/0x1500 io_uring/rsrc.c:884 io_sqe_buffers_register.cold+0x346/0x4c3 io_uring/rsrc.c:995 __io_uring_register io_uring/register.c:767 [inline] __do_sys_io_uring_register+0x13ce/0x1bc0 io_uring/register.c:1029 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x840 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fcd6539ce59 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 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 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffc5b4af188 EFLAGS: 00000246 ORIG_RAX: 00000000000001ab RAX: ffffffffffffffda RBX: 00007fcd65615fa0 RCX: 00007fcd6539ce59 RDX: 0000200000000000 RSI: 0000000000000000 RDI: 0000000000000002 RBP: 00007fcd65432e6f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fcd65615fac R14: 00007fcd65615fa0 R15: 00007fcd65615fa0 </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
syzbot
syzbotForwarded: [PATCH] io_uring/memmap: bound io_pin_pages() by page array byte size
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject: [PATCH] io_uring/memmap: bound io_pin_pages() by page array byte size
Author: [email protected]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
io_pin_pages() checks that nr_pages does not exceed INT_MAX, then allocates a struct page * array of nr_pages entries. kvmalloc() limits allocations to INT_MAX bytes, but the check counts pages, not bytes. On 64-bit each entry is 8 bytes, so the array hits the INT_MAX byte limit at INT_MAX / sizeof(struct page *) pages, well before the page count check fires.
Since commit d760d3f59f0d ("io_uring/rsrc: raise registered buffer 1GB limit") raised the per-buffer cap to 1TB, a buffer near that cap maps ~2^28 pages, making the array allocation exceed INT_MAX bytes. This passes the page count check, reaches kvmalloc(), and triggers the WARN_ON_ONCE() for oversized allocations in __kvmalloc_node_noprof().
Check nr_pages against INT_MAX / sizeof(struct page *) so the buffer is rejected with -EOVERFLOW before the allocation is attempted.
--- io_uring/memmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/memmap.c +1 -1
@@ -53,7 +53,7 @@ struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages) nr_pages = end - start;if (WARN_ON_ONCE (!nr_pages))return ERR_PTR (-EINVAL ); -if (WARN_ON_ONCE (nr_pages >INT_MAX )) +if (nr_pages >INT_MAX /sizeof (struct page *))return ERR_PTR (-EOVERFLOW ); pages = kvmalloc_objs(struct page *, nr_pages, GFP_KERNEL_ACCOUNT);
Signature · 1 line
2.43.0