[Devel] [PATCH RHEL9 COMMIT] pid_max: use pid_max from proper pidns

Konstantin Khorenko khorenko at virtuozzo.com
Fri Nov 12 19:50:24 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.26
------>
commit 25743bec039e3c9fb90fd807019404a7b5e291ec
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue Nov 2 20:09:36 2021 +0300

    pid_max: use pid_max from proper pidns
    
    We should use pid_max from pidns where we are allocating pid, note that
    in alloc_pid we first allocate pid in ns than in it's parent and so on
    and so forth, so we should use proper limit for each allocation.
    
    Problem reproduces when there are a lot of processes on host and we
    create a pid namespace with lower pid_max limit, before this patch we
    fail to fork processes with EAGAIN.
    
    https://jira.sw.ru/browse/PSBM-135461
    Fixes: be6c3736d9cb ("pid_ns: Virtualize pid_max")
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 kernel/pid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index 6b1a86863d5e..29e21ccfdf0b 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -231,7 +231,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
 			 * a partially initialized PID (see below).
 			 */
 			nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
-					      ns->pid_max, GFP_ATOMIC);
+					      tmp->pid_max, GFP_ATOMIC);
 		}
 		spin_unlock_irq(&pidmap_lock);
 		idr_preload_end();


More information about the Devel mailing list