Skip to contentSkip to conversation

pidns: fix free_pid() to handle the first fork failure

PATCH RESEND In review Oleg Nesterov 2 participants 2 messages Sep 15, 2013 – Sep 16, 2013

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 pidns: fix free_pid() to handle the first fork failure

"case 0" in free_pid() assumes that disable_pid_allocation() should clear PIDNS_HASH_ADDING before the last pid goes away. However this doesn't happen if the 1st fork() fails to create the child reaper which should call disable_pid_allocation().

---
 kernel/pid.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/pid.c +5 -0
index 66505c1..606a212 100644
@@ -272,6 +272,11 @@ void free_pid(struct pid *pid)
 			 */
 			wake_up_process(ns->child_reaper);
 			break;
+		case PIDNS_HASH_ADDING:
+			/* Handle a fork failure of the first process */
+			WARN_ON(ns->child_reaper);
+			ns->nr_hashed = 0;
+			/* fall through */
 		case 0:
 			schedule_work(&ns->proc_work);
 			break;
Signature · 1 line
1.5.5.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Oleg Nesterov

"case 0" in free_pid() assumes that disable_pid_allocation() should clear PIDNS_HASH_ADDING before the last pid goes away. However this doesn't happen if the 1st fork() fails to create the child reaper which should call disable_pid_allocation().

Quoted 2 lines

---

I am not really setup to do deal with bug fixes, inbetween releases but if Andrew doesn't grab this I will toss this in my tree for 3.13.

Eric

Quoted 19 lines
 kernel/pid.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/pid.c +5 -0
index 66505c1..606a212 100644
@@ -272,6 +272,11 @@ void free_pid(struct pid *pid)
 			 */
 			wake_up_process(ns->child_reaper);
 			break;
+		case PIDNS_HASH_ADDING:
+			/* Handle a fork failure of the first process */
+			WARN_ON(ns->child_reaper);
+			ns->nr_hashed = 0;
+			/* fall through */
 		case 0:
 			schedule_work(&ns->proc_work);
 			break;