[syzbot] general protection fault in tls_sk_proto_close (3)

20 views
Skip to first unread message

syzbot

unread,
May 17, 2021, 7:28:20 AM5/17/21
to ak...@linux-foundation.org, bor...@nvidia.com, b...@alien8.de, dan...@iogearbox.net, da...@davemloft.net, h...@zytor.com, jmat...@google.com, john.fa...@gmail.com, jo...@8bytes.org, ku...@kernel.org, k...@vger.kernel.org, linux-...@vger.kernel.org, mark.r...@arm.com, masa...@kernel.org, mi...@redhat.com, net...@vger.kernel.org, pbon...@redhat.com, pet...@infradead.org, rafael.j...@intel.com, ros...@goodmis.org, sea...@google.com, syzkall...@googlegroups.com, tg...@linutronix.de, vkuz...@redhat.com, wanp...@tencent.com, wi...@kernel.org, x...@kernel.org
Hello,

syzbot found the following issue on:

HEAD commit: f3f409a9 Merge branch 'ionic-ptp'
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10fae07ed00000
kernel config: https://syzkaller.appspot.com/x/.config?x=7eff0f22b8563a5f
dashboard link: https://syzkaller.appspot.com/bug?extid=29c3c12f3214b85ad081
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158fe316d00000

The issue was bisected to:

commit 997acaf6b4b59c6a9c259740312a69ea549cc684
Author: Mark Rutland <mark.r...@arm.com>
Date: Mon Jan 11 15:37:07 2021 +0000

lockdep: report broken irq restoration

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11a85786d00000
final oops: https://syzkaller.appspot.com/x/report.txt?x=13a85786d00000
console output: https://syzkaller.appspot.com/x/log.txt?x=15a85786d00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+29c3c1...@syzkaller.appspotmail.com
Fixes: 997acaf6b4b5 ("lockdep: report broken irq restoration")

general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 PID: 8662 Comm: syz-executor.0 Not tainted 5.12.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:tls_sk_proto_close+0xd8/0xaf0 net/tls/tls_main.c:304
Code: 02 00 0f 85 16 09 00 00 48 8b 85 f0 02 00 00 4d 8d 6c 24 14 4c 89 ea 48 c1 ea 03 48 89 44 24 18 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 4f 07 00 00
RSP: 0018:ffffc9000216fc78 EFLAGS: 00010203
RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87a353b3 RDI: ffff8880216aa7b0
RBP: ffff8880216aa4c0 R08: 0000000000000001 R09: 00000000fffffff0
R10: ffffffff87a35641 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000014 R14: ffff88801c1e5108 R15: 0000000000000001
FS: 0000000001f87400(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000780000 CR3: 0000000013807000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
tls_sk_proto_close+0x356/0xaf0 net/tls/tls_main.c:327
inet_release+0x12e/0x280 net/ipv4/af_inet.c:431
inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:478
__sock_release+0xcd/0x280 net/socket.c:599
sock_close+0x18/0x20 net/socket.c:1258
__fput+0x288/0x920 fs/file_table.c:280
task_work_run+0xdd/0x1a0 kernel/task_work.c:140
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop kernel/entry/common.c:174 [inline]
exit_to_user_mode_prepare+0x249/0x250 kernel/entry/common.c:208
__syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x41926b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffd0160cbc0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 000000000041926b
RDX: 00000000005711e8 RSI: 0000000000000001 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b321200e0
R10: ffffffffffffffff R11: 0000000000000293 R12: 00000000005711e8
R13: 00007ffd0160cce0 R14: 000000000056bf60 R15: 0000000000012c65
Modules linked in:
---[ end trace 7e9ee67b64dc5682 ]---
RIP: 0010:tls_sk_proto_close+0xd8/0xaf0 net/tls/tls_main.c:304
Code: 02 00 0f 85 16 09 00 00 48 8b 85 f0 02 00 00 4d 8d 6c 24 14 4c 89 ea 48 c1 ea 03 48 89 44 24 18 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 4f 07 00 00
RSP: 0018:ffffc9000216fc78 EFLAGS: 00010203
RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87a353b3 RDI: ffff8880216aa7b0
RBP: ffff8880216aa4c0 R08: 0000000000000001 R09: 00000000fffffff0
R10: ffffffff87a35641 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000014 R14: ffff88801c1e5108 R15: 0000000000000001
FS: 0000000001f87400(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc1c76c3010 CR3: 0000000013807000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Jul 31, 2021, 10:48:23 AM7/31/21
to ak...@linux-foundation.org, bor...@nvidia.com, b...@alien8.de, dan...@iogearbox.net, da...@davemloft.net, h...@zytor.com, jmat...@google.com, john.fa...@gmail.com, jo...@8bytes.org, ku...@kernel.org, k...@vger.kernel.org, linux-...@vger.kernel.org, mark.r...@arm.com, masa...@kernel.org, mi...@redhat.com, net...@vger.kernel.org, pbon...@redhat.com, pet...@infradead.org, rafael.j...@intel.com, ros...@goodmis.org, sea...@google.com, syzkall...@googlegroups.com, tg...@linutronix.de, vkuz...@redhat.com, wanp...@tencent.com, wi...@kernel.org, x...@kernel.org
syzbot has found a reproducer for the following issue on:

HEAD commit: 8d67041228ac Merge tag 'linux-can-fixes-for-5.14-20210730'..
git tree: net
console output: https://syzkaller.appspot.com/x/log.txt?x=17a6e966300000
kernel config: https://syzkaller.appspot.com/x/.config?x=42748795a8952874
dashboard link: https://syzkaller.appspot.com/bug?extid=29c3c12f3214b85ad081
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11c631b2300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1519451e300000

The issue was bisected to:

commit 997acaf6b4b59c6a9c259740312a69ea549cc684
Author: Mark Rutland <mark.r...@arm.com>
Date: Mon Jan 11 15:37:07 2021 +0000

lockdep: report broken irq restoration

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11a85786d00000
final oops: https://syzkaller.appspot.com/x/report.txt?x=13a85786d00000
console output: https://syzkaller.appspot.com/x/log.txt?x=15a85786d00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+29c3c1...@syzkaller.appspotmail.com
Fixes: 997acaf6b4b5 ("lockdep: report broken irq restoration")

general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 0 PID: 9805 Comm: syz-executor059 Not tainted 5.14.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:tls_sk_proto_close+0xd8/0xaf0 net/tls/tls_main.c:304
Code: 02 00 0f 85 16 09 00 00 48 8b 85 f0 02 00 00 4d 8d 6c 24 14 4c 89 ea 48 c1 ea 03 48 89 44 24 18 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 4f 07 00 00
RSP: 0018:ffffc9000afffc60 EFLAGS: 00010203
RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87c151d3 RDI: ffff888147a24170
RBP: ffff888147a23e80 R08: 0000000000000001 R09: 00000000fffffff0
R10: ffffffff87c15461 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000014 R14: ffff88803d517908 R15: 0000000000000001
FS: 000000000076f400(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb379600000 CR3: 000000003d560000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
tls_sk_proto_close+0x356/0xaf0 net/tls/tls_main.c:327
inet_release+0x12e/0x280 net/ipv4/af_inet.c:431
inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:478
__sock_release+0xcd/0x280 net/socket.c:648
sock_close+0x18/0x20 net/socket.c:1300
__fput+0x288/0x920 fs/file_table.c:280
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:209
__syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x40c81b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007fffc346f8f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 000000000040c81b
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 0000000000000005
RBP: 00000000000149a5 R08: 0000000000000000 R09: 0000000000000000
R10: 00007fffc346f940 R11: 0000000000000293 R12: 00007fffc346f940
R13: 00007fffc346f960 R14: 0000000000405060 R15: 00007fffc346f9d0
Modules linked in:
---[ end trace 6a958f78622ad753 ]---
RIP: 0010:tls_sk_proto_close+0xd8/0xaf0 net/tls/tls_main.c:304
Code: 02 00 0f 85 16 09 00 00 48 8b 85 f0 02 00 00 4d 8d 6c 24 14 4c 89 ea 48 c1 ea 03 48 89 44 24 18 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 4f 07 00 00
RSP: 0018:ffffc9000afffc60 EFLAGS: 00010203

RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87c151d3 RDI: ffff888147a24170
RBP: ffff888147a23e80 R08: 0000000000000001 R09: 00000000fffffff0
R10: ffffffff87c15461 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000014 R14: ffff88803d517908 R15: 0000000000000001
FS: 000000000076f400(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb379600000 CR3: 000000003d560000 CR4: 00000000001506f0

Hillf Danton

unread,
Jul 31, 2021, 9:42:14 PM7/31/21
to syzbot, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
On Sat, 31 Jul 2021 07:48:23 -0700
Given the same function name in the line with the RIP prefix, tls recursively
spirals up into tls.

> inet_release+0x12e/0x280 net/ipv4/af_inet.c:431
> inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:478
> __sock_release+0xcd/0x280 net/socket.c:648
> sock_close+0x18/0x20 net/socket.c:1300
> __fput+0x288/0x920 fs/file_table.c:280
> task_work_run+0xdd/0x1a0 kernel/task_work.c:164
> tracehook_notify_resume include/linux/tracehook.h:189 [inline]
> exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
> exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:209
> __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
> syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
> do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
> entry_SYSCALL_64_after_hwframe+0x44/0xae

Fix it by detecting and denying any attempts of embedding tls.

+++ x/net/tls/tls_main.c
@@ -637,6 +637,11 @@ struct tls_context *tls_ctx_create(struc
rcu_assign_pointer(icsk->icsk_ulp_data, ctx);
ctx->sk_proto = READ_ONCE(sk->sk_prot);
ctx->sk = sk;
+ if (ctx->sk_proto->close == tls_sk_proto_close) {
+ /* embedding tls in tls makes no sense */
+ kfree(ctx);
+ return NULL;
+ }
return ctx;
}

Reply all
Reply to author
Forward
0 new messages