diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-01-28 20:25:24 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-01-28 20:25:24 +0300 |
commit | 76fcbc9c7c57a5d44e7ca493d8f2f6eba3964f29 (patch) | |
tree | 7d3afcdf830cfc2fae495c00f7ddeca79be0c026 | |
parent | a773abf72eb0cac008743891068ca6edecc44683 (diff) | |
parent | f9d87929d451d3e649699d0f1d74f71f77ad38f5 (diff) | |
download | linux-76fcbc9c7c57a5d44e7ca493d8f2f6eba3964f29.tar.xz |
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
-rw-r--r-- | kernel/ucount.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/ucount.c b/kernel/ucount.c index 7b32c356ebc5..65b597431c86 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -190,6 +190,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) kfree(new); } else { hlist_add_head(&new->node, hashent); + get_user_ns(new->ns); spin_unlock_irq(&ucounts_lock); return new; } @@ -210,6 +211,7 @@ void put_ucounts(struct ucounts *ucounts) if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { hlist_del_init(&ucounts->node); spin_unlock_irqrestore(&ucounts_lock, flags); + put_user_ns(ucounts->ns); kfree(ucounts); } } |