lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d3a6c5ad-bca4-1a33-9e02-0985b708eb4a@fujitsu.com>
Date:   Fri, 17 Dec 2021 09:35:21 +0000
From:   "lizhijian@...itsu.com" <lizhijian@...itsu.com>
To:     Shuah Khan <skhan@...uxfoundation.org>,
        Christian Brauner <christian.brauner@...ntu.com>,
        Kees Cook <keescook@...omium.org>
CC:     "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "shuah@...nel.org" <shuah@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...capital.net>,
        Will Drewry <wad@...omium.org>,
        Christian Brauner <christian@...uner.io>,
        Philip Li <philip.li@...el.com>,
        "xuyang2018.jy@...itsu.com" <xuyang2018.jy@...itsu.com>
Subject: Re: [PATCH 1/2] kselftest: signal all child processes

I just post V2 which split these 2 patches standalone for reviewing easily.
And rewrite 2/2 with pipe()

PTAL


Thanks
Zhijian


On 04/12/2021 01:03, Shuah Khan wrote:
> On 12/2/21 8:05 PM, lizhijian@...itsu.com wrote:
>> kindly ping
>>
>>
>> On 29/10/2021 16:31, Christian Brauner wrote:
>>> On Fri, Oct 29, 2021 at 10:45:27AM +0800, Li Zhijian wrote:
>>>> We have some many cases that will create child process as well, such as
>>>> pidfd_wait. Previously, we will signal/kill the parent process when it
>>>> is time out, but this signal will not be sent to its child process. In
>>>> such case, if child process doesn't terminate itself, ksefltest framework
>>>> will hang forever.
>>>>
>>>> below ps tree show the situation when ksefltest is blocking:
>>>> root      1172  0.0  0.0   5996  2500 ?        S    07:03 0:00  \_ /bin/bash /lkp/lkp/src/tests/kernel-selftests
>>>> root      1216  0.0  0.0   4392  1976 ?        S    07:03 0:00      \_ make run_tests -C pidfd
>>>> root      1218  0.0  0.0   2396  1652 ?        S    07:03 0:00          \_ /bin/sh -c BASE_DIR="/usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests"; . /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/runner.sh; if [ "X" != "X" ]; then per_test_logging=1; fi; run_many /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_fdinfo_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_open_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_poll_test 
>>>> /usr/src/perf_selftests-x86_64-rhel-8.
>>>> root     12491  0.0  0.0   2396   132 ?        S    07:03 0:00              \_ /bin/sh -c BASE_DIR="/usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests"; . /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/runner.sh; if [ "X" != "X" ]; then per_test_logging=1; fi; run_many /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_fdinfo_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_open_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_poll_test 
>>>> /usr/src/perf_selftests-x86_64-rhe
>>>> root     12492  0.0  0.0   2396   132 ?        S    07:03 0:00                  \_ /bin/sh -c BASE_DIR="/usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests"; . /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/runner.sh; if [ "X" != "X" ]; then per_test_logging=1; fi; run_many /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_fdinfo_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_open_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_poll_test 
>>>> /usr/src/perf_selftests-x86_64
>>>> root     12493  0.0  0.0   2396   132 ?        S    07:03 0:00                      \_ /bin/sh -c BASE_DIR="/usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests"; . /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/runner.sh; if [ "X" != "X" ]; then per_test_logging=1; fi; run_many /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_fdinfo_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_open_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_poll_test 
>>>> /usr/src/perf_selftests-x8
>>>> root     12496  0.0  0.0   2396   132 ?        S    07:03 0:00                          \_ /bin/sh -c BASE_DIR="/usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests"; . /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/runner.sh; if [ "X" != "X" ]; then per_test_logging=1; fi; run_many /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_fdinfo_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_open_test /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/pidfd/pidfd_poll_test 
>>>> /usr/src/perf_selftest
>>>> root     12498  0.0  0.0  10564  6116 ?        S    07:03 0:00                              \_ perl /usr/src/perf_selftests-x86_64-rhel-8.3-kselftests-519d81956ee277b4419c723adfb154603c2565ba/tools/testing/selftests/kselftest/prefix.pl
>>>> root     12503  0.0  0.0   2452   112 ?        T    07:03 0:00 ./pidfd_wait
>>>> root     12621  0.0  0.0   2372  1600 ?        SLs  07:04 0:00 /usr/sbin/watchdog
>>>> root     19438  0.0  0.0    992    60 ?        Ss   07:39 0:00 /lkp/lkp/src/bin/event/wakeup activate-monitor
>>>>
>>>> Here we group all its child processes so that kill() can signal all of
>>>> them in timeout.
>>>>
>>>> CC: Kees Cook <keescook@...omium.org>
>>>> CC: Andy Lutomirski <luto@...capital.net>
>>>> CC: Will Drewry <wad@...omium.org>
>>>> CC: Shuah Khan <shuah@...nel.org>
>>>> CC: Christian Brauner <christian@...uner.io>
>>>> CC: Philip Li <philip.li@...el.com>
>>>> Suggested-by: yang xu <xuyang2018.jy@...fujitsu.com>
>>>> Signed-off-by: Li Zhijian <lizhijian@...fujitsu.com>
>>>> ---
>>> Seems sensible. Is it guaranteed that t->pid is neither 0 nor 1? If not
>>> then maybe sanity check t->pid at least for not being 1 as negating that
>>> would mean "signal everything that you have permission to signal". :)
>>>
>>> Otherwise,
>>> Acked-by: Christian Brauner <christian.brauner@...ntu.com>
>>>
>>>> tools/testing/selftests/kselftest_harness.h | 4 +++-
>>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
>>>> index ae0f0f33b2a6..c7251396e7ee 100644
>>>> --- a/tools/testing/selftests/kselftest_harness.h
>>>> +++ b/tools/testing/selftests/kselftest_harness.h
>>>> @@ -875,7 +875,8 @@ static void __timeout_handler(int sig, siginfo_t *info, void *ucontext)
>>>>        }
>>>>           t->timed_out = true;
>>>> -    kill(t->pid, SIGKILL);
>>>> +    // signal process group
>>>> +    kill(-(t->pid), SIGKILL);
>>>>    }
>>>>       void __wait_for_test(struct __test_metadata *t)
>>>> @@ -985,6 +986,7 @@ void __run_test(struct __fixture_metadata *f,
>>>>            ksft_print_msg("ERROR SPAWNING TEST CHILD\n");
>>>>            t->passed = 0;
>>>>        } else if (t->pid == 0) {
>>>> +        setpgrp();
>>>>            t->fn(t, variant);
>>>>            if (t->skip)
>>>>                _exit(255);
>>>> -- 
>>>> 2.33.0
>>>>
>>>>
>>>>
>>>
>>
>
> Kees,
>
> Will you be able to take a look at this fix? This is in the kselftest_harness
>
> thanks,
> -- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