Skip to content

Commit db56723

Browse files
committed
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 <[email protected]>
1 parent 4dd6566 commit db56723

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/pid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void put_pid(struct pid *pid)
100100

101101
ns = pid->numbers[pid->level].ns;
102102
if (refcount_dec_and_test(&pid->count)) {
103+
WARN_ON_ONCE(pid->stashed);
103104
kmem_cache_free(ns->pid_cachep, pid);
104105
put_pid_ns(ns);
105106
}

0 commit comments

Comments
 (0)