From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] get rid of dead code in legitimize_root()
Date: Fri, 20 May 2022 03:18:32 +0000 [thread overview]
Message-ID: <YocIiPQjR7tuYdkP@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <YocIMkS1qcPGrik0@zeniv-ca.linux.org.uk>
Combination of LOOKUP_IS_SCOPED and NULL nd->root.mnt is impossible
after successful path_init(). All places where ->root.mnt might
become NULL do that only if LOOKUP_IS_SCOPED is not there and
path_init() itself can return success without setting nd->root
only if ND_ROOT_PRESET had been set (in which case nd->root
had been set by caller and never changed) or if the name had
been a relative one *and* none of the bits in LOOKUP_IS_SCOPED
had been present.
Since all calls of legitimize_root() must be downstream of successful
path_init(), the check for !nd->root.mnt && (nd->flags & LOOKUP_IS_SCOPED)
is pure paranoia.
FWIW, it had been discussed (and agreed upon) with Aleksa back when
scoped lookups had been merged; looks like that had fallen through the
cracks back then.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/namei.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 2d6b94a950fe..bfe4ec9e282b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -729,13 +729,6 @@ static bool legitimize_links(struct nameidata *nd)
static bool legitimize_root(struct nameidata *nd)
{
- /*
- * For scoped-lookups (where nd->root has been zeroed), we need to
- * restart the whole lookup from scratch -- because set_root() is wrong
- * for these lookups (nd->dfd is the root, not the filesystem root).
- */
- if (!nd->root.mnt && (nd->flags & LOOKUP_IS_SCOPED))
- return false;
/* Nothing to do if nd->root is zero or is managed by the VFS user. */
if (!nd->root.mnt || (nd->state & ND_ROOT_PRESET))
return true;
--
2.30.2
next prev parent reply other threads:[~2022-05-20 3:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 3:17 [PATCHES] stuff from the last cycle that missed the window Al Viro
2022-05-20 3:17 ` [PATCH] fs/namei.c:reserve_stack(): tidy up the call of try_to_unlazy() Al Viro
2022-05-20 11:48 ` Christian Brauner
2022-05-20 3:18 ` Al Viro [this message]
2022-05-20 3:20 ` [PATCH] uninline may_mount() and don't opencode it in fspick(2)/fsopen(2) Al Viro
2022-05-20 3:20 ` [PATCH] linux/mount.h: trim includes Al Viro
2022-05-20 3:22 ` [PATCH] m->mnt_root->d_inode->i_sb is a weird way to spell m->mnt_sb Al Viro
2022-05-20 3:23 ` [PATCH] blob_to_mnt(): kern_unmount() is needed to undo kern_mount() Al Viro
2022-05-20 3:23 ` [PATCH] move mount-related externs from fs.h to mount.h Al Viro
2022-05-20 11:54 ` Christian Brauner
2022-05-20 19:02 ` [PATCH] blob_to_mnt(): kern_unmount() is needed to undo kern_mount() Eric W. Biederman
2022-05-20 11:45 ` [PATCH] linux/mount.h: trim includes Christian Brauner
2022-05-20 11:44 ` [PATCH] uninline may_mount() and don't opencode it in fspick(2)/fsopen(2) Christian Brauner
2022-05-20 11:43 ` [PATCH] get rid of dead code in legitimize_root() Christian Brauner
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=YocIiPQjR7tuYdkP@zeniv-ca.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
/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