Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3799832rwb; Tue, 16 Aug 2022 08:59:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QZNh0dJ3liMex6JqCrIOqn9mdIWs8//shY5Z+VLmFyqSy9KLxSEKWJRAqGXl0facpEl02 X-Received: by 2002:a17:907:6091:b0:731:37fb:bd9 with SMTP id ht17-20020a170907609100b0073137fb0bd9mr13766967ejc.219.1660665556102; Tue, 16 Aug 2022 08:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660665556; cv=none; d=google.com; s=arc-20160816; b=VAtOdVsjKd+o8gcp+1y9gV5Ysh4e38LwLGJ/Uf1YLCCIpW5pX530cDNAcpHx/l4MnS O/JpEd2rwT12PlAQpvt8vQVkPDwsYB/wqSD4qu0P4PajAVqIKbk2FzKCiy6hwXlf6F/1 fuc1sJ/2ig1RgbpO5tPSMuV/Kr7qxVHOk1mF5NDMu0S6v0/UYI3SAj/dt5tqjLFUYAPb SPrPHNNz9twIweJXdY4Ij2qB0fObPgNiBgEUcMqEcYG+pMuqVuuJriKqFO8ZM82rwgkl CP3Q2ZY3oJ6CBraXaVjdtrIkOLmV/NxLHv3h0Kvp6GgQUO5grA3oPVSBrF3D3JaLGMJl Vm4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ETcTb291U+LQVGzQDxoqXPmvwJRL1DHZCtw/kAWPJKs=; b=wL7pYYn9mCQ23lBnhpsveBUlQ3jI8BKO6jQNWdeNYI8DYMMhOlBedxIbnpcviAtLNe 9NORXzB5+IbtpI7KExafbizm2azmmXLvSItv9uTj3fcdZrvQDs0YWtAVtXgkj2xogV7n jauWB+5e6AWsL4XLq3+pH/HTCTI1RCmY7vOigaCkXZ26YMHRNwv6c6dJPqHPqpTfR/dW 8OKc0NoDc1D9GLHukzqPZtZApSY0HuIZ2sRhPL4UQ7yNr+OMKgdrQn+0Z5niFXt8gg+2 TMyGY/VXbETgofpIX1X6vRW+8wjxubbfoLzrKVbVPubPsDQKfpvpNSO9mODOAukKAvGq jGSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iMG9agru; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn16-20020a1709070d1000b00730aacadc13si11144718ejc.993.2022.08.16.08.58.50; Tue, 16 Aug 2022 08:59:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iMG9agru; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232540AbiHPPq3 (ORCPT + 99 others); Tue, 16 Aug 2022 11:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236427AbiHPPpi (ORCPT ); Tue, 16 Aug 2022 11:45:38 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5906A80EA2 for ; Tue, 16 Aug 2022 08:41:48 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id x19so15447085lfq.7 for ; Tue, 16 Aug 2022 08:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=ETcTb291U+LQVGzQDxoqXPmvwJRL1DHZCtw/kAWPJKs=; b=iMG9agruLuSZJoHKUeKqxb/AV2q+NiGrkld/xQ7F7T8AQpriWl5PjlXoWOfOHpjvxE ojHoBeJjeR6hF0d/quBa5gW3Nzgo7KpSqK5X9g6Oal81XMXs3NlaDEziAzorhhPdmXJ2 u5+ziGLlIk3K9c26xwAOzjEZpFxzoSzO4ITVsZ31RnbVaG71b5HOxOr/u75IAYTx7yzx NFFGHrIjF8s3A+psTsr3bFPE3ikRIgVy4vSyS027nvuMGXS6PEjqIZilQjvhjbK1coQs OBxo/vIOlbuDBCtk3k+lxOE4WEW7U97jtH0fKeZ4e+1//PjkKMzKEKjVanyAlDT0Vona zIOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=ETcTb291U+LQVGzQDxoqXPmvwJRL1DHZCtw/kAWPJKs=; b=FLYD3Zn9eV2EkSC7k6Ky8w9PMjtzxpn7KSgCnzPeVHaZLNLYaYxZWAZQvjF7+MmX/a bjZxwNZcjbXlISdLosh4EhryIFutp0Dx/uMwymAY2olHaMx4b1MzmNw6rI/VmyRSFYKx feoiHrIVN4MPMwMq/KsL5YD2k6tUyQsRNXk9uc+nmPHXfFFQok46lhPenScNJqnGvyzf bA0SMZiRU/5TgFmBJ1ilysADT+WYqQgp8BTNUi7bQx7oyArHTO0mjzLlzSF/5pe2EXHW K6cyjH8rYbd4VpiIYBWjoRQDEIij4oaDdsLOyIVUlyAtS7Lr0mpMX/x9q7jTLouiQRIL XRKg== X-Gm-Message-State: ACgBeo0N0JhCs3CQlyTCI82luD8Zsq+Nd3Swvyvzzek3LT3h9Nr9TneF KmD8W1R/TDNwuteTGPMKexjuoGgij0UdesGhP4JeLA== X-Received: by 2002:a05:6512:1283:b0:48b:9817:ce2b with SMTP id u3-20020a056512128300b0048b9817ce2bmr7021243lfs.417.1660664506516; Tue, 16 Aug 2022 08:41:46 -0700 (PDT) MIME-Version: 1.0 References: <0000000000002c46ec05e6572415@google.com> In-Reply-To: From: Dmitry Vyukov Date: Tue, 16 Aug 2022 17:41:34 +0200 Message-ID: Subject: Re: [syzbot] KASAN: use-after-free Read in sock_has_perm To: Paul Moore Cc: syzbot , anton@enomsg.org, bpf@vger.kernel.org, ccross@android.com, eparis@parisplace.org, keescook@chromium.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, stephen.smalley.work@gmail.com, syzkaller-bugs@googlegroups.com, tony.luck@intel.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Aug 2022 at 17:02, Paul Moore wrote: > > On Tue, Aug 16, 2022 at 4:00 AM syzbot > wrote: > > > > Hello, > > > > syzbot found the following issue on: > > > > HEAD commit: 200e340f2196 Merge tag 'pull-work.dcache' of git://git.ker.. > > git tree: upstream > > console output: https://syzkaller.appspot.com/x/log.txt?x=16021dfd080000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=f2886ebe3c7b3459 > > dashboard link: https://syzkaller.appspot.com/bug?extid=2f2c6bea25b08dc06f86 > > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > > > > Unfortunately, I don't have any reproducer for this issue yet. > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > Reported-by: syzbot+2f2c6bea25b08dc06f86@syzkaller.appspotmail.com > > > > ================================================================== > > BUG: KASAN: use-after-free in sock_has_perm+0x258/0x280 security/selinux/hooks.c:4532 > > Read of size 8 at addr ffff88807630e480 by task syz-executor.0/8123 > > > > CPU: 1 PID: 8123 Comm: syz-executor.0 Not tainted 5.19.0-syzkaller-02972-g200e340f2196 #0 > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022 > > Call Trace: > > > > __dump_stack lib/dump_stack.c:88 [inline] > > dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 > > print_address_description.constprop.0.cold+0xeb/0x467 mm/kasan/report.c:313 > > print_report mm/kasan/report.c:429 [inline] > > kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 > > sock_has_perm+0x258/0x280 security/selinux/hooks.c:4532 > > selinux_socket_setsockopt+0x3e/0x80 security/selinux/hooks.c:4913 > > security_socket_setsockopt+0x50/0xb0 security/security.c:2249 > > __sys_setsockopt+0x107/0x6a0 net/socket.c:2233 > > __do_sys_setsockopt net/socket.c:2266 [inline] > > __se_sys_setsockopt net/socket.c:2263 [inline] > > __x64_sys_setsockopt+0xba/0x150 net/socket.c:2263 > > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > > do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 > > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > RIP: 0033:0x7f96c7289279 > > Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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:00007f96c842f168 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 > > RAX: ffffffffffffffda RBX: 00007f96c739c050 RCX: 00007f96c7289279 > > RDX: 0000000000000007 RSI: 0000000000000103 RDI: 0000000000000004 > > RBP: 00007f96c72e3189 R08: 0000000000000004 R09: 0000000000000000 > > R10: 0000000020000000 R11: 0000000000000246 R12: 0000000000000000 > > R13: 00007ffe7030593f R14: 00007f96c842f300 R15: 0000000000022000 > > > > SELinux hasn't changed anything in this area for a while, and looking > over everything again just now it still looks sane to me. I suspect > there is something else going on with respect to socket lifetimes and > SELinux just happens to be the one that catches the use-after-free > first. My completely unfounded guess would be that net/netrom/af_netrom.c does incorrect socket lifetime management. Though, that wouldn't explain what Casey mentioned re UDP. But it can well be 2 separate issues.