linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Null-ptr-deref due to "sanitized pathwalk machinery (v4)"
Date: Wed, 25 Mar 2020 15:43:06 -0400	[thread overview]
Message-ID: <C2554121-109E-450A-965F-B8DFE2B0E528@lca.pw> (raw)
In-Reply-To: <20200325055830.GL23230@ZenIV.linux.org.uk>



> On Mar 25, 2020, at 1:58 AM, Al Viro <viro@zeniv.linux.org.uk> 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.  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)) {
> 			/*

Since that one has a compilation warning, I have tested this patch and seen no crash so far.

diff --git a/fs/namei.c b/fs/namei.c
index 311e33dbac63..73851acdbf3a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1806,6 +1806,9 @@ static const char *handle_dots(struct nameidata *nd, int type)
                                         parent, inode, seq);
                }
 
+               if (unlikely(error))
+                       return error;
+
                if (unlikely(nd->flags & LOOKUP_IS_SCOPED)) {
                        /*
                         * If there was a racing rename or mount along our

  parent reply	other threads:[~2020-03-25 19:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 21:06 Null-ptr-deref due to "sanitized pathwalk machinery (v4)" Qian Cai
2020-03-24 21:46 ` Al Viro
2020-03-25  1:49   ` Qian Cai
2020-03-25  2:13     ` Al Viro
2020-03-25  3:24       ` Qian Cai
2020-03-25  4:03         ` Al Viro
2020-03-25  5:58           ` Al Viro
2020-03-25 14:02             ` Al Viro
2020-03-25 14:05               ` Al Viro
2020-03-25 19:43             ` Qian Cai [this message]
2020-03-25 21:07               ` Al Viro
2020-03-25 13:21           ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C2554121-109E-450A-965F-B8DFE2B0E528@lca.pw \
    --to=cai@lca.pw \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).