All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Anant Thazhemadam <anant.thazhemadam@gmail.com>,
	syzbot+4191a44ad556eacc1a7a@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] [PATCH] fs: fix KMSAN uninit-value bug by initializing nd in do_file_open_root
Date: Sat, 19 Sep 2020 17:55:58 +0100	[thread overview]
Message-ID: <20200919165558.GH3421308@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200919161727.GG3421308@ZenIV.linux.org.uk>

On Sat, Sep 19, 2020 at 05:17:27PM +0100, Al Viro wrote:

> Lovely...  That would get an empty path and non-directory for a starting
> point, but it should end up with LAST_ROOT in nd->last_type.  Which should
> not be able to reach the readers of those fields...  Which kernel had
> that been on?

Yecchhh...  I see what's going on; I suspect that this ought to be enough.
Folks, could somebody test it on the original reproducer setup?

diff --git a/fs/namei.c b/fs/namei.c
index e99e2a9da0f7..3f02cae7e73f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2113,8 +2113,10 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 		return PTR_ERR(name);
 	while (*name=='/')
 		name++;
-	if (!*name)
+	if (!*name) {
+		nd->dir_mode = 0; // short-circuit the 'hardening' idiocy
 		return 0;
+	}
 
 	/* At this point we know we have a real path component. */
 	for(;;) {
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

WARNING: multiple messages have this Message-ID (diff)
From: Al Viro <viro@zeniv.linux.org.uk>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Eric Biggers <ebiggers@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	Anant Thazhemadam <anant.thazhemadam@gmail.com>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	syzbot+4191a44ad556eacc1a7a@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [Linux-kernel-mentees] [PATCH] fs: fix KMSAN uninit-value bug by initializing nd in do_file_open_root
Date: Sat, 19 Sep 2020 17:55:58 +0100	[thread overview]
Message-ID: <20200919165558.GH3421308@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200919161727.GG3421308@ZenIV.linux.org.uk>

On Sat, Sep 19, 2020 at 05:17:27PM +0100, Al Viro wrote:

> Lovely...  That would get an empty path and non-directory for a starting
> point, but it should end up with LAST_ROOT in nd->last_type.  Which should
> not be able to reach the readers of those fields...  Which kernel had
> that been on?

Yecchhh...  I see what's going on; I suspect that this ought to be enough.
Folks, could somebody test it on the original reproducer setup?

diff --git a/fs/namei.c b/fs/namei.c
index e99e2a9da0f7..3f02cae7e73f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2113,8 +2113,10 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 		return PTR_ERR(name);
 	while (*name=='/')
 		name++;
-	if (!*name)
+	if (!*name) {
+		nd->dir_mode = 0; // short-circuit the 'hardening' idiocy
 		return 0;
+	}
 
 	/* At this point we know we have a real path component. */
 	for(;;) {

  reply	other threads:[~2020-09-19 16:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  5:26 [Linux-kernel-mentees] [PATCH] fs: fix KMSAN uninit-value bug by initializing nd in do_file_open_root Anant Thazhemadam
2020-09-16  5:26 ` Anant Thazhemadam
2020-09-16  5:41 ` [Linux-kernel-mentees] " Eric Biggers
2020-09-16  5:41   ` Eric Biggers
2020-09-17  0:22   ` [Linux-kernel-mentees] " Al Viro
2020-09-17  0:22     ` Al Viro
2020-09-19 14:44     ` [Linux-kernel-mentees] " Greg KH
2020-09-19 14:44       ` Greg KH
2020-09-19 16:17       ` Al Viro
2020-09-19 16:17         ` Al Viro
2020-09-19 16:55         ` Al Viro [this message]
2020-09-19 16:55           ` Al Viro
2020-09-19 11:33           ` Anant Thazhemadam
2020-09-19 11:33             ` Anant Thazhemadam
2020-09-19 20:17             ` Anant Thazhemadam
2020-09-19 20:17               ` Anant Thazhemadam
2020-10-04 15:25               ` Anant Thazhemadam
2020-10-04 15:25                 ` Anant Thazhemadam
2020-09-16  6:16 ` Greg KH
2020-09-16  6:16   ` Greg KH

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=20200919165558.GH3421308@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=anant.thazhemadam@gmail.com \
    --cc=ebiggers@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+4191a44ad556eacc1a7a@syzkaller.appspotmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.