Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp294531ybb; Tue, 24 Mar 2020 23:02:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtAdb4+30AX5vQ3lC78gSLMpZtNFVedsjhjHZTMlo6EOxk+aahMHyqs9T+tvbgWS14MUYJZ X-Received: by 2002:aca:5a56:: with SMTP id o83mr1337287oib.134.1585116163646; Tue, 24 Mar 2020 23:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585116163; cv=none; d=google.com; s=arc-20160816; b=oQeCWBRwuz5kLXmm2CekW6r8Dhl42tksBYlQ2pCxL5y0dylOcGh7m6dN57Uz4j5qUb 18Ed1V0CVVEaujlcqHqiK7fHsZNAAXp9VDgJEitoyC/Gd4lu9t4qeYgk8XuH/NP51qE6 4M1BSYtwPoE6eh3BXB7v7w69WEpJmkp1CBHzIeful7rbLYg7nU9boG5btsO2nD10b2Mw tLtEPfFN2vxvAshSd7TEgS7oGHJ6IF7x0qbtwSUUTNXPsZkzIuafd9yb9fHZepHtcaab TQu2RgpGiiPOuB5aVC3dAqgJXMox07Pz6a4xEqez6hL5MQ15DcPNMayZKRFZ1jgt44NL ic5A== 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=RJlfzu3NbAJ/disf5h028NUrbqCQCTD0rR0ZHetcwTg=; b=EmqBpgLWH3kz59A0ga1H5jpId1zkmIrhZucXvGXB613KC+7E/+v69k26RMzj1E3mpj K23hR9DtckPNfqLcz927tJsJuof6eJmK0g2Vnq+k+Bb6rGEFLS7Wmli84LFLGErkfSwn gPeWkkFS1OFxUsJNScmg9pkksnAbbHZ+VNrPf0s2fwq+kiajuME8q7+72OSyJJJ2M8ZG I2lrMd0tNsx2ZN5Ywax6h2MW0gnoPlDrTXgeTvezksz4Uxych/unbc+/Ht2zGAihCNMf E8tWPpR1G8E3sRpox8E1PUaF89uKesJwWY49bZeXD0slxOloUjNYPTi2ZfTksFcKYrSn m3FA== 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 141si9275794oii.44.2020.03.24.23.02.29; Tue, 24 Mar 2020 23:02:43 -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 S1726109AbgCYGAn (ORCPT + 99 others); Wed, 25 Mar 2020 02:00:43 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:43040 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgCYGAn (ORCPT ); Wed, 25 Mar 2020 02:00:43 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jGz3e-002EkU-4i; Wed, 25 Mar 2020 05:58:30 +0000 Date: Wed, 25 Mar 2020 05:58:30 +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: <20200325055830.GL23230@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200325040359.GK23230@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 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. 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)) { /*