Skip to content

Commit 76fcbc9

Browse files
committed
Merge branch 'ucount-rlimit-fixes-for-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull ucount rlimit fix from Eric Biederman. Make sure the ucounts have a reference to the user namespace it refers to, so that users that themselves don't carry such a reference around can safely use the ucount functions. * 'ucount-rlimit-fixes-for-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: ucount: Make get_ucount a safe get_user replacement
2 parents a773abf + f9d8792 commit 76fcbc9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/ucount.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
190190
kfree(new);
191191
} else {
192192
hlist_add_head(&new->node, hashent);
193+
get_user_ns(new->ns);
193194
spin_unlock_irq(&ucounts_lock);
194195
return new;
195196
}
@@ -210,6 +211,7 @@ void put_ucounts(struct ucounts *ucounts)
210211
if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) {
211212
hlist_del_init(&ucounts->node);
212213
spin_unlock_irqrestore(&ucounts_lock, flags);
214+
put_user_ns(ucounts->ns);
213215
kfree(ucounts);
214216
}
215217
}

0 commit comments

Comments
 (0)