[syzbot] [bpf?] [trace?] WARNING in format_decode (3)

16 views
Skip to first unread message

syzbot

unread,
Nov 21, 2023, 5:43:21 PM11/21/23
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, hao...@google.com, ha...@kernel.org, john.fa...@gmail.com, jo...@kernel.org, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, marti...@kernel.org, marti...@linux.dev, mhir...@kernel.org, net...@vger.kernel.org, pab...@redhat.com, ros...@goodmis.org, s...@google.com, so...@kernel.org, syzkall...@googlegroups.com, y...@fb.com, yongho...@linux.dev
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 <s...@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+e2c932...@syzkaller.appspotmail.com
Fixes: 114039b34201 ("bpf: Move skb->len == 0 checks into __bpf_redirect")

------------[ cut here ]------------
Please remove unsupported % 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 syzk...@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

Edward Adam Davis

unread,
Nov 21, 2023, 7:18:56 PM11/21/23
to syzbot+e2c932...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test unsupported %? in format string

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 76df934c6d5f
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;


syzbot

unread,
Nov 21, 2023, 7:43:07 PM11/21/23
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e2c932...@syzkaller.appspotmail.com

Tested on:

commit: 76df934c MAINTAINERS: Add netdev subsystem profile link
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
console output: https://syzkaller.appspot.com/x/log.txt?x=166ceb14e80000
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
patch: https://syzkaller.appspot.com/x/patch.diff?x=15ee2b48e80000

Note: testing is done by a robot and is best-effort only.

Edward Adam Davis

unread,
Nov 21, 2023, 7:51:13 PM11/21/23
to syzbot+e2c932...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, hao...@google.com, ha...@kernel.org, john.fa...@gmail.com, jo...@kernel.org, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, marti...@kernel.org, marti...@linux.dev, mhir...@kernel.org, net...@vger.kernel.org, pab...@redhat.com, ros...@goodmis.org, s...@google.com, so...@kernel.org, syzkall...@googlegroups.com, y...@fb.com, yongho...@linux.dev
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+e2c932...@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <ead...@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

Yonghong Song

unread,
Nov 22, 2023, 12:28:49 AM11/22/23
to Edward Adam Davis, syzbot+e2c932...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, hao...@google.com, ha...@kernel.org, john.fa...@gmail.com, jo...@kernel.org, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, marti...@kernel.org, marti...@linux.dev, mhir...@kernel.org, net...@vger.kernel.org, pab...@redhat.com, ros...@goodmis.org, s...@google.com, so...@kernel.org, syzkall...@googlegroups.com, y...@fb.com

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+e2c932...@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <ead...@qq.com>

Stan, Could you take a look at this patch?

Daniel Borkmann

unread,
Nov 27, 2023, 9:11:21 AM11/27/23
to Yonghong Song, Edward Adam Davis, syzbot+e2c932...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, da...@davemloft.net, edum...@google.com, hao...@google.com, ha...@kernel.org, john.fa...@gmail.com, jo...@kernel.org, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, linux-tra...@vger.kernel.org, marti...@kernel.org, marti...@linux.dev, mhir...@kernel.org, net...@vger.kernel.org, pab...@redhat.com, ros...@goodmis.org, s...@google.com, so...@kernel.org, syzkall...@googlegroups.com, y...@fb.com
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+e2c932...@syzkaller.appspotmail.com
>> Signed-off-by: Edward Adam Davis <ead...@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.
Reply all
Reply to author
Forward
0 new messages