Skip to content

Commit 87ad46e

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull proc fix from Eric Biederman: "A brown paper bag slipped through my proc changes, and syzcaller caught it when the code ended up in your tree. I have opted to fix it the simplest cleanest way I know how, so there is no reasonable chance for the bug to repeat" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: proc: Use a dedicated lock in struct pid
2 parents 75bdc92 + 63f818f commit 87ad46e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

fs/proc/base.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,9 +1839,9 @@ void proc_pid_evict_inode(struct proc_inode *ei)
18391839
struct pid *pid = ei->pid;
18401840

18411841
if (S_ISDIR(ei->vfs_inode.i_mode)) {
1842-
spin_lock(&pid->wait_pidfd.lock);
1842+
spin_lock(&pid->lock);
18431843
hlist_del_init_rcu(&ei->sibling_inodes);
1844-
spin_unlock(&pid->wait_pidfd.lock);
1844+
spin_unlock(&pid->lock);
18451845
}
18461846

18471847
put_pid(pid);
@@ -1877,9 +1877,9 @@ struct inode *proc_pid_make_inode(struct super_block * sb,
18771877
/* Let the pid remember us for quick removal */
18781878
ei->pid = pid;
18791879
if (S_ISDIR(mode)) {
1880-
spin_lock(&pid->wait_pidfd.lock);
1880+
spin_lock(&pid->lock);
18811881
hlist_add_head_rcu(&ei->sibling_inodes, &pid->inodes);
1882-
spin_unlock(&pid->wait_pidfd.lock);
1882+
spin_unlock(&pid->lock);
18831883
}
18841884

18851885
task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid);
@@ -3273,7 +3273,7 @@ static const struct inode_operations proc_tgid_base_inode_operations = {
32733273

32743274
void proc_flush_pid(struct pid *pid)
32753275
{
3276-
proc_invalidate_siblings_dcache(&pid->inodes, &pid->wait_pidfd.lock);
3276+
proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock);
32773277
put_pid(pid);
32783278
}
32793279

include/linux/pid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct pid
6060
{
6161
refcount_t count;
6262
unsigned int level;
63+
spinlock_t lock;
6364
/* lists of tasks that use this pid */
6465
struct hlist_head tasks[PIDTYPE_MAX];
6566
struct hlist_head inodes;

kernel/pid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
256256

257257
get_pid_ns(ns);
258258
refcount_set(&pid->count, 1);
259+
spin_lock_init(&pid->lock);
259260
for (type = 0; type < PIDTYPE_MAX; ++type)
260261
INIT_HLIST_HEAD(&pid->tasks[type]);
261262

0 commit comments

Comments
 (0)