linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [bpf?] [trace?] WARNING in format_decode (3)
@ 2023-11-21 22:43 syzbot
  2023-11-22  0:50 ` [PATCH net] bpf: test_run: fix WARNING in format_decode Edward Adam Davis
  0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2023-11-21 22:43 UTC (permalink / raw)
  To: andrii, ast, bpf, daniel, davem, edumazet, haoluo, hawk,
	john.fastabend, jolsa, kpsingh, kuba, linux-kernel,
	linux-trace-kernel, martin.lau, martin.lau, mhiramat, netdev,
	pabeni, rostedt, sdf, song, syzkaller-bugs, yhs, yonghong.song

Hello,

syzbot found the following issue on:

HEAD commit:    76df934c6d5f MAINTAINERS: Add netdev subsystem profile link
git tree:       net
console+strace: https://syzkaller.appspot.com/x/log.txt?x=10c2b667680000
kernel config:  https://syzkaller.appspot.com/x/.config?x=84217b7fc4acdc59
dashboard link: https://syzkaller.appspot.com/bug?extid=e2c932aec5c8a6e1d31c
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=12b2f668e80000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=171ea200e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/e271179068c6/disk-76df934c.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b9523b3749bb/vmlinux-76df934c.xz
kernel image: https://storage.googleapis.com/syzbot-assets/6c1a888bade0/bzImage-76df934c.xz

The issue was bisected to:

commit 114039b342014680911c35bd6b72624180fd669a
Author: Stanislav Fomichev <sdf@google.com>
Date:   Mon Nov 21 18:03:39 2022 +0000

    bpf: Move skb->len == 0 checks into __bpf_redirect

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13d237b7680000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=103237b7680000
console output: https://syzkaller.appspot.com/x/log.txt?x=17d237b7680000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e2c932aec5c8a6e1d31c@syzkaller.appspotmail.com
Fixes: 114039b34201 ("bpf: Move skb->len == 0 checks into __bpf_redirect")

------------[ cut here ]------------
Please remove unsupported %\0 in format string
WARNING: CPU: 0 PID: 5068 at lib/vsprintf.c:2675 format_decode+0xa03/0xba0 lib/vsprintf.c:2675
Modules linked in:
CPU: 0 PID: 5068 Comm: syz-executor288 Not tainted 6.7.0-rc1-syzkaller-00134-g76df934c6d5f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
RIP: 0010:format_decode+0xa03/0xba0 lib/vsprintf.c:2675
Code: f7 41 c6 44 24 05 08 e9 c4 fa ff ff e8 c6 f7 15 f7 c6 05 0b bd 91 04 01 90 48 c7 c7 60 5f 19 8c 40 0f b6 f5 e8 2e 17 dc f6 90 <0f> 0b 90 90 e9 17 fc ff ff 48 8b 3c 24 e8 4b 87 6c f7 e9 13 f7 ff
RSP: 0018:ffffc90003b6f798 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffffc90003b6fa0c RCX: ffffffff814db209
RDX: ffff8880214b9dc0 RSI: ffffffff814db216 RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: ffffc90003b6f898
R13: 0000000000000000 R14: 0000000000000000 R15: 00000000ffffffd0
FS:  000055555567c380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000f6f398 CR3: 00000000251e7000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 bstr_printf+0x13b/0x1050 lib/vsprintf.c:3248
 ____bpf_trace_printk kernel/trace/bpf_trace.c:386 [inline]
 bpf_trace_printk+0x10b/0x180 kernel/trace/bpf_trace.c:371
 bpf_prog_12183cdb1cd51dab+0x36/0x3a
 bpf_dispatcher_nop_func include/linux/bpf.h:1196 [inline]
 __bpf_prog_run include/linux/filter.h:651 [inline]
 bpf_prog_run include/linux/filter.h:658 [inline]
 bpf_test_run+0x3e1/0x9e0 net/bpf/test_run.c:423
 bpf_prog_test_run_skb+0xb75/0x1dd0 net/bpf/test_run.c:1045
 bpf_prog_test_run kernel/bpf/syscall.c:4040 [inline]
 __sys_bpf+0x11bf/0x4920 kernel/bpf/syscall.c:5401
 __do_sys_bpf kernel/bpf/syscall.c:5487 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5485 [inline]
 __x64_sys_bpf+0x78/0xc0 kernel/bpf/syscall.c:5485
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7fefcec014e9
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:00007ffca6179888 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007ffca6179a58 RCX: 00007fefcec014e9
RDX: 0000000000000028 RSI: 0000000020000080 RDI: 000000000000000a
RBP: 00007fefcec74610 R08: 0000000000000000 R09: 00007ffca6179a58
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffca6179a48 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 syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

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

* [PATCH net] bpf: test_run: fix WARNING in format_decode
  2023-11-21 22:43 [syzbot] [bpf?] [trace?] WARNING in format_decode (3) syzbot
@ 2023-11-22  0:50 ` Edward Adam Davis
  2023-11-22  5:28   ` Yonghong Song
  0 siblings, 1 reply; 4+ messages in thread
From: Edward Adam Davis @ 2023-11-22  0:50 UTC (permalink / raw)
  To: syzbot+e2c932aec5c8a6e1d31c
  Cc: andrii, ast, bpf, daniel, davem, edumazet, haoluo, hawk,
	john.fastabend, jolsa, kpsingh, kuba, linux-kernel,
	linux-trace-kernel, martin.lau, martin.lau, mhiramat, netdev,
	pabeni, rostedt, sdf, song, syzkaller-bugs, yhs, yonghong.song

Confirm that skb->len is not 0 to ensure that skb length is valid.

Fixes: 114039b34201 ("bpf: Move skb->len == 0 checks into __bpf_redirect")
Reported-by: syzbot+e2c932aec5c8a6e1d31c@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 net/bpf/test_run.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index c9fdcc5cdce1..78258a822a5c 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -845,6 +845,9 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)
 {
 	struct qdisc_skb_cb *cb = (struct qdisc_skb_cb *)skb->cb;
 
+	if (!skb->len)
+		return -EINVAL;
+
 	if (!__skb)
 		return 0;
 
-- 
2.26.1


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

* Re: [PATCH net] bpf: test_run: fix WARNING in format_decode
  2023-11-22  0:50 ` [PATCH net] bpf: test_run: fix WARNING in format_decode Edward Adam Davis
