mbind04: terminate child processes
PATCH 1/1 mbind04: terminate child processes
verify_policy() forks a child, which continues to run pass end of function and into same loop in verify_mbind() as parent, effectively creating fork bomb. With 2 nodes, there's 45 forked children. With 4 nodes, 765 processes.
Terminate child process at the end of verify_policy();
--- testcases/kernel/syscalls/mbind/mbind04.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/mbind/mbind04.c +6 -1
@@ -47,6 +47,7 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)struct bitmask *bm =numa_allocate_nodemask ();unsigned int i;void *ptr; +pid_t child;unsigned long size =PAGES_ALLOCATED * page_size;numa_bitmask_setbit (bm, node);
@@ -69,7 +70,8 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)const char *prefix ="child: " ; -if (SAFE_FORK ()) { + child =SAFE_FORK (); +if (child) { prefix ="parent: " ;tst_reap_children (); }
@@ -104,6 +106,9 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)if (fail)tst_nodemap_print_counters (nodes); + +if (!child) +exit (0 ); }static const int modes[] = {
Signature · 1 line
1.8.3.1
PATCH 1/1 mbind04: terminate child processes
Hi!
Quoted 6 lines
verify_policy()forks a child, which continues to run pass end of function and into same loop inverify_mbind()as parent, effectively creating fork bomb. With 2 nodes, there's 45 forked children. With 4 nodes, 765 processes.Terminate child process at the end of
verify_policy();
Good catch, thanks for fixing this.
Quoted 28 lines
Signed-off-by Jan Stancek <[email protected]>--- testcases/kernel/syscalls/mbind/mbind04.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)testcases/kernel/syscalls/mbind/mbind04.c +3
-1@@ -47,6 +47,7 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)struct bitmask *bm =numa_allocate_nodemask ();unsigned int i;void *ptr; +pid_t child;unsigned long size =PAGES_ALLOCATED * page_size;numa_bitmask_setbit (bm, node);@@ -69,7 +70,8 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)const char *prefix ="child: " ; -if (SAFE_FORK ()) { + child =SAFE_FORK (); +if (child) { prefix ="parent: " ;tst_reap_children (); }
testcases/kernel/syscalls/mbind/mbind04.c static void verify_policy(unsigned int node, int mode, unsigned flag) · line 112
Quoted 7 lines
testcases/kernel/syscalls/mbind/mbind04.c +3
-0@@ -104,6 +106,9 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)if (fail)tst_nodemap_print_counters (nodes); + +if (!child) +exit (0 ); }
I find the name for the variable quite confusing here, because it suggests that the parent exits here, while the opposite is true. Can we please just use pid or something less confusing for the variable name?
Other than that it's fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 mbind04: terminate child processes
Quoted 3 lines
I find the name for the variable quite confusing here, because it suggests that the parent exits here, while the opposite is true. Can we please just use pid or something less confusing for the variable name?
Pushed with renamed variable.