On 11/8/24 6:28 AM, Yeqi Fu wrote:
Hi there, A warning is triggered in lib/vsprintf.c due to an unsupported '%' in a format string. This issue occurs in the function format_decode at line 2659 of kernel version 6.12.0-rc3-gb22db8b8befe. A proof-of-concept is available, and I have manually reproduced this bug.
I think the below patch set (not merged yet) https://lore.kernel.org/bpf/20241028195343.2104-1-rabbelkin@xxxxxxx/ should fix this issue.
Report: ``` Please remove unsupported % in format string WARNING: CPU: 1 PID: 29307 at lib/vsprintf.c:2659 format_decode+0x121a/0x1c00 lib/vsprintf.c:2659 Modules linked in: CPU: 1 UID: 0 PID: 29307 Comm: syz.5.9298 Not tainted 6.12.0-rc3-gb22db8b8befe #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 RIP: 0010:format_decode+0x121a/0x1c00 lib/vsprintf.c:2659 Code: 8b 9c 24 80 00 00 00 48 89 d8 48 c1 e8 03 42 8a 04 30 84 c0 0f 85 d5 09 00 00 0f b6 33 48 c7 c7 00 bd eb 92 e8 b7 59 67 fc 90 <0f> 0b 90 90 4d 89 f7 48 8b 5c 24 18 e9 d7 fc ff ff 89 d1 80 e1 07 RSP: 0018:ffff888041197600 EFLAGS: 00010246 RAX: ea46d93351edcc00 RBX: ffff88804119792c RCX: ffff888009a78000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff8880411976f0 R08: ffffffff8ebc8e3b R09: 1ffff1100d9e515a R10: dffffc0000000000 R11: ffffed100d9e515b R12: ffff0000ffffff00 R13: ffff888041197700 R14: dffffc0000000000 R15: dffffc0000000000 FS: 00007fbe06321640(0000) GS:ffff88806cf00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020a8c000 CR3: 00000000404b6005 CR4: 0000000000370ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> bstr_printf+0x136/0x1260 lib/vsprintf.c:3232 ____bpf_trace_printk kernel/trace/bpf_trace.c:389 [inline] bpf_trace_printk+0x1a1/0x220 kernel/trace/bpf_trace.c:374 bpf_prog_7ee8fe4dad0c4460+0x4e/0x50 bpf_dispatcher_nop_func include/linux/bpf.h:1257 [inline] __bpf_prog_run include/linux/filter.h:692 [inline] bpf_prog_run include/linux/filter.h:708 [inline] bpf_test_run+0x7a9/0x910 net/bpf/test_run.c:433 bpf_prog_test_run_skb+0xc47/0x1750 net/bpf/test_run.c:1094 bpf_prog_test_run+0x2df/0x350 kernel/bpf/syscall.c:4247 __sys_bpf+0x484/0x850 kernel/bpf/syscall.c:5652 __do_sys_bpf kernel/bpf/syscall.c:5741 [inline] __se_sys_bpf kernel/bpf/syscall.c:5739 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5739 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd8/0x1c0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x67/0x6f RIP: 0033:0x7fbe07ccd72d Code: 02 b8 ff ff ff ff c3 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fbe06320f98 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007fbe07ea5f80 RCX: 00007fbe07ccd72d RDX: 0000000000000050 RSI: 0000000020000700 RDI: 000000000000000a RBP: 00007fbe07d57584 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fbe07ea5f80 R15: 00007fbe06301000 </TASK> irq event stamp: 39314 hardirqs last enabled at (39324): [<ffffffff8ed766cb>] __up_console_sem kernel/printk/printk.c:344 [inline] hardirqs last enabled at (39324): [<ffffffff8ed766cb>] __console_unlock+0xfb/0x130 kernel/printk/printk.c:2844 hardirqs last disabled at (39335): [<ffffffff8ed766b0>] __up_console_sem kernel/printk/printk.c:342 [inline] hardirqs last disabled at (39335): [<ffffffff8ed766b0>] __console_unlock+0xe0/0x130 kernel/printk/printk.c:2844 softirqs last enabled at (38482): [<ffffffff9195aaea>] bpf_test_run+0x31a/0x910 softirqs last disabled at (38484): [<ffffffff9195aaea>] bpf_test_run+0x31a/0x910 ---[ end trace 0000000000000000 ]--- ```
[...]