Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1761936imb; Sun, 3 Mar 2019 05:57:03 -0800 (PST) X-Google-Smtp-Source: APXvYqz8CRnCnDnNWh5H4yka07pnWN1E6m1uzFY51XCCLu70vSZ84lAhZ75DEDBJYNuzA9pWrqS1 X-Received: by 2002:a17:902:9a09:: with SMTP id v9mr14889858plp.225.1551621423723; Sun, 03 Mar 2019 05:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551621423; cv=none; d=google.com; s=arc-20160816; b=v7aKgOf5BoQ0g6w80V08GiDMpx5mWUmvi5vQZWxOlkaoEBt3JruDldcdmLHe9XE7HD VcY3ulrawtACHisvx+NV00Ss7sI/lqVcOrnJlGzzrBi5udvOTQC4Kzsq8602l9zgRNNx MfwTKc+sE9qcBeaGSAQPZ+dY98Ekkb8cn0b+40PzKIOe60vGGR0LgaqRjbum3HAoYJiJ 8b40baeWoFyNq/DaM8BQ+5Ux9UPKl/SuqhQZ5cqzd90ZIug3WzOUGFNzO25C9kKT3i5F qJiBrldbA0/DSVmCSmWBkOJpxJBKcZ6NYx1C/EkNneeXEzRen6ccRxQDGTrl1Rycruw/ /Tuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=4Ix7OR0OrFkQ1I9ZSdsGcN3Rw2VbLy3rnmV3nrgLVk8=; b=clDqzUrzY2gkqGStiLLc3URmRQFUU2xe5vqSBv4F4u0mLzlQtT3TAV9KQO0VM59GdI bKiYDprjYUCkwxgMqPqObUWmHRm4h8ZJtmEXkCMgZ6PujC0P51hOOJz9Z3OyIPnOjiQ8 S8x5o8ikL9QF0qXjCm4OdxLAVO7ii0WEpWXh5Flh2F3qz3nT60dAZyvJ6Gi2RwqI85rp sS/ozoxpCAFyIlfNIaSf+i/IR1grEp+fAAL6QNWMf43av4zDbLA4j18seUJshK65bR1K caXHuvz0QvzJyWluXDwxZ9xlis6TyO60ip0yqwden9JONCu0nb/3NHicnK8wSxyG55OI 87rg== ARC-Authentication-Results: i=1; mx.google.com; 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 c24si2751811pgw.46.2019.03.03.05.56.49; Sun, 03 Mar 2019 05:57:03 -0800 (PST) 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; 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 S1726323AbfCCNzR (ORCPT + 99 others); Sun, 3 Mar 2019 08:55:17 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:33676 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfCCNzR (ORCPT ); Sun, 3 Mar 2019 08:55:17 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h0Ra2-0000rx-Ro; Sun, 03 Mar 2019 13:55:02 +0000 Date: Sun, 3 Mar 2019 13:55:02 +0000 From: Al Viro To: syzbot Cc: davem@davemloft.net, jbaron@akamai.com, kgraul@linux.ibm.com, ktkhai@virtuozzo.com, kyeongdon.kim@lge.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com, hch@lst.de Subject: Re: KASAN: use-after-free Read in unix_dgram_poll Message-ID: <20190303135502.GP2217@ZenIV.linux.org.uk> References: <000000000000f39c7b05832e0219@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000f39c7b05832e0219@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 03, 2019 at 02:22:04AM -0800, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: 7d762d69145a afs: Fix manually set volume location server .. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=131d832ac00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=b76ec970784287c > dashboard link: https://syzkaller.appspot.com/bug?extid=503d4cc169fcec1cb18c > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11934262c00000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+503d4cc169fcec1cb18c@syzkaller.appspotmail.com > > ================================================================== > BUG: KASAN: use-after-free in unix_dgram_poll+0x5e1/0x690 > net/unix/af_unix.c:2695 > Read of size 4 at addr ffff88809292aae0 by task syz-executor.1/18946 > > CPU: 0 PID: 18946 Comm: syz-executor.1 Not tainted 5.0.0-rc8+ #88 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x172/0x1f0 lib/dump_stack.c:113 > print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187 > kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317 > __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134 > unix_dgram_poll+0x5e1/0x690 net/unix/af_unix.c:2695 > sock_poll+0x291/0x340 net/socket.c:1127 > vfs_poll include/linux/poll.h:86 [inline] > aio_poll fs/aio.c:1766 [inline] > __io_submit_one fs/aio.c:1876 [inline] > io_submit_one+0xe3e/0x1cf0 fs/aio.c:1909 > __do_sys_io_submit fs/aio.c:1954 [inline] > __se_sys_io_submit fs/aio.c:1924 [inline] > __x64_sys_io_submit+0x1bd/0x580 fs/aio.c:1924 > ? 0xffffffff81000000 > do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290 > entry_SYSCALL_64_after_hwframe+0x49/0xbe Apparently, a call of ->poll() overlapping with call of ->release() (if not outright happening after it). Which should never happen... Maybe unrelated to this bug, but... What's to prevent a wakeup that happens just after we'd been added to a waitqueue by ->poll() triggering aio_poll_wake(), which gets to aio_poll_complete() with its fput() *before* we'd reached the end of ->poll() instance? I wonder if adding get_file(req->file); // make sure that early completion is safe right after req->file = fget(iocb->aio_fildes); if (unlikely(!req->file)) return -EBADF; paired with fput(req->file); right after out: in aio_poll() is needed... Am I missing something obvious here? Christoph?