@ 2023-11-22  5:28   ` Yonghong Song
  2023-11-27 14:10     ` Daniel Borkmann
  0 siblings, 1 reply; 4+ messages in thread
From: Yonghong Song @ 2023-11-22  5:28 UTC (permalink / raw)
  To: Edward Adam Davis, syzbot+e2c932aec5c8a6e1d31c
  Cc: andrii, ast, bpf, daniel, davem, edumazet, haoluo, hawk,
	john.fastabend, jolsa, kpsingh, kuba, linux-kernel,
	linux-trace-kernel, martin.lau, martin.lau, mhiramat, netdev,
	pabeni, rostedt, sdf, song, syzkaller-bugs, yhs


On 11/21/23 7:50 PM, Edward Adam Davis wrote:
> Confirm that skb->len is not 0 to ensure that skb length is valid.
>
> Fixes: 114039b34201 ("bpf: Move skb->len == 0 checks into __bpf_redirect")
> Reported-by: syzbot+e2c932aec5c8a6e1d31c@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>

Stan, Could you take a look at this patch?


> ---
>   net/bpf/test_run.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index c9fdcc5cdce1..78258a822a5c 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -845,6 +845,9 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)
>   {
>   	struct qdisc_skb_cb *cb = (struct qdisc_skb_cb *)skb->cb;
>   
> +	if (!skb->len)
> +		return -EINVAL;
> +
>   	if (!__skb)
>   		return 0;
>   

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

* Re: [PATCH net] bpf: test_run: fix WARNING in format_decode
  2023-11-22  5:28   ` Yonghong Song
@ 2023-11-27 14:10     ` Daniel Borkmann
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2023-11-27 14:10 UTC (permalink / raw)
  To: Yonghong Song, Edward Adam Davis, syzbot+e2c932aec5c8a6e1d31c
  Cc: andrii, ast, bpf, davem, edumazet, haoluo, hawk, john.fastabend,
	jolsa, kpsingh, kuba, linux-kernel, linux-trace-kernel,
	martin.lau, martin.lau, mhiramat, netdev, pabeni, rostedt, sdf,
	song, syzkaller-bugs, yhs

On 11/22/23 6:28 AM, Yonghong Song wrote:
> On 11/21/23 7:50 PM, Edward Adam Davis wrote:
>> Confirm that skb->len is not 0 to ensure that skb length is valid.
>>
>> Fixes: 114039b34201 ("bpf: Move skb->len == 0 checks into __bpf_redirect")
>> Reported-by: syzbot+e2c932aec5c8a6e1d31c@syzkaller.appspotmail.com
>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> 
> Stan, Could you take a look at this patch?

I think this only papers over the bug.. also BPF selftests seem to break
with this change.

Looking again at the syzkaller trace :

   [...]
   Please remove unsupported %\0 in format string
   WARNING: CPU: 0 PID: 5068 at lib/vsprintf.c:2675 format_decode+0xa03/0xba0 lib/vsprintf.c:2675
   [...]

We need to fix bpf_bprintf_prepare() instead to reject invalid fmts such
as %0 and similar.

>>   net/bpf/test_run.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
>> index c9fdcc5cdce1..78258a822a5c 100644
>> --- a/net/bpf/test_run.c
>> +++ b/net/bpf/test_run.c
>> @@ -845,6 +845,9 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)
>>   {
>>       struct qdisc_skb_cb *cb = (struct qdisc_skb_cb *)skb->cb;
>> +    if (!skb->len)
>> +        return -EINVAL;
>> +
>>       if (!__skb)
>>           return 0;


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

end of thread, other threads:[~2023-11-27 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21 22:43 [syzbot] [bpf?] [trace?] WARNING in format_decode (3) syzbot
2023-11-22  0:50 ` [PATCH net] bpf: test_run: fix WARNING in format_decode Edward Adam Davis
2023-11-22  5:28   ` Yonghong Song
2023-11-27 14:10     ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).