Skip to contentSkip to conversation

fork13: a race in pid generation

PATCH New [email protected] 1 participant 1 message Dec 13, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1615822844.819121292217239826.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH v2 1/1 fork13: a race in pid generation

From the mainline commit 5fdee8c4a5e1800489ce61963208f8cc55e42ea1:

A program that repeatedly forks and waits is susceptible to having the same pid repeated, especially when it competes with another instance of the same program. This is really bad for bash implementation. Furthermore, many shell scripts assume that pid numbers will not be used for some length of time.

Race Description:

A B

// pid == offset == n // pid == offset == n + 1
test_and_set_bit(offset, map->page)

                                 test_and_set_bit(offset, map->page);
                                 pid_ns->last_pid = pid;
pid_ns->last_pid = pid;
                                 // pid == n + 1 is freed (wait())

                                 // Next fork()...
                                 last = pid_ns->last_pid; // == n
                                 pid = last + 1;

---
v2: backup/restore pid_max and remove probably artificial PID distance
assertion.

 runtest/syscalls                        |    1 +
 testcases/kernel/syscalls/fork/fork13.c |  179 +++++++++++++++++++++++++++++++
 2 files changed, 180 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fork/fork13.c
runtest/syscalls +1 -0
index 2071ed3..119d582 100644
@@ -274,6 +274,7 @@ fork08 fork08
 fork09 fork09
 fork10 fork10
 fork11 fork11
+fork13 fork13 -c 2 -i 10000000
 
 fpathconf01 fpathconf01
 
testcases/kernel/syscalls/fork/fork13.c new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.7.3.2

From 4681ff1796c0d9a9fa143b0c4b1452fe95303537 Mon Sep 17 00:00:00 2001
From: CAI Qian <[email protected]>
Date: Mon, 13 Dec 2010 13:08:37 +0800
Subject: [PATCH] fork13: a race in pid generation

From the mainline commit 5fdee8c4a5e1800489ce61963208f8cc55e42ea1:

A program that repeatedly forks and waits is susceptible to having the same pid repeated, especially when it competes with another instance of the same program. This is really bad for bash implementation. Furthermore, many shell scripts assume that pid numbers will not be used for some length of time.

Race Description:

A B

// pid == offset == n // pid == offset == n + 1
test_and_set_bit(offset, map->page)

                                 test_and_set_bit(offset, map->page);
                                 pid_ns->last_pid = pid;
pid_ns->last_pid = pid;
                                 // pid == n + 1 is freed (wait())

                                 // Next fork()...
                                 last = pid_ns->last_pid; // == n
                                 pid = last + 1;
---
 runtest/syscalls                        |    1 +
 testcases/kernel/syscalls/fork/fork13.c |  179 +++++++++++++++++++++++++++++++
 2 files changed, 180 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fork/fork13.c
runtest/syscalls +1 -0
index 2071ed3..119d582 100644
@@ -274,6 +274,7 @@ fork08 fork08
 fork09 fork09
 fork10 fork10
 fork11 fork11
+fork13 fork13 -c 2 -i 10000000
 
 fpathconf01 fpathconf01
 
testcases/kernel/syscalls/fork/fork13.c new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.7.3.2

------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL, new data types, scalar functions, improved concurrency, built-in packages, OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list