From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E799FC43334 for ; Mon, 4 Jul 2022 13:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234410AbiGDNzq (ORCPT ); Mon, 4 Jul 2022 09:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233375AbiGDNzk (ORCPT ); Mon, 4 Jul 2022 09:55:40 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A00742720; Mon, 4 Jul 2022 06:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sFBRrsK/nUCO/qpurgOa37xWDf0Rw4TWhvCcPDzVFrw=; b=fGvBCBUUizUVOtp0n9eFyK6qEp BlBJ2LXAd0hh4Ac/kOInhtYaicGuP0Wm+9RpmeAcNCveOfiNg2HalpF71G6tE0sxRAOoJnnnJ8jDo LzrOgSbBh27d4lrinBT/6BTlPxLOemUmVcp9N08w+0hNimZQPMPk331algyiCyhqUh44lkkWpPmmY R0/v2bo6OqfBLfb3ZP66/skFycQymC2OCzUed8HfkyDvpKdX2Zugr38vE288P/qWfhzbrVpgSoItW lZComXKs5lJQWRJj/s21c22jLyTgHTbTtCNo+CUvRSFL+2Lib/Pig8sU6eh28YZ87NBq8C1awuPRj X1SbUxKA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.95 #2 (Red Hat Linux)) id 1o8MXa-0081o6-IG; Mon, 04 Jul 2022 13:55:06 +0000 Date: Mon, 4 Jul 2022 14:55:06 +0100 From: Al Viro To: Alexander Potapenko Cc: Linus Torvalds , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux-MM , linux-arch , Linux Kernel Mailing List , Evgenii Stepanov , Nathan Chancellor , Nick Desaulniers , Segher Boessenkool , Vitaly Buka , linux-toolchains Subject: Re: [PATCH v4 43/45] namei: initialize parameters passed to step_into() Message-ID: References: <20220701142310.2188015-1-glider@google.com> <20220701142310.2188015-44-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 04, 2022 at 02:44:00PM +0100, Al Viro wrote: > On Mon, Jul 04, 2022 at 10:20:53AM +0200, Alexander Potapenko wrote: > > > What makes you think they are false positives? Is the scenario I > > described above: > > > > """ > > In particular, if the call to lookup_fast() in walk_component() > > returns NULL, and lookup_slow() returns a valid dentry, then the > > `seq` and `inode` will remain uninitialized until the call to > > step_into() > > """ > > > > impossible? > > Suppose step_into() has been called in non-RCU mode. The first > thing it does is > int err = handle_mounts(nd, dentry, &path, &seq); > if (err < 0) > return ERR_PTR(err); > > And handle_mounts() in non-RCU mode is > path->mnt = nd->path.mnt; > path->dentry = dentry; > if (nd->flags & LOOKUP_RCU) { > [unreachable code] > } > [code not touching seqp] > if (unlikely(ret)) { > [code not touching seqp] > } else { > *seqp = 0; /* out of RCU mode, so the value doesn't matter */ > } > return ret; Make that [code assigning ret a non-negative value and never using seqp] if (unlikely(ret)) { [code never using seqp or ret] } else { *seqp = 0; /* out of RCU mode, so the value doesn't matter */ } return ret; so if (err < 0) in the caller is equivalent to if (err).