]> Git Repo - linux.git/commitdiff
Fix failure path in alloc_pid()
authorMatthew Wilcox <[email protected]>
Fri, 28 Dec 2018 15:22:26 +0000 (07:22 -0800)
committerLinus Torvalds <[email protected]>
Fri, 28 Dec 2018 20:42:30 +0000 (12:42 -0800)
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: 95846ecf9dac ("pid: replace pid bitmap implementation with IDR API")
Cc: <[email protected]>
Signed-off-by: Matthew Wilcox <[email protected]>
Acked-by: "Eric W. Biederman" <[email protected]>
Reviewed-by: Oleg Nesterov <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
kernel/pid.c

index b2f6c506035da7c75b6b7e277f8d7c1a7ee244a2..20881598bdfaccc2e0ad736e1e2f8228ca3299bf 100644 (file)
@@ -233,8 +233,10 @@ out_unlock:
 
 out_free:
        spin_lock_irq(&pidmap_lock);
-       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)
This page took 0.057305 seconds and 4 git commands to generate.