Skip to content

Commit db04dc6

Browse files
committed
proc: Use nd_jump_link in proc_ns_follow_link
Update proc_ns_follow_link to use nd_jump_link instead of just manually updating nd.path.dentry. This fixes the BUG_ON(nd->inode != parent->d_inode) reported by Dave Jones and reproduced trivially with mkdir /proc/self/ns/uts/a. Sigh it looks like the VFS change to require use of nd_jump_link happend while proc_ns_follow_link was baking and since the common case of proc_ns_follow_link continued to work without problems the need for making this change was overlooked. Cc: [email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 9141770 commit db04dc6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/proc/namespaces.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
118118
struct super_block *sb = inode->i_sb;
119119
struct proc_inode *ei = PROC_I(inode);
120120
struct task_struct *task;
121-
struct dentry *ns_dentry;
121+
struct path ns_path;
122122
void *error = ERR_PTR(-EACCES);
123123

124124
task = get_proc_task(inode);
@@ -128,14 +128,14 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
128128
if (!ptrace_may_access(task, PTRACE_MODE_READ))
129129
goto out_put_task;
130130

131-
ns_dentry = proc_ns_get_dentry(sb, task, ei->ns_ops);
132-
if (IS_ERR(ns_dentry)) {
133-
error = ERR_CAST(ns_dentry);
131+
ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns_ops);
132+
if (IS_ERR(ns_path.dentry)) {
133+
error = ERR_CAST(ns_path.dentry);
134134
goto out_put_task;
135135
}
136136

137-
dput(nd->path.dentry);
138-
nd->path.dentry = ns_dentry;
137+
ns_path.mnt = mntget(nd->path.mnt);
138+
nd_jump_link(nd, &ns_path);
139139
error = NULL;
140140

141141
out_put_task:

0 commit comments

Comments
 (0)