public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* Re: [syzbot] [mm?] WARNING in alloc_frozen_pages_noprof (2)
       [not found] <6a150a33.2b0a0220.185dbd.0005.GAE@google.com>
@ 2026-05-26 19:58 ` Andrew Morton
  2026-05-27  9:58   ` [PATCH] drm/lease: Limit amount of maximum objects per lease Maarten Lankhorst
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-05-26 19:58 UTC (permalink / raw)
  To: syzbot
  Cc: apopple, byungchul, david, gourry, joshua.hahnjy, linux-kernel,
	linux-mm, matthew.brost, rakie.kim, syzkaller-bugs, ying.huang,
	ziy, dri-devel, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter

On Mon, 25 May 2026 19:49:23 -0700 syzbot <syzbot+5d32c8bd82427f9c77cc@syzkaller.appspotmail.com> wrote:

> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    4cbfe4502e3d Merge tag 'v7.1-rc5-ksmbd-server-fixes' of gi..
> git tree:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux master
> console output: https://syzkaller.appspot.com/x/log.txt?x=146c161f980000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=9475bd041c93289
> dashboard link: https://syzkaller.appspot.com/bug?extid=5d32c8bd82427f9c77cc
> compiler:       aarch64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
> userspace arch: arm64
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11026336580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ab9796580000

Thanks.

> Downloadable assets:
> disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/fa3fbcfdac58/non_bootable_disk-4cbfe450.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/e825a08fb48d/vmlinux-4cbfe450.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/55037c053ec3/Image-4cbfe450.gz.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+5d32c8bd82427f9c77cc@syzkaller.appspotmail.com
> 
> ------------[ cut here ]------------
> WARNING: mm/page_alloc.c:5202 at __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202, CPU#0: syz.2.17/3592

	if (WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp))

