[syzbot] [bpf?] [net?] WARNING in __sk_msg_free

8 views
Skip to first unread message

syzbot

unread,
Jan 5, 2024, 12:32:34 PMJan 5
to and...@kernel.org, a...@kernel.org, bor...@nvidia.com, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, dhow...@redhat.com, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 2ab1efad60ad net/sched: cls_api: complement tcf_tfilter_du..
git tree: net-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=162a3829e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=a4e9ca8e3c104d2a
dashboard link: https://syzkaller.appspot.com/bug?extid=f2977222e0e95cec15c8
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=153f4f29e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14acd65ee80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/bc9bebeba249/disk-2ab1efad.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1b355f4afef6/vmlinux-2ab1efad.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0c561e15b929/bzImage-2ab1efad.xz

The issue was bisected to:

commit fe1e81d4f73b6cbaed4fcc476960d26770642842
Author: David Howells <dhow...@redhat.com>
Date: Wed Jun 7 18:19:17 2023 +0000

tls/sw: Support MSG_SPLICE_PAGES

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13e87d81e80000
final oops: https://syzkaller.appspot.com/x/report.txt?x=10187d81e80000
console output: https://syzkaller.appspot.com/x/log.txt?x=17e87d81e80000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+f29772...@syzkaller.appspotmail.com
Fixes: fe1e81d4f73b ("tls/sw: Support MSG_SPLICE_PAGES")

------------[ cut here ]------------
WARNING: CPU: 0 PID: 5059 at include/linux/skmsg.h:137 sk_msg_check_to_free include/linux/skmsg.h:137 [inline]
WARNING: CPU: 0 PID: 5059 at include/linux/skmsg.h:137 sk_msg_check_to_free include/linux/skmsg.h:135 [inline]
WARNING: CPU: 0 PID: 5059 at include/linux/skmsg.h:137 __sk_msg_free+0x29f/0x390 net/core/skmsg.c:203
Modules linked in:
CPU: 0 PID: 5059 Comm: syz-executor395 Not tainted 6.7.0-rc6-syzkaller-01873-g2ab1efad60ad #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:sk_msg_check_to_free include/linux/skmsg.h:137 [inline]
RIP: 0010:sk_msg_check_to_free include/linux/skmsg.h:135 [inline]
RIP: 0010:__sk_msg_free+0x29f/0x390 net/core/skmsg.c:203
Code: 00 00 48 83 e0 fe 48 83 c8 02 49 89 85 40 02 00 00 8b 44 24 0c 48 83 c4 30 5b 5d 41 5c 41 5d 41 5e 41 5f c3 e8 62 98 00 f9 90 <0f> 0b 90 e8 59 98 00 f9 48 63 5c 24 08 48 83 fb 13 0f 87 9d 00 00
RSP: 0018:ffffc90003bff8e8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 000000000000000e RCX: ffffffff8886e85f
RDX: ffff888022e88000 RSI: ffffffff8886e90e RDI: 0000000000000005
RBP: 000000000000000e R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000036 R11: 0000000000000002 R12: 0000000000000036
R13: ffff8880177f2018 R14: 0000000000000007 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0c1dd31a18 CR3: 000000000cd77000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
tls_free_rec net/tls/tls_sw.c:359 [inline]
tls_free_open_rec net/tls/tls_sw.c:370 [inline]
tls_sw_release_resources_tx+0x4e8/0x6f0 net/tls/tls_sw.c:2467
tls_sk_proto_cleanup net/tls/tls_main.c:352 [inline]
tls_sk_proto_close+0x678/0xac0 net/tls/tls_main.c:382
inet_release+0x132/0x270 net/ipv4/af_inet.c:433
inet6_release+0x4f/0x70 net/ipv6/af_inet6.c:485
__sock_release+0xae/0x260 net/socket.c:659
sock_close+0x1c/0x20 net/socket.c:1419
__fput+0x270/0xb70 fs/file_table.c:394
task_work_run+0x14d/0x240 kernel/task_work.c:180
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xa8a/0x2ad0 kernel/exit.c:869
do_group_exit+0xd4/0x2a0 kernel/exit.c:1018
get_signal+0x23b5/0x2790 kernel/signal.c:2904
arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x121/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x1e/0x60 kernel/entry/common.c:296
do_syscall_64+0x4d/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f0c1dcdae39
Code: Unable to access opcode bytes at 0x7f0c1dcdae0f.
RSP: 002b:00007f0c1dc9d218 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: 0000000000010000 RBX: 00007f0c1dd64328 RCX: 00007f0c1dcdae39
RDX: 00000000fffffecc RSI: 0000000020000100 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f0c1dd64320
R13: 0000000000000000 R14: 00007f0c1dd32004 R15: 34ea337571a66fd8
</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,
Jan 9, 2024, 12:35:13 AMJan 9
to syzbot+f29772...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
please test WARNING in __sk_msg_free

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index e37b4d2e2acd..68dbe821f61d 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1016,6 +1016,8 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,

