Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7015958ybf; Fri, 6 Mar 2020 08:45:37 -0800 (PST) X-Google-Smtp-Source: ADFU+vst248n8X5QZ2BOF8w6ZI3Bw3tnPVlRme24W2VviEvDMy5yDGlfhgsFE0zmoxW5kAOtCs8V X-Received: by 2002:a9d:49:: with SMTP id 67mr799159ota.163.1583513137753; Fri, 06 Mar 2020 08:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583513137; cv=none; d=google.com; s=arc-20160816; b=Efye91V+CwqrdoF06sZ/5QxWwNeeeRUbfPaIjE6IHHS0mZ46rDVxY59mafjVvE3RU8 /V4L8BGikkgqx2N5fXmWfIaM7dflbvxvi4vTs2P/zlyqq+RNSPF4GLOQ1to9Tjcmu2d5 6ysE0qIZ9bXCOb7IYP2tkeiJNmW1j4iorH0Gv/Yh7+c8QQrxMnY9Vd38FQUhks1/Ie0Z 6alGrx3z4qBulkMnr+8DYdMyyNWmOZX/MZ4kJJnqr5a0k3r+RySA0lyDeX9fCMuSRkUP VO/XG5dYMt+xTbpSoOHFXm9MvchPctZjOZKFdD9DUrSLkOoVYZ0r09uKaPyE0x9xRgXS ld7Q== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=d66Ub9/YPrmQyBV7LC7zNOOvEotKFSzThVJkmtNuG9Y=; b=krkvIJbS/7D/QQs5EkMRpOQSwR6EfJYwWzCyZ8fKdIWwv+QtXopaZrySI5PAGUtm+X RwRSwS0tS1OL6iYQGumUR3MvYvMwM471N01dcj2c9uQl8NY4m6P6ypH66FK3Pb/hJY4z UYZJgHStQRGcXlcH9CbCO1SmPVmbcaDEiqVHqZL706AMkFydqvBBBaMTZUNaE0rbk6m4 MadCekc5a6DK1OmeVwlqoNYd5g8dZAtCyGKDhIMGG704FBQknaCkioLqiYSUOgB8THvl z3t+aQ5kdM5mb2IXUlUV6zeoSH4z4okfg5K83Pdc2Vgau/eOIpuGuid7UVDL/3g5dWds o0vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=suKLdZ7u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si1707347otp.314.2020.03.06.08.45.26; Fri, 06 Mar 2020 08:45:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=suKLdZ7u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgCFQop (ORCPT + 99 others); Fri, 6 Mar 2020 11:44:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:43274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbgCFQoo (ORCPT ); Fri, 6 Mar 2020 11:44:44 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39A3A2072A; Fri, 6 Mar 2020 16:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583513083; bh=uM6BBzCXa6HAUuOEGiA8P2jf81J77c6GVb5q3IeM3R4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=suKLdZ7u99Tu+TZXXLBW/DTPMhhpoblbweU/aMPVupcPWtgSo/+q6IAK70+gMPfRL ah5o8KFpGEyp2Ul18AA3nzRoMfgJYb3P5A7YF5u3e5JqpvT3J9JTC8iW7bZG8EUK/I jZckRz4TQB2vJtmbOVkawf2lRhrHScoF9i7hpsxg= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 0E85935226BF; Fri, 6 Mar 2020 08:44:43 -0800 (PST) Date: Fri, 6 Mar 2020 08:44:43 -0800 From: "Paul E. McKenney" To: Jann Horn Cc: Jens Axboe , Dmitry Vyukov , syzbot , Al Viro , io-uring , linux-fsdevel , Borislav Petkov , "H. Peter Anvin" , LKML , Ingo Molnar , Peter Zijlstra , syzkaller-bugs , Thomas Gleixner , tony.luck@intel.com, the arch/x86 maintainers , Dan Carpenter Subject: Re: KASAN: use-after-free Read in percpu_ref_switch_to_atomic_rcu Message-ID: <20200306164443.GU2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <00000000000067c6df059df7f9f5@google.com> <3f805e51-1db7-3e57-c9a3-15a20699ea54@kernel.dk> <075e7fbe-aeec-cb7d-9338-8eb4e1576293@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 04:36:20PM +0100, Jann Horn wrote: > On Fri, Mar 6, 2020 at 4:34 PM Jens Axboe wrote: > > On 3/6/20 7:57 AM, Jann Horn wrote: > > > +paulmck > > > > > > On Wed, Mar 4, 2020 at 3:40 PM Jens Axboe wrote: > > >> On 3/4/20 12:59 AM, Dmitry Vyukov wrote: > > >>> On Fri, Feb 7, 2020 at 9:14 AM syzbot > > >>> wrote: > > >>>> > > >>>> Hello, > > >>>> > > >>>> syzbot found the following crash on: > > >>>> > > >>>> HEAD commit: 4c7d00cc Merge tag 'pwm/for-5.6-rc1' of git://git.kernel.o.. > > >>>> git tree: upstream > > >>>> console output: https://syzkaller.appspot.com/x/log.txt?x=12fec785e00000 > > >>>> kernel config: https://syzkaller.appspot.com/x/.config?x=e162021ddededa72 > > >>>> dashboard link: https://syzkaller.appspot.com/bug?extid=e017e49c39ab484ac87a > > >>>> compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) > > >>>> > > >>>> Unfortunately, I don't have any reproducer for this crash yet. > > >>>> > > >>>> IMPORTANT: if you fix the bug, please add the following tag to the commit: > > >>>> Reported-by: syzbot+e017e49c39ab484ac87a@syzkaller.appspotmail.com > > >>> > > >>> +io_uring maintainers > > >>> > > >>> Here is a repro: > > >>> https://gist.githubusercontent.com/dvyukov/6b340beab6483a036f4186e7378882ce/raw/cd1922185516453c201df8eded1d4b006a6d6a3a/gistfile1.txt > > >> > > >> I've queued up a fix for this: > > >> > > >> https://git.kernel.dk/cgit/linux-block/commit/?h=io_uring-5.6&id=9875fe3dc4b8cff1f1b440fb925054a5124403c3 > > > > > > I believe that this fix relies on call_rcu() having FIFO ordering; but > > > > > > says: > > > > > > | call_rcu() normally acts only on CPU-local state[...] It simply > > > enqueues the rcu_head structure on a per-CPU list, Indeed. For but one example, if there was a CPU-to-CPU migration between the two call_rcu() invocations, it would not be at all surprising for the two callbacks to execute out of order. > > > Is this fix really correct? > > > > That's a good point, there's a potentially stronger guarantee we need > > here that isn't "nobody is inside an RCU critical section", but rather > > that we're depending on a previous call_rcu() to have happened. Hence I > > think you are right - it'll shrink the window drastically, since the > > previous callback is already queued up, but it's not a full close. > > > > Hmm... > > You could potentially hack up the semantics you want by doing a > call_rcu() whose callback does another call_rcu(), or something like > that - but I'd like to hear paulmck's opinion on this first. That would work! Or, alternatively, do an rcu_barrier() between the two calls to call_rcu(), assuming that the use case can tolerate rcu_barrier() overhead and latency. Thanx, Paul