> Modules linked in:
> CPU: 0 UID: 0 PID: 3592 Comm: syz.2.17 Not tainted syzkaller #0 PREEMPT 
> Hardware name: linux,dummy-virt (DT)
> pstate: 21402009 (nzCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
> pc : __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202
> lr : alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
> sp : ffff800085d93900
> x29: ffff800085d93a00 x28: 000000000000000b x27: 0000000000000000
> x26: 0000000000000000 x25: fcf0000014c00000 x24: 0000000000040dc0
> x23: 0000000000000000 x22: 0000000000000000 x21: 000000000000000b
> x20: ffffffffffffffff x19: 0000000000000000 x18: 0000000000000002
> x17: 0000000000000000 x16: 0000000000000000 x15: 0000000020000200
> x14: ffff8000828b2000 x13: ffffc1ffc0000000 x12: 0000000000000001
> x11: 0000000000000000 x10: ffff800082b6f4e8 x9 : 0000000000000000
> x8 : 0000000000000030 x7 : ffff800082e9b430 x6 : 0000000000000001
> x5 : 0000000000000000 x4 : f3f00000065c90c0 x3 : 0000000000000000
> x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffff800082dfd000
> Call trace:
>  __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202 (P)
>  alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
>  alloc_frozen_pages_noprof+0x48/0xd4 mm/mempolicy.c:2561
>  ___kmalloc_large_node+0x11c/0x13c mm/slub.c:5237
>  __kmalloc_large_node_noprof mm/slub.c:5268 [inline]
>  __do_kmalloc_node mm/slub.c:5284 [inline]
>  __kmalloc_noprof+0x450/0x560 mm/slub.c:5308
>  kmalloc_noprof include/linux/slab.h:954 [inline]
>  kzalloc_noprof include/linux/slab.h:1188 [inline]
>  fill_object_idr drivers/gpu/drm/drm_lease.c:389 [inline]
>  drm_mode_create_lease_ioctl+0x184/0x93c drivers/gpu/drm/drm_lease.c:521
>  drm_ioctl_kernel+0xc0/0x130 drivers/gpu/drm/drm_ioctl.c:804
>  drm_ioctl+0x258/0x580 drivers/gpu/drm/drm_ioctl.c:901
>  vfs_ioctl fs/ioctl.c:51 [inline]

Methinks drm_mode_create_lease_ioctl() wants some more arg checking.

otoh, memdup_user() passes __GFP_NOWARN, so perhaps
__alloc_frozen_pages_noprof() should be taught to honor that.

>  __do_sys_ioctl fs/ioctl.c:597 [inline]
>  __se_sys_ioctl fs/ioctl.c:583 [inline]
>  __arm64_sys_ioctl+0xac/0x104 fs/ioctl.c:583
>  __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
>  invoke_syscall+0x54/0x10c arch/arm64/kernel/syscall.c:49
>  el0_svc_common.constprop.0+0x40/0xe0 arch/arm64/kernel/syscall.c:121
>  do_el0_svc+0x1c/0x34 arch/arm64/kernel/syscall.c:140
>  el0_svc+0x38/0x140 arch/arm64/kernel/entry-common.c:740
>  el0t_64_sync_handler+0xa0/0xf0 arch/arm64/kernel/entry-common.c:759
>  el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:594
> ---[ end trace 0000000000000000 ]---


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

* [PATCH] drm/lease: Limit amount of maximum objects per lease.
  2026-05-26 19:58 ` [syzbot] [mm?] WARNING in alloc_frozen_pages_noprof (2) Andrew Morton
@ 2026-05-27  9:58   ` Maarten Lankhorst
  2026-05-28  2:30     ` Claude review: " Claude Code Review Bot
  0 siblings, 1 reply; 3+ messages in thread
From: Maarten Lankhorst @ 2026-05-27  9:58 UTC (permalink / raw)
  To: Andrew Morton, syzbot
  Cc: apopple, byungchul, david, gourry, joshua.hahnjy, linux-kernel,
	linux-mm, matthew.brost, rakie.kim, syzkaller-bugs, ying.huang,
	ziy, dri-devel, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter

Hey,

Den 2026-05-26 kl. 21:58, skrev Andrew Morton:
> On Mon, 25 May 2026 19:49:23 -0700 syzbot <syzbot+5d32c8bd82427f9c77cc@syzkaller.appspotmail.com> wrote:
> 
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit:    4cbfe4502e3d Merge tag 'v7.1-rc5-ksmbd-server-fixes' of gi..
>> git tree:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux master
>> console output: https://syzkaller.appspot.com/x/log.txt?x=146c161f980000
>> kernel config:  https://syzkaller.appspot.com/x/.config?x=9475bd041c93289
>> dashboard link: https://syzkaller.appspot.com/bug?extid=5d32c8bd82427f9c77cc
>> compiler:       aarch64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
>> userspace arch: arm64
>> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11026336580000
>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ab9796580000
> 
> Thanks.
> 
>> Downloadable assets:
>> disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/fa3fbcfdac58/non_bootable_disk-4cbfe450.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/e825a08fb48d/vmlinux-4cbfe450.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/55037c053ec3/Image-4cbfe450.gz.xz
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+5d32c8bd82427f9c77cc@syzkaller.appspotmail.com
>>
>> ------------[ cut here ]------------
>> WARNING: mm/page_alloc.c:5202 at __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202, CPU#0: syz.2.17/3592
> 
> 	if (WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp))
> 
>> Modules linked in:
>> CPU: 0 UID: 0 PID: 3592 Comm: syz.2.17 Not tainted syzkaller #0 PREEMPT 
>> Hardware name: linux,dummy-virt (DT)
>> pstate: 21402009 (nzCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
>> pc : __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202
>> lr : alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
>> sp : ffff800085d93900
>> x29: ffff800085d93a00 x28: 000000000000000b x27: 0000000000000000
>> x26: 0000000000000000 x25: fcf0000014c00000 x24: 0000000000040dc0
>> x23: 0000000000000000 x22: 0000000000000000 x21: 000000000000000b
>> x20: ffffffffffffffff x19: 0000000000000000 x18: 0000000000000002
>> x17: 0000000000000000 x16: 0000000000000000 x15: 0000000020000200
>> x14: ffff8000828b2000 x13: ffffc1ffc0000000 x12: 0000000000000001
>> x11: 0000000000000000 x10: ffff800082b6f4e8 x9 : 0000000000000000
>> x8 : 0000000000000030 x7 : ffff800082e9b430 x6 : 0000000000000001
>> x5 : 0000000000000000 x4 : f3f00000065c90c0 x3 : 0000000000000000
>> x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffff800082dfd000
>> Call trace:
>>  __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202 (P)
>>  alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
>>  alloc_frozen_pages_noprof+0x48/0xd4 mm/mempolicy.c:2561
>>  ___kmalloc_large_node+0x11c/0x13c mm/slub.c:5237
>>  __kmalloc_large_node_noprof mm/slub.c:5268 [inline]
>>  __do_kmalloc_node mm/slub.c:5284 [inline]
>>  __kmalloc_noprof+0x450/0x560 mm/slub.c:5308
>>  kmalloc_noprof include/linux/slab.h:954 [inline]
>>  kzalloc_noprof include/linux/slab.h:1188 [inline]
>>  fill_object_idr drivers/gpu/drm/drm_lease.c:389 [inline]
>>  drm_mode_create_lease_ioctl+0x184/0x93c drivers/gpu/drm/drm_lease.c:521
>>  drm_ioctl_kernel+0xc0/0x130 drivers/gpu/drm/drm_ioctl.c:804
>>  drm_ioctl+0x258/0x580 drivers/gpu/drm/drm_ioctl.c:901
>>  vfs_ioctl fs/ioctl.c:51 [inline]
> 
> Methinks drm_mode_create_lease_ioctl() wants some more arg checking.
> 
> otoh, memdup_user() passes __GFP_NOWARN, so perhaps
> __alloc_frozen_pages_noprof() should be taught to honor that.
> 

A lot of places assume max 32 planes, connectors and crtc's per device.
drm_plane_mask(), drm_connector_mask and drm_crtc_mask are an example.

It wouldn't be too hard to cap it to 96 (or 8 * sizeof(drm_plane_mask(NULL) + ...)
in case it changes. Anything above it will need fixing in a lot of places anyway.

Kind regards,
~Maarten Lankhorst

What about the below?

>>  __do_sys_ioctl fs/ioctl.c:597 [inline]
>>  __se_sys_ioctl fs/ioctl.c:583 [inline]
>>  __arm64_sys_ioctl+0xac/0x104 fs/ioctl.c:583
>>  __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
>>  invoke_syscall+0x54/0x10c arch/arm64/kernel/syscall.c:49
>>  el0_svc_common.constprop.0+0x40/0xe0 arch/arm64/kernel/syscall.c:121
>>  do_el0_svc+0x1c/0x34 arch/arm64/kernel/syscall.c:140
>>  el0_svc+0x38/0x140 arch/arm64/kernel/entry-common.c:740
>>  el0t_64_sync_handler+0xa0/0xf0 arch/arm64/kernel/entry-common.c:759
>>  el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:594
>> ---[ end trace 0000000000000000 ]---
> 
-- >8 --
There's no practical limit currently to the amount of objects inside the lease ioctl.
Limit it to 96 for now, the maximum of plane_mask + crtc_mask + connector_mask.

I believe this is sufficient on all platforms, and fixes the backtrace below.

------------[ cut here ]------------
WARNING: mm/page_alloc.c:5202 at __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202, CPU#0: syz.2.17/3592

	if (WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp))

Modules linked in:
CPU: 0 UID: 0 PID: 3592 Comm: syz.2.17 Not tainted syzkaller #0 PREEMPT 
Hardware name: linux,dummy-virt (DT)
pstate: 21402009 (nzCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202
lr : alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
sp : ffff800085d93900
x29: ffff800085d93a00 x28: 000000000000000b x27: 0000000000000000
x26: 0000000000000000 x25: fcf0000014c00000 x24: 0000000000040dc0
x23: 0000000000000000 x22: 0000000000000000 x21: 000000000000000b
x20: ffffffffffffffff x19: 0000000000000000 x18: 0000000000000002
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000020000200
x14: ffff8000828b2000 x13: ffffc1ffc0000000 x12: 0000000000000001
x11: 0000000000000000 x10: ffff800082b6f4e8 x9 : 0000000000000000
x8 : 0000000000000030 x7 : ffff800082e9b430 x6 : 0000000000000001
x5 : 0000000000000000 x4 : f3f00000065c90c0 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffff800082dfd000
Call trace:
 __alloc_frozen_pages_noprof+0x734/0x1144 mm/page_alloc.c:5202 (P)
 alloc_pages_mpol+0x70/0x1a4 mm/mempolicy.c:2490
 alloc_frozen_pages_noprof+0x48/0xd4 mm/mempolicy.c:2561
 ___kmalloc_large_node+0x11c/0x13c mm/slub.c:5237
 __kmalloc_large_node_noprof mm/slub.c:5268 [inline]
 __do_kmalloc_node mm/slub.c:5284 [inline]
 __kmalloc_noprof+0x450/0x560 mm/slub.c:5308
 kmalloc_noprof include/linux/slab.h:954 [inline]
 kzalloc_noprof include/linux/slab.h:1188 [inline]
 fill_object_idr drivers/gpu/drm/drm_lease.c:389 [inline]
 drm_mode_create_lease_ioctl+0x184/0x93c drivers/gpu/drm/drm_lease.c:521
 drm_ioctl_kernel+0xc0/0x130 drivers/gpu/drm/drm_ioctl.c:804
 drm_ioctl+0x258/0x580 drivers/gpu/drm/drm_ioctl.c:901
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __arm64_sys_ioctl+0xac/0x104 fs/ioctl.c:583
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x54/0x10c arch/arm64/kernel/syscall.c:49
 el0_svc_common.constprop.0+0x40/0xe0 arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x1c/0x34 arch/arm64/kernel/syscall.c:140
 el0_svc+0x38/0x140 arch/arm64/kernel/entry-common.c:740
 el0t_64_sync_handler+0xa0/0xf0 arch/arm64/kernel/entry-common.c:759
 el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:594
---[ end trace 0000000000000000 ]---

Reported-by: syzbot+5d32c8bd82427f9c77cc@syzkaller.appspotmail.com
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
index 5d2cf724cbd7b..9d0ccc8e0274f 100644
--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -486,6 +486,10 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
 	struct drm_file *lessee_priv;
 	int fd = -1;
 	uint32_t *object_ids;
+	static const size_t max_objects =
+		8 * sizeof(drm_crtc_mask(NULL)) +
+		8 * sizeof(drm_plane_mask(NULL)) +
+		8 * sizeof(drm_connector_mask(NULL));
 
 	/* Can't lease without MODESET */
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
@@ -505,6 +509,11 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
 	}
 
 	object_count = cl->object_count;
+	if (object_count > max_objects) {
+		drm_dbg_lease(dev, "too many objects (%ld)\n", object_count);
+		ret = -EINVAL;
+		goto out_lessor;
+	}
 
 	/* Handle leased objects, if any */
 	idr_init(&leases);


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

* Claude review: drm/lease: Limit amount of maximum objects per lease.
  2026-05-27  9:58   ` [PATCH] drm/lease: Limit amount of maximum objects per lease Maarten Lankhorst
@ 2026-05-28  2:30     ` Claude Code Review Bot
  0 siblings, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-28  2:30 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/lease: Limit amount of maximum objects per lease.
Author: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Patches: 1
Reviewed: 2026-05-28T12:30:53.798502

---

This is a single-patch fix for a syzkaller-reported bug where userspace can pass an arbitrarily large `object_count` to the `DRM_IOCTL_MODE_CREATE_LEASE` ioctl, causing `kzalloc_objs()` inside `fill_object_idr()` to attempt an allocation that exceeds `MAX_PAGE_ORDER`, triggering a `WARN_ON` in the page allocator. The fix caps `object_count` to 96 (the sum of the bit widths of the three relevant 32-bit mask types). The approach is sound and correctly placed, but there are a couple of issues that should be addressed before merging.

**Verdict: Needs minor fixes before applying.**

---

---
Generated by Claude Code Patch Reviewer

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

end of thread, other threads:[~2026-05-28  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <6a150a33.2b0a0220.185dbd.0005.GAE@google.com>
2026-05-26 19:58 ` [syzbot] [mm?] WARNING in alloc_frozen_pages_noprof (2) Andrew Morton
2026-05-27  9:58   ` [PATCH] drm/lease: Limit amount of maximum objects per lease Maarten Lankhorst
2026-05-28  2:30     ` Claude review: " Claude Code Review Bot

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