Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6953264ybf; Fri, 6 Mar 2020 07:37:29 -0800 (PST) X-Google-Smtp-Source: ADFU+vu0+Ub++SfV84Bgdb90keiiPF/FD/AyUCnCfOsh9PZR4j+Iq1Er6zOp8fivvKZbRe10GEzy X-Received: by 2002:a05:6830:46:: with SMTP id d6mr3061184otp.81.1583509049533; Fri, 06 Mar 2020 07:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583509049; cv=none; d=google.com; s=arc-20160816; b=NY3LaBYSnM+0M/Y+l6lfY6bky7cUxRFvJeAxYh5paDdRdK1BEgnZNd9Jh4K+PohUDf 2n/l4H2aAJrgFpjwa/BcxWie/t7TsZjSkuZHSt2w3k7VKwVhLWvs7DKkksrqYsc/oZ82 OThWlE5uhf6ShdzSAGq5v6yIM7CFeYk0KKrLiP3Z+r/m7ZIGQAlpQuFjVFTxQ6nk3aQG xqc69Y0zjiuQFbqrbZDvZ3LSjrektHXWb5vL2qICFB0IcKwNUCiEJa29ULhFMH24buHk ROtNxYMxm+C5rN12EBy+vt506sZHWRi4hgvLM1R/vg0NAI7Yuu8U+nWirwS286Z+GtQJ CobQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aIS3j9BcsIx1974rQkdX3Sq/wS4nhMN+kP4/ppiopJQ=; b=Oc2634LLlRrteeuqh/2AjpDpV5EcmHI88bxRntZVkREKwXfx0Wz3LLyiCxvhT2uII6 mBd1KFSwATHcVr887OzZekh6IE0C9hJ0arObJTcKs5IQeg3nvs4seVsKv6YroT+vXrqI r+fP8/KPMel4VlfYo+Kd4AECu4y1J2vu95rPaNn9fGsG/Rdjh7joXCkBxgf49AmDV99L t9tw+Zsu7fLU23ZaBLd8I5uueQhK8o4nuaFKvlaBHLOVuBm/2FxrCmdiN9hIW0BI3ePq ccGGLFqk5M1sxmXIPaRQvElqF6bLu8SuQ+tZI3Sc83cmaUafYmc3Pn3GBejuyhA1sSVn orvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pdzfVkRp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si1554498oic.80.2020.03.06.07.37.15; Fri, 06 Mar 2020 07:37:29 -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=@google.com header.s=20161025 header.b=pdzfVkRp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727178AbgCFPgu (ORCPT + 99 others); Fri, 6 Mar 2020 10:36:50 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:36988 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbgCFPgt (ORCPT ); Fri, 6 Mar 2020 10:36:49 -0500 Received: by mail-oi1-f195.google.com with SMTP id q65so2932333oif.4 for ; Fri, 06 Mar 2020 07:36:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aIS3j9BcsIx1974rQkdX3Sq/wS4nhMN+kP4/ppiopJQ=; b=pdzfVkRpdhCdinsJQyA2PpGXMwl9diPaAtQ+q5PW7umYSE8oOsh+l4A7IkWmbd5V30 FVXy2Y5U+5S7vPuSIkuWSXFTasDAGkFOEf1jlNfn2DSNAz37CkwOZZ/So73T1EpJeKsy Z0uixE4WN+DrWt9CriO18kAzqHWWy3qebwSLleITjbms4v81y6Jq9tZRtNWNGYmEaX/Z n7tiP8mwgfqQ9F+kl4DnTqxA0TRHNrnQuFlfAL0kPfG5fBhEkkidL3UXquSbhYhIeo5X kYpplD1y0KZNmODQs8TfxBxhueX2QCEv381klgHQxcoaX9sY/bszhuiSfVzkR1xt66XO wEQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aIS3j9BcsIx1974rQkdX3Sq/wS4nhMN+kP4/ppiopJQ=; b=BrW4CEEmCDsW9SU5CloHc57HHjqNwvvFAOXOQKqfJEGvWtCD350zq0LVJxVif79gav uqXQg97iO0Njx3+SwN5kC4ZmIUVcrGfNWAaMiKFAKxq0S5pRnbTOr6TgQiQ/4bP03dKi XbR55pBZ4uum2ulPX5dO/W7VoS1U4bLqnR8YM0Z8RG5Rwehq5QaIbpH+f5LYO/36gK97 wHb7DWvuuI90FFv2TpFRvILqsHXV2efmsANA0u6VTrvDAE8M0bRXrlLimHkHbEoE92s4 Vh9BWRbwVD7svTRFsbtHN2pe21XoIPROB5vUlkGKPzKyGDR25NIMIrLM1WYcXK12qCsR NWgg== X-Gm-Message-State: ANhLgQ2LtFyOjvr8o7s4fOu0sx/sQxlowXEOBWo1Px8wfTGKCvQVctuQ ZW57wgfBOlRBbN8P/MeqRw463t2l+aDJOnPz3ZY8RA== X-Received: by 2002:a05:6808:8d0:: with SMTP id k16mr3048626oij.68.1583509007480; Fri, 06 Mar 2020 07:36:47 -0800 (PST) MIME-Version: 1.0 References: <00000000000067c6df059df7f9f5@google.com> <3f805e51-1db7-3e57-c9a3-15a20699ea54@kernel.dk> <075e7fbe-aeec-cb7d-9338-8eb4e1576293@kernel.dk> In-Reply-To: <075e7fbe-aeec-cb7d-9338-8eb4e1576293@kernel.dk> From: Jann Horn Date: Fri, 6 Mar 2020 16:36:20 +0100 Message-ID: Subject: Re: KASAN: use-after-free Read in percpu_ref_switch_to_atomic_rcu To: Jens Axboe , "Paul E . McKenney" Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, > > > > 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.