msg_pl = &rec->msg_plaintext;
msg_en = &rec->msg_encrypted;
+ if (msg_pl->sg.end >= MAX_MSG_FRAGS)
+ return -EINVAL;

orig_size = msg_pl->sg.size;
full_record = false;

Edward Adam Davis

unread,
Jan 9, 2024, 4:32:52 AMJan 9
to syzbot+f29772...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, bor...@nvidia.com, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, dhow...@redhat.com, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Syzbot constructed 32 scatterlists, and the data members in struct sk_msg_sg
can only store a maximum of MAX_MSG_FRAGS scatterlists.
However, the value of MAX_MSG_FRAGS=CONFIG_MAX_SKB_FRAG is less than 32, which
leads to the warning reported here.

Prevent similar issues from occurring by checking whether sg.end is greater
than MAX_MSG_FRAGS.

Reported-and-tested-by: syzbot+f29772...@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <ead...@qq.com>
---
net/tls/tls_sw.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index e37b4d2e2acd..68dbe821f61d 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1016,6 +1016,8 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,

msg_pl = &rec->msg_plaintext;
msg_en = &rec->msg_encrypted;
+ if (msg_pl->sg.end >= MAX_MSG_FRAGS)
+ return -EINVAL;

orig_size = msg_pl->sg.size;
full_record = false;
--
2.43.0

syzbot

unread,
Jan 9, 2024, 1:17:10 PMJan 9
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+f29772...@syzkaller.appspotmail.com

Tested on:

commit: 9f8413c4 Merge tag 'cgroup-for-6.8' of git://git.kerne..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=13e7b575e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=d908a1f683257685
dashboard link: https://syzkaller.appspot.com/bug?extid=f2977222e0e95cec15c8
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=1482db4de80000

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

John Fastabend

unread,
Jan 9, 2024, 6:22:42 PMJan 9
to Edward Adam Davis, syzbot+f29772...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, bor...@nvidia.com, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, dhow...@redhat.com, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
I'll test this in a bit, but I suspect this error is because even
if the msg_pl is full (the sg.end == MAX_MSG_FRAGS) the code is
missing a full_record=true set to force the loop to do the send
and abort. My opinion is we should never iterated the loop if the
msg_pl was full.

I think something like this is actually needed.

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index e37b4d2e2acd..9cfa6f8d51e3 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1052,8 +1052,10 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,
if (ret < 0)
goto send_end;
tls_ctx->pending_open_record_frags = true;
- if (full_record || eor || sk_msg_full(msg_pl))
+ if (full_record || eor || sk_msg_full(msg_pl)) {
+ full_record = true;
goto copied;
+ }
continue;
}

John Fastabend

unread,
Jan 10, 2024, 2:53:33 AMJan 10
to John Fastabend, Edward Adam Davis, syzbot+f29772...@syzkaller.appspotmail.com, and...@kernel.org, a...@kernel.org, bor...@nvidia.com, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, dhow...@redhat.com, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Actually, it needs a bit more than above. That will fix the warning,
but it returns an error on when it should flush the full_record in
some cases. I'll send a fix shortly.
Reply all
Reply to author
Forward
0 new messages