Files
linux/lib
Kuniyuki Iwashima 071876fd50 ref_tracker: Don't use __GFP_NOFAIL for PF_MEMALLOC thread.
syzbot triggered a warning in __alloc_pages_slowpath(). [0]

ref_tracker_alloc() uses __GFP_NOFAIL if the passed gfp has
__GFP_DIRECT_RECLAIM.

However, cifs_demultiplex_thread() calls memalloc_noreclaim_save()
and its kthread has PF_MEMALLOC.

As commented in __alloc_pages_slowpath(), __GFP_NOFAIL should
not be used for PF_MEMALLOC thread.

	if (unlikely(nofail)) {
...
		/*
		 * PF_MEMALLOC request from this context is rather bizarre
		 * because we cannot reclaim anything and only can loop waiting
                 * for somebody to do a work for us.
		 */
		WARN_ON_ONCE(current->flags & PF_MEMALLOC);

Let's avoid using __GFP_NOFAIL for PF_MEMALLOC thread.

[0]:
current->flags & PF_MEMALLOC
WARNING: mm/page_alloc.c:4816 at __alloc_pages_slowpath mm/page_alloc.c:4816 [inline], CPU#0: cifsd/12032
WARNING: mm/page_alloc.c:4816 at __alloc_frozen_pages_noprof+0x1eac/0x3300 mm/page_alloc.c:5449, CPU#0: cifsd/12032
Modules linked in:
CPU: 0 UID: 0 PID: 12032 Comm: cifsd Tainted: G             L      syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:__alloc_pages_slowpath mm/page_alloc.c:4816 [inline]
RIP: 0010:__alloc_frozen_pages_noprof+0x1eac/0x3300 mm/page_alloc.c:5449
Code: 38 d0 7c 08 84 d2 0f 85 de 12 00 00 65 48 8b 05 e2 a7 1c 12 c7 84 24 94 00 00 00 00 80 00 00 f6 40 2d 08 0f 84 ba e7 ff ff 90 <0f> 0b 90 e9 b1 e7 ff ff 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03
RSP: 0000:ffffc90002e172d0 EFLAGS: 00010202
RAX: ffff888029380000 RBX: 0000000000000000 RCX: 1ffff1100fffad29
RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffff88803fffd938
RBP: ffff88802938002c R08: 0000000000008000 R09: 0000000000000001
R10: 0000000000000002 R11: 0000000000000000 R12: 00000000000cac40
R13: ffff88803fffb900 R14: 0000000000000000 R15: 1ffff920005c2e74
FS:  0000000000000000(0000) GS:ffff888096955000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000008000a000 CR3: 00000000403b5000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 alloc_slab_page mm/slub.c:3347 [inline]
 allocate_slab mm/slub.c:3470 [inline]
 new_slab+0x1f6/0x6e0 mm/slub.c:3513
 refill_objects+0xe3/0x410 mm/slub.c:7417
 refill_sheaf mm/slub.c:2885 [inline]
 __pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774
 alloc_from_pcs mm/slub.c:4850 [inline]
 slab_alloc_node mm/slub.c:4984 [inline]
 __kmalloc_cache_noprof+0x4f4/0x6d0 mm/slub.c:5559
 _kmalloc_noprof include/linux/slab.h:991 [inline]
 _kzalloc_noprof include/linux/slab.h:1312 [inline]
 ref_tracker_alloc+0x190/0x590 lib/ref_tracker.c:270
 __netns_tracker_alloc include/net/net_namespace.h:370 [inline]
 sk_alloc+0xcfc/0xe80 net/core/sock.c:2329
 inet_create net/ipv4/af_inet.c:333 [inline]
 inet_create+0x3a0/0x1060 net/ipv4/af_inet.c:259
 __sock_create+0x339/0x860 net/socket.c:1676
 generic_ip_connect+0x826/0x1810 fs/smb/client/connect.c:3377
 __cifs_reconnect+0x348/0xa80 fs/smb/client/connect.c:420
 _cifs_reconnect fs/smb/client/connect.c:596 [inline]
 cifs_reconnect fs/smb/client/connect.c:610 [inline]
 cifs_readv_from_socket+0x7c1/0xa30 fs/smb/client/connect.c:749
 cifs_read_from_socket+0xb8/0x100 fs/smb/client/connect.c:804
 cifs_demultiplex_thread+0x2db/0x2ea0 fs/smb/client/connect.c:1295
 kthread+0x373/0x450 kernel/kthread.c:436
 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Cc: [email protected] # ref_tracker is debug instrumentation
Fixes: 4e66934eaa ("lib: add reference counting tracking infrastructure")
Reported-by: [email protected]
Closes: https://lore.kernel.org/netdev/[email protected]/
Signed-off-by: Kuniyuki Iwashima <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
2026-10-01 18:39:54 -07:00
..
2026-08-03 21:10:16 -07:00
2026-08-13 15:42:05 -07:00
2025-03-16 22:30:49 -07:00
…
…
2025-04-11 17:32:37 -07:00
2026-03-05 22:16:08 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-07-31 10:09:12 +02:00
2024-10-14 16:33:24 -05:00
…
…
2026-01-11 06:09:11 -10:00
2026-02-27 16:40:16 +01:00
…
…
2025-03-25 10:18:31 -03:00
2026-04-18 00:10:48 -07:00
…
2024-12-09 13:48:29 -08:00