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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65A5DC1975A for ; Wed, 25 Mar 2020 06:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C1B4206F8 for ; Wed, 25 Mar 2020 06:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbgCYGAn (ORCPT ); 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)) { /*