Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp649807ybb; Wed, 25 Mar 2020 07:05:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuEeAfOuxt66Kg6cJAxWCMQvtaVcqmnGk0wq5PbOiP9LGKOxFRfFmuPmV2rDjcB1erzUUD1 X-Received: by 2002:a05:6830:616:: with SMTP id w22mr2473461oti.215.1585145102906; Wed, 25 Mar 2020 07:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585145102; cv=none; d=google.com; s=arc-20160816; b=0c0mUnlcUCscAiv2mbmHfPAhJiwCyR5poVdhixZ25lQJQNoy/xv08pVJtdMitmzf9Y UyXkh/v61rmyxSQCF/5MlTiv3g7ZPI89Zflz89wHO462MBouF/Fh63VuCpv2FXuVnAkV 8gqDtcCyaE7rcJaZjvMMYvIWiXlF8kHb9UG77lIDYrBQt57oHBmln4Yfq3m+23BZK6aZ dhlb9gbt58st9lYhc1TjCWmc2qwSfxt/Bx3LxIX9tAoxV0oAHI+B9/5C4Qkv38uzKDNT f+T+jhK8wIxXDZm3xTxv7QJjLr7PnHJPVqds3IJJel5AD9rChL3Hgz13ycyLY99Z2RG6 WKmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=xLE3YtGLbKIOfg8J8O7YGEB1OgWBX+MT8nVLS7nZfGY=; b=AudKU5K7gzsrA7h3n6tiduRllwbGHKJ9OyhcJqub+7mGorUpkgg587d7C7KNuourVp ByHl94VJiNKdmWgYbQXIFRKnoaqVEL6y5eg56Me4u20cN+hZ/cWmg/8Fb1Afi/LTdUFb Gni0gjN48i8Gs/UVeE+u2wseZy2czF66i3PqXBrviOx/kJ2UkXxYypMIec+Owf9GSEdJ JF0EV6D1LLGaJcXNgdENv2Cpy14Qu8zhYetaxi21Hgs8LqWQJCSQSNjlk7UAYea+Az1Z QXfg3+CWdcVE/7ZPPGI7uGaxk32FyE1m/Ne6zSfI8unuC6JNTbZ35Q+tupnS2iIlxCrT rI7A== 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 e20si10643372otk.273.2020.03.25.07.04.19; Wed, 25 Mar 2020 07:05:02 -0700 (PDT) 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 S1727561AbgCYOCK (ORCPT + 99 others); Wed, 25 Mar 2020 10:02:10 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:48968 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbgCYOCK (ORCPT ); Wed, 25 Mar 2020 10:02:10 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jH6bf-002WDe-9O; Wed, 25 Mar 2020 14:02:07 +0000 Date: Wed, 25 Mar 2020 14:02:07 +0000 From: Al Viro To: Qian Cai Cc: Linus Torvalds , linux-fsdevel@vger.kernel.org, LKML Subject: Re: Null-ptr-deref due to "sanitized pathwalk machinery (v4)" Message-ID: <20200325140207.GM23230@ZenIV.linux.org.uk> References: <4CBDE0F3-FB73-43F3-8535-6C75BA004233@lca.pw> <20200324214637.GI23230@ZenIV.linux.org.uk> <20200325021327.GJ23230@ZenIV.linux.org.uk> <5281297D-B66E-4A4C-9B41-D2242F6B7AE7@lca.pw> <20200325040359.GK23230@ZenIV.linux.org.uk> <20200325055830.GL23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200325055830.GL23230@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 05:58:30AM +0000, Al Viro wrote: > On Wed, Mar 25, 2020 at 04:03:59AM +0000, Al Viro wrote: > > > Lovely. So > > * we really do get NULL nd->path.dentry there; I've not misread the > > trace. > > * on the entry into link_path_walk() nd->path.dentry is non-NULL. > > * *ALL* components should've been LAST_NORM ones > > * not a single symlink in sight, unless the setup is rather unusual > > * possibly not even a single mountpoint along the way (depending > > upon the userland used) > > OK, I see one place where that could occur, but I really don't see how that > could be triggered on this pathname, short of very odd symlink layout in > the filesystem on the testbox. ... which, apparently, is what you've got there (/var/run -> ../run), so stepping into that braino is not implausible. Could you check if the fix below fixes what you've observed? I am folding it in anyway (into "lift all calls of step_into() out of follow_dotdot/follow_dotdot_rcu") - it's an obvious braino introduced in the commit in question, but I'd like a confirmation that this _is_ what you've caught. > Does the following fix your reproducer? > > diff --git a/fs/namei.c b/fs/namei.c > index 311e33dbac63..4082b70f32ff 100644 > --- a/fs/namei.c > +++ b/fs/namei.c > @@ -1805,6 +1805,8 @@ static const char *handle_dots(struct nameidata *nd, int type) > error = step_into(nd, WALK_NOFOLLOW, > parent, inode, seq); > } > + if (unlikely(error)) > + return ERR_PTR(error); > > if (unlikely(nd->flags & LOOKUP_IS_SCOPED)) { > /*