Commit db4570bb authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Greg Kroah-Hartman

Fix failure path in alloc_pid()

commit 1a80dade upstream.

The failure path removes the allocated PIDs from the wrong namespace.
This could lead to us inadvertently reusing PIDs in the leaf namespace
and leaking PIDs in parent namespaces.

Fixes: 95846ecf ("pid: replace pid bitmap implementation with IDR API")
Cc: <>
Signed-off-by: default avatarMatthew Wilcox <>
Acked-by: default avatar"Eric W. Biederman" <>
Reviewed-by: default avatarOleg Nesterov <>
Signed-off-by: default avatarLinus Torvalds <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 1fdd2859
......@@ -233,8 +233,10 @@ struct pid *alloc_pid(struct pid_namespace *ns)
while (++i <= ns->level)
idr_remove(&ns->idr, (pid->numbers + i)->nr);
while (++i <= ns->level) {
upid = pid->numbers + i;
idr_remove(&upid->ns->idr, upid->nr);
/* On failure to allocate the first pid, reset the state */
if (ns->pid_allocated == PIDNS_ADDING)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment