public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] crashme:fork12 test may kill other process that is not forked child
@ 2012-06-27  9:52 羅秉鈞
  2012-06-29  7:45 ` Wanlong Gao
  2012-06-29 16:22 ` [LTP] crashme:fork12 test may kill other process that is not forked child chrubis
  0 siblings, 2 replies; 8+ messages in thread
From: 羅秉鈞 @ 2012-06-27  9:52 UTC (permalink / raw)
  To: ltp-list

Dear All,

fork12 test forks as many child process as possible until
the system out of memory. And kernel OOM killer is
triggered to select candidate process to be killed.

fork12 expected one of its forked child process to be chosen,
but what if any other process is chosen. Even the worst,
shell script("/bin/sh") or parent process was chosen to be killed.
No way return and the system really crashed. But this is not
what fork12 wants.

I proposed the solution for this is disable the OOM killer of parent
process and adjust child process's oom_score_adj to 500(or any
other number larger than 0), this purpose just to make child process
can be easily chosen.

Do you have better idea? Thank you.

--------------------------------------------------------------------------------------------

From: Luo,BingJiun <bjluo@faraday-tech.com>
---
 .../testcases/kernel/syscalls/fork/fork12.c        |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/ltp-full-20120401/testcases/kernel/syscalls/fork/fork12.c
b/ltp-full-20120401/testcases/kernel/syscalls/fork/fork12.c
index d052fba..c3d7cb5 100644
--- a/ltp-full-20120401/testcases/kernel/syscalls/fork/fork12.c
+++ b/ltp-full-20120401/testcases/kernel/syscalls/fork/fork12.c
@@ -63,6 +63,7 @@ int main(int ac, char **av)
        int ret, status;
        int lc;                 /* loop counter */
        char *msg;              /* message returned from parse_opts */
+       char cmd[40];

        /*
         * parse standard options
@@ -76,6 +77,11 @@ int main(int ac, char **av)
         */
        setup();

+       /* adjust parent process so not be killed when out of memory */
+       sprintf(cmd,"echo -1000 > /proc/%d/oom_score_adj", getppid());
+       printf("%s\n", cmd);
+       system(cmd);
+
        /*
         * check looping state if -i option is given
         */
@@ -92,6 +98,9 @@ int main(int ac, char **av)
                                pause();
                                exit(0);
                        }
+                       /* adjust child process so it is killed first
when out of memory */
+                       sprintf(cmd,"echo 500 > /proc/%d/oom_score_adj", pid1);
+                       system(cmd);
                        forks++;
                        ret = waitpid(-1, &status, WNOHANG);
                        if (ret < 0)
-- 
1.7.0.4



Best Regards,
Bing-Jiun

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-10-17 12:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-27  9:52 [LTP] crashme:fork12 test may kill other process that is not forked child 羅秉鈞
2012-06-29  7:45 ` Wanlong Gao
2012-10-09  6:08   ` [LTP] [PATCH] io_submit: uninitialized iocb may not return -EINVAL Nitin Yadav
2012-10-16  2:31     ` Wanlong Gao
2012-10-16  6:53       ` Jan Stancek
2012-10-16 10:11         ` chrubis
     [not found]           ` <E351E450E8B9F54684A699D42DC5ADF2263AF477@MPBAGVEX02.corp.mphasis.com>
     [not found]             ` <E351E450E8B9F54684A699D42DC5ADF22640E162@MPBAGVEX02.corp.mphasis.com>
2012-10-17 12:44               ` [LTP] [PATCH] io_submit: uninitialized iocb may notreturn-EINVAL chrubis
2012-06-29 16:22 ` [LTP] crashme:fork12 test may kill other process that is not forked child chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox