Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1471195ybl; Wed, 28 Aug 2019 15:28:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1Lr1ntoEAi/UC08ukAFIZjsQ0cgnoicKyWT6Eq50aCUzIrus1ptnh6I5x2sHl/xapnQcT X-Received: by 2002:a65:5003:: with SMTP id f3mr5472702pgo.335.1567031293437; Wed, 28 Aug 2019 15:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567031293; cv=none; d=google.com; s=arc-20160816; b=YtvRk6hP05QbwKyF4WYFQz+Bf7HCGYZkRLEt0sC2Zq2layvcuPE9ujjBpmeqKY2FkL trSkp6qAVRn34Ipd5DKBnhB3FyfwOUbwHmmjGe0dG1LEXo2SVvf9uGCIt4yDHl/QHzmr WRr3yTVrYKkYNKJUWA0pWkoYSnZfJsxh8LC5FRZqmghVM+lny5P/oxLHBGmUlHR9P4oQ YizgLph9XW5nIevldPq6XabQ813b72kQf8fPphRSSmLYCfCpau+BQyCYtHRm70kRTV1V PLmonx6mNN4qOCIFCL8hBFeagU+fhB2dUpqEPo3ZVoCik/0QYjKBHG26+nGjnIF0gICN kWVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=ePoJ33Wu/icAvNqWpNFENY9LYrP4c2t65btHAa+RjrE=; b=FOmVeMNG3W/dw+i7J/b4P+Zg1/rOxI9i/+d3q6lH7rzIQ/88rg/os+PnipOTQDR/1O MLTwYI0eyV3UrxGPRUDfZdXuVEankq9Nzs3zVmeD5LjGVLVAb4BZ3YI7U5ruVW8juou9 BJBX7jn8iXIyslK+ny3ZClV1dhO+0I3Xqmj+zMAlV22qltXqTwnK5lclWqK79pMViDws 6NtD4MiTQWNd/JjbuNUVONHdYLhn3bdl5vVfFFkGskJI/8tOFkJ6oNCxpoImGiJbiAvA nk4iNYaDIJIvg/iz6Oyf4c76RJl2aTRNfJg553vJMC6mcvKTcKSKLI1iOPksT4W6I2up u3Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=bF70Avyn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k144si521319pfd.34.2019.08.28.15.27.54; Wed, 28 Aug 2019 15:28:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=bF70Avyn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbfH1W0m (ORCPT + 99 others); Wed, 28 Aug 2019 18:26:42 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45581 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfH1W0l (ORCPT ); Wed, 28 Aug 2019 18:26:41 -0400 Received: by mail-ed1-f68.google.com with SMTP id x19so1685726eda.12 for ; Wed, 28 Aug 2019 15:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=ePoJ33Wu/icAvNqWpNFENY9LYrP4c2t65btHAa+RjrE=; b=bF70Avyn4DwRjJdfn6Nbjw+PVDiW17xek6/F9luxsSGrjM7XrjyLbCNMz9T8/mQ5VE qD/00YM36KvgtJluIgSioCgBGb7oHDDYXdcaIgAbGB579NS1O/jGWnS8LVU2roupZ16X yXxzQ7s8c+VHG6XP7O0Dp11/uo4BDjTFzhNt3khIPx3bv5j19hlB7aPJznezcwUUDRID cXWdEaorJXviipYteiSz8JNSXswmk75S7EXiDuAIS4Ka/kORCVA+qoCoNwlZ6hQkVD/p qp+swzgy8a04x2TJwT2v1jMNXlrTHp2FU5c0q7BwpcaGm/fxZ6Am7rrUuI48li9/bisi j6gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=ePoJ33Wu/icAvNqWpNFENY9LYrP4c2t65btHAa+RjrE=; b=X32l3dXgh81QjLKgWuoopeACgqn/cDN1emWkvmghx4elOCvxU5o+/OMPOgM8Eyj08/ y0iC7erazQu6HErnDkIhcbwYnudTLcOvNSmESPc5Qh900nQs9W/qdd/iB9eN163f00dk db2NQMmpSsuW81g0lUd2oKzgdSjjdQi3aqcjjocqmRN2v2xB7dmetKM0Hhj7zT45/8se qP30NB9Uvgcd81kQ5BA5NaVieVfR+1HD9IiRaSLC6h+Q7ulCu2KhJRBPrxn21O+gaXmx KOOX6dbu2kr6cslVLzC/lHwNOqXydJICI3SjfvW9QDUyyu+wKkvRxekxCmSQoovaqmbe g2Yw== X-Gm-Message-State: APjAAAUwyy+UstfEwR2KX4/Q/IbqF8BQpCiykUa1rsRqG7EZY8tS8j+Q bp0ao7xqzc0oXsALZTkQdfBsAw== X-Received: by 2002:a17:906:5e50:: with SMTP id b16mr5377019eju.254.1567031199536; Wed, 28 Aug 2019 15:26:39 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id x11sm91676eju.26.2019.08.28.15.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 15:26:39 -0700 (PDT) Date: Wed, 28 Aug 2019 15:26:15 -0700 From: Jakub Kicinski To: john.fastabend@gmail.com Cc: syzbot , aviadye@mellanox.com, borisp@mellanox.com, daniel@iogearbox.net, davejwatson@fb.com, davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: general protection fault in tls_sk_proto_close (2) Message-ID: <20190828152615.0fec59b2@cakuba.netronome.com> In-Reply-To: <000000000000c3c461059127a1c4@google.com> References: <000000000000c3c461059127a1c4@google.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Aug 2019 23:38:07 -0700, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: a55aa89a Linux 5.3-rc6 > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=16c26ebc600000 > kernel config: https://syzkaller.appspot.com/x/.config?x=2a6a2b9826fdadf9 > dashboard link: https://syzkaller.appspot.com/bug?extid=7a6ee4d0078eac6bf782 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1112a4de600000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+7a6ee4d0078eac6bf782@syzkaller.appspotmail.com Hi John! This is a loop where TLS calls it's own close function recursively. It seems we must have gotten BPF installed on top of TLS, and then it handed TLS TLS'es own sk_proto via tcp_update_ulp(). Can BPF on top of TLS be prevented somehow? Quick fix should probably be something like: diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 43252a801c3f..3f4962756fa4 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -816,6 +816,9 @@ static void tls_update(struct sock *sk, struct proto *p) ctx = tls_get_ctx(sk); if (likely(ctx)) { + if (p->setsockopt == tls_setsockopt) + return; + ctx->sk_proto_close = p->close; ctx->sk_proto = p; } else { > kasan: CONFIG_KASAN_INLINE enabled > kasan: GPF could be caused by NULL-ptr deref or user memory access > general protection fault: 0000 [#1] PREEMPT SMP KASAN > CPU: 1 PID: 10290 Comm: syz-executor.0 Not tainted 5.3.0-rc6 #120 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > RIP: 0010:tls_sk_proto_close+0xe5/0x990 net/tls/tls_main.c:298 > Code: 0f 85 3f 08 00 00 49 8b 84 24 c0 02 00 00 4d 8d 75 14 4c 89 f2 48 c1 > ea 03 48 89 85 50 ff ff ff 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c > 89 f2 83 e2 07 38 d0 7f 08 84 c0 0f 85 2e 06 00 00 > RSP: 0018:ffff88809b23fb90 EFLAGS: 00010203 > RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: ffffffff862cb8db > RDX: 0000000000000002 RSI: ffffffff862cb639 RDI: ffff8880a155ef00 > RBP: ffff88809b23fc48 R08: ffff888094344640 R09: ffffed10142abd9a > R10: ffffed10142abd99 R11: ffff8880a155eccb R12: ffff8880a155ec40 > R13: 0000000000000000 R14: 0000000000000014 R15: 0000000000000001 > FS: 00005555556a8940(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00007f353458e000 CR3: 00000000a9174000 CR4: 00000000001406e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > tls_sk_proto_close+0x35b/0x990 net/tls/tls_main.c:321 > tcp_bpf_close+0x17c/0x390 net/ipv4/tcp_bpf.c:582 > inet_release+0xed/0x200 net/ipv4/af_inet.c:427 > inet6_release+0x53/0x80 net/ipv6/af_inet6.c:470 > __sock_release+0xce/0x280 net/socket.c:590 > sock_close+0x1e/0x30 net/socket.c:1268 > __fput+0x2ff/0x890 fs/file_table.c:280 > ____fput+0x16/0x20 fs/file_table.c:313 > task_work_run+0x145/0x1c0 kernel/task_work.c:113 > tracehook_notify_resume include/linux/tracehook.h:188 [inline] > exit_to_usermode_loop+0x316/0x380 arch/x86/entry/common.c:163 > prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] > syscall_return_slowpath arch/x86/entry/common.c:274 [inline] > do_syscall_64+0x5a9/0x6a0 arch/x86/entry/common.c:299 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > RIP: 0033:0x413540 > Code: 01 f0 ff ff 0f 83 30 1b 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f > 44 00 00 83 3d 4d 2d 66 00 00 75 14 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff > ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff > RSP: 002b:00007fff5d481778 EFLAGS: 00000246 ORIG_RAX: 0000000000000003 > RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000413540 > RDX: 0000001b2e520000 RSI: 0000000000000000 RDI: 0000000000000005 > RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffff > R10: 0000000000000000 R11: 0000000000000246 R12: 000000000075bf20 > R13: 0000000000000003 R14: 0000000000761220 R15: ffffffffffffffff > Modules linked in: > ---[ end trace bdfd4385a0f1f76d ]--- > RIP: 0010:tls_sk_proto_close+0xe5/0x990 net/tls/tls_main.c:298 > Code: 0f 85 3f 08 00 00 49 8b 84 24 c0 02 00 00 4d 8d 75 14 4c 89 f2 48 c1 > ea 03 48 89 85 50 ff ff ff 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 02 4c > 89 f2 83 e2 07 38 d0 7f 08 84 c0 0f 85 2e 06 00 00 > RSP: 0018:ffff88809b23fb90 EFLAGS: 00010203 > RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: ffffffff862cb8db > RDX: 0000000000000002 RSI: ffffffff862cb639 RDI: ffff8880a155ef00 > RBP: ffff88809b23fc48 R08: ffff888094344640 R09: ffffed10142abd9a > R10: ffffed10142abd99 R11: ffff8880a155eccb R12: ffff8880a155ec40 > R13: 0000000000000000 R14: 0000000000000014 R15: 0000000000000001 > FS: 00005555556a8940(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00007f353458e000 CR3: 00000000a9174000 CR4: 00000000001406e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > > --- > This bug 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 bug report. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > syzbot can test patches for this bug, for details see: > https://goo.gl/tpsmEJ#testing-patches