mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
pidfs: detect refcount bugs
Now that we have pidfs_{get,register}_pid() that needs to be paired with
pidfs_put_pid() it's possible that someone pairs them with put_pid().
Thus freeing struct pid while it's still used by pidfs. Notice when that
happens. I'll also add a scheme to detect invalid uses of
pidfs_get_pid() and pidfs_put_pid() later.
Link: https://lore.kernel.org/20250506-uferbereich-guttun-7c8b1a0a431f@brauner
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
4dd6566b5a
commit
db56723cea
|
|
@ -100,6 +100,7 @@ void put_pid(struct pid *pid)
|
|||
|
||||
ns = pid->numbers[pid->level].ns;
|
||||
if (refcount_dec_and_test(&pid->count)) {
|
||||
WARN_ON_ONCE(pid->stashed);
|
||||
kmem_cache_free(ns->pid_cachep, pid);
|
||||
put_pid_ns(ns);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user