* [LTP] [PATCH] Fix prctl02 @ 2020-01-23 14:31 Martin Doucha 2020-01-23 14:55 ` Jan Stancek 0 siblings, 1 reply; 8+ messages in thread From: Martin Doucha @ 2020-01-23 14:31 UTC (permalink / raw) To: ltp The prctl() system call takes 5 integer arguments but only 3 of them were passed in the test. This means that the system call read random garbage from stack in place of the two missing arguments and failed even on some perfectly valid combinations of arguments on some platforms. - Fixed arguments in test case 9 (second PR_SET_NO_NEW_PRIVS) - Dropped test case 13 (PR_CAP_AMBIENT) because the args are valid - Dropped test case 14 (PR_GET_SPECULATION_CTRL) because the args are valid - Fixed test call of prctl() to have all 5 arguments Signed-off-by: Martin Doucha <mdoucha@suse.cz> CC: Yang Xu <xuyang2018.jy@cn.fujitsu.com> --- testcases/kernel/syscalls/prctl/prctl02.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c index 93f30b54a..7bf3684e5 100644 --- a/testcases/kernel/syscalls/prctl/prctl02.c +++ b/testcases/kernel/syscalls/prctl/prctl02.c @@ -23,13 +23,9 @@ * arg4, arg5 is non-zero. * 12) prctl() fails with EINVAL when options is PR_GET_THP_DISABLE & arg2, * arg3, arg4, or arg5 is nonzero. - * 13) prctl() fails with EINVAL when options is PR_CAP_AMBIENT & an unused - * argument such as arg4 is nonzero. - * 14) prctl() fails with EINVAL when option is PR_GET_SPECULATION_CTRL and - * unused arguments is nonzero. - * 15) prctl() fails with EPERM when option is PR_SET_SECUREBITS and the + * 13) prctl() fails with EPERM when option is PR_SET_SECUREBITS and the * caller does not have the CAP_SETPCAP capability. - * 16) prctl() fails with EPERM when option is PR_CAPBSET_DROP and the caller + * 14) prctl() fails with EPERM when option is PR_CAPBSET_DROP and the caller * does not have the CAP_SETPCAP capability. */ @@ -87,12 +83,10 @@ static struct tcase { {PR_SET_SECCOMP, &num_2, &strict_addr, EACCES, "PR_SET_SECCOMP"}, {PR_SET_TIMING, &num_1, &num_0, EINVAL, "PR_SET_TIMING"}, {PR_SET_NO_NEW_PRIVS, &num_0, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, - {PR_SET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, + {PR_SET_NO_NEW_PRIVS, &num_1, &num_1, EINVAL, "PR_SET_NO_NEW_PRIVS"}, {PR_GET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_GET_NO_NEW_PRIVS"}, {PR_SET_THP_DISABLE, &num_0, &num_1, EINVAL, "PR_SET_THP_DISABLE"}, {PR_GET_THP_DISABLE, &num_1, &num_1, EINVAL, "PR_GET_THP_DISABLE"}, - {PR_CAP_AMBIENT, &num_2, &num_1, EINVAL, "PR_CAP_AMBIENT"}, - {PR_GET_SPECULATION_CTRL, &num_1, &num_0, EINVAL, "PR_GET_SPECULATION_CTRL"}, {PR_SET_SECUREBITS, &num_0, &num_0, EPERM, "PR_SET_SECUREBITS"}, {PR_CAPBSET_DROP, &num_1, &num_0, EPERM, "PR_CAPBSET_DROP"}, }; @@ -140,7 +134,7 @@ static void verify_prctl(unsigned int n) break; } - TEST(prctl(tc->option, *tc->arg2, *tc->arg3)); + TEST(prctl(tc->option, *tc->arg2, *tc->arg3, 0, 0)); if (TST_RET == 0) { tst_res(TFAIL, "prctl() succeeded unexpectedly"); return; -- 2.24.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH] Fix prctl02 2020-01-23 14:31 [LTP] [PATCH] Fix prctl02 Martin Doucha @ 2020-01-23 14:55 ` Jan Stancek 2020-01-23 15:18 ` [LTP] [PATCH v2] " Martin Doucha 0 siblings, 1 reply; 8+ messages in thread From: Jan Stancek @ 2020-01-23 14:55 UTC (permalink / raw) To: ltp ----- Original Message ----- > The prctl() system call takes 5 integer arguments but only 3 of them were > passed in the test. This means that the system call read random garbage > from stack in place of the two missing arguments and failed even on some > perfectly valid combinations of arguments on some platforms. > > - Fixed arguments in test case 9 (second PR_SET_NO_NEW_PRIVS) > - Dropped test case 13 (PR_CAP_AMBIENT) because the args are valid > - Dropped test case 14 (PR_GET_SPECULATION_CTRL) because the args are valid Can we make them invalid and keep the test cases? For example: PR_CAP_AMBIENT arg2 could be num_invalid PR_GET_SPECULATION_CTRL arg3 could be num_1 The rest looks good to me. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-23 14:55 ` Jan Stancek @ 2020-01-23 15:18 ` Martin Doucha 2020-01-23 23:54 ` Jan Stancek ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Martin Doucha @ 2020-01-23 15:18 UTC (permalink / raw) To: ltp The prctl() system call takes 5 integer arguments but only 3 of them were passed in the test. This means that the system call read random garbage from stack in place of the two missing arguments and failed even on some perfectly valid combinations of arguments on some platforms. - Change num_invalid to ULONG_MAX - Fix arguments in test case 9, 13 and 14 - Fix test call of prctl() to have all 5 arguments Signed-off-by: Martin Doucha <mdoucha@suse.cz> CC: Yang Xu <xuyang2018.jy@cn.fujitsu.com> --- Changes since v1: - Change num_invalid to ULONG_MAX - Return removed test cases and fix them instead testcases/kernel/syscalls/prctl/prctl02.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c index 93f30b54a..ebc0e5060 100644 --- a/testcases/kernel/syscalls/prctl/prctl02.c +++ b/testcases/kernel/syscalls/prctl/prctl02.c @@ -41,6 +41,7 @@ #include <unistd.h> #include <stdlib.h> #include <stddef.h> +#include <limits.h> #include "config.h" #include "lapi/prctl.h" #include "lapi/seccomp.h" @@ -65,7 +66,7 @@ static unsigned long bad_addr; static unsigned long num_0; static unsigned long num_1 = 1; static unsigned long num_2 = 2; -static unsigned long num_invalid = 999; +static unsigned long num_invalid = ULONG_MAX; static int seccomp_nsup; static int nonewprivs_nsup; static int thpdisable_nsup; @@ -87,12 +88,12 @@ static struct tcase { {PR_SET_SECCOMP, &num_2, &strict_addr, EACCES, "PR_SET_SECCOMP"}, {PR_SET_TIMING, &num_1, &num_0, EINVAL, "PR_SET_TIMING"}, {PR_SET_NO_NEW_PRIVS, &num_0, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, - {PR_SET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, + {PR_SET_NO_NEW_PRIVS, &num_1, &num_1, EINVAL, "PR_SET_NO_NEW_PRIVS"}, {PR_GET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_GET_NO_NEW_PRIVS"}, {PR_SET_THP_DISABLE, &num_0, &num_1, EINVAL, "PR_SET_THP_DISABLE"}, {PR_GET_THP_DISABLE, &num_1, &num_1, EINVAL, "PR_GET_THP_DISABLE"}, - {PR_CAP_AMBIENT, &num_2, &num_1, EINVAL, "PR_CAP_AMBIENT"}, - {PR_GET_SPECULATION_CTRL, &num_1, &num_0, EINVAL, "PR_GET_SPECULATION_CTRL"}, + {PR_CAP_AMBIENT, &num_invalid, &num_0, EINVAL, "PR_CAP_AMBIENT"}, + {PR_GET_SPECULATION_CTRL, &num_0, &num_invalid, EINVAL, "PR_GET_SPECULATION_CTRL"}, {PR_SET_SECUREBITS, &num_0, &num_0, EPERM, "PR_SET_SECUREBITS"}, {PR_CAPBSET_DROP, &num_1, &num_0, EPERM, "PR_CAPBSET_DROP"}, }; @@ -140,7 +141,7 @@ static void verify_prctl(unsigned int n) break; } - TEST(prctl(tc->option, *tc->arg2, *tc->arg3)); + TEST(prctl(tc->option, *tc->arg2, *tc->arg3, 0, 0)); if (TST_RET == 0) { tst_res(TFAIL, "prctl() succeeded unexpectedly"); return; -- 2.24.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-23 15:18 ` [LTP] [PATCH v2] " Martin Doucha @ 2020-01-23 23:54 ` Jan Stancek 2020-01-24 11:10 ` Yang Xu 2020-01-24 14:14 ` Cyril Hrubis 2 siblings, 0 replies; 8+ messages in thread From: Jan Stancek @ 2020-01-23 23:54 UTC (permalink / raw) To: ltp ----- Original Message ----- > The prctl() system call takes 5 integer arguments but only 3 of them were > passed in the test. This means that the system call read random garbage > from stack in place of the two missing arguments and failed even on some > perfectly valid combinations of arguments on some platforms. > > - Change num_invalid to ULONG_MAX > - Fix arguments in test case 9, 13 and 14 > - Fix test call of prctl() to have all 5 arguments > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > CC: Yang Xu <xuyang2018.jy@cn.fujitsu.com> Acked-by: Jan Stancek <jstancek@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-23 15:18 ` [LTP] [PATCH v2] " Martin Doucha 2020-01-23 23:54 ` Jan Stancek @ 2020-01-24 11:10 ` Yang Xu 2020-01-24 12:48 ` Cyril Hrubis 2020-01-24 14:14 ` Cyril Hrubis 2 siblings, 1 reply; 8+ messages in thread From: Yang Xu @ 2020-01-24 11:10 UTC (permalink / raw) To: ltp Hi > The prctl() system call takes 5 integer arguments but only 3 of them were > passed in the test. This means that the system call read random garbage > from stack in place of the two missing arguments and failed even on some > perfectly valid combinations of arguments on some platforms. > > - Change num_invalid to ULONG_MAX > - Fix arguments in test case 9, 13 and 14 > - Fix test call of prctl() to have all 5 arguments looks prctl manpages and kernel code, you are right, Thanks for the fix! Feel free to add? Reviewed-by: xuyang_jy_0410@163.com Tested-by: xuyang_jy_0410@163.com Also, do we should use 5 arguments for other prctl test cases? Best Regards Yang Xu > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > CC: Yang Xu <xuyang2018.jy@cn.fujitsu.com> > --- > > Changes since v1: > - Change num_invalid to ULONG_MAX > - Return removed test cases and fix them instead > > testcases/kernel/syscalls/prctl/prctl02.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c > index 93f30b54a..ebc0e5060 100644 > --- a/testcases/kernel/syscalls/prctl/prctl02.c > +++ b/testcases/kernel/syscalls/prctl/prctl02.c > @@ -41,6 +41,7 @@ > #include <unistd.h> > #include <stdlib.h> > #include <stddef.h> > +#include <limits.h> > #include "config.h" > #include "lapi/prctl.h" > #include "lapi/seccomp.h" > @@ -65,7 +66,7 @@ static unsigned long bad_addr; > static unsigned long num_0; > static unsigned long num_1 = 1; > static unsigned long num_2 = 2; > -static unsigned long num_invalid = 999; > +static unsigned long num_invalid = ULONG_MAX; > static int seccomp_nsup; > static int nonewprivs_nsup; > static int thpdisable_nsup; > @@ -87,12 +88,12 @@ static struct tcase { > {PR_SET_SECCOMP, &num_2, &strict_addr, EACCES, "PR_SET_SECCOMP"}, > {PR_SET_TIMING, &num_1, &num_0, EINVAL, "PR_SET_TIMING"}, > {PR_SET_NO_NEW_PRIVS, &num_0, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, > - {PR_SET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_SET_NO_NEW_PRIVS"}, > + {PR_SET_NO_NEW_PRIVS, &num_1, &num_1, EINVAL, "PR_SET_NO_NEW_PRIVS"}, > {PR_GET_NO_NEW_PRIVS, &num_1, &num_0, EINVAL, "PR_GET_NO_NEW_PRIVS"}, > {PR_SET_THP_DISABLE, &num_0, &num_1, EINVAL, "PR_SET_THP_DISABLE"}, > {PR_GET_THP_DISABLE, &num_1, &num_1, EINVAL, "PR_GET_THP_DISABLE"}, > - {PR_CAP_AMBIENT, &num_2, &num_1, EINVAL, "PR_CAP_AMBIENT"}, > - {PR_GET_SPECULATION_CTRL, &num_1, &num_0, EINVAL, "PR_GET_SPECULATION_CTRL"}, > + {PR_CAP_AMBIENT, &num_invalid, &num_0, EINVAL, "PR_CAP_AMBIENT"}, > + {PR_GET_SPECULATION_CTRL, &num_0, &num_invalid, EINVAL, "PR_GET_SPECULATION_CTRL"}, > {PR_SET_SECUREBITS, &num_0, &num_0, EPERM, "PR_SET_SECUREBITS"}, > {PR_CAPBSET_DROP, &num_1, &num_0, EPERM, "PR_CAPBSET_DROP"}, > }; > @@ -140,7 +141,7 @@ static void verify_prctl(unsigned int n) > break; > } > > - TEST(prctl(tc->option, *tc->arg2, *tc->arg3)); > + TEST(prctl(tc->option, *tc->arg2, *tc->arg3, 0, 0)); > if (TST_RET == 0) { > tst_res(TFAIL, "prctl() succeeded unexpectedly"); > return; > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-24 11:10 ` Yang Xu @ 2020-01-24 12:48 ` Cyril Hrubis 2020-01-24 13:06 ` Yang Xu 0 siblings, 1 reply; 8+ messages in thread From: Cyril Hrubis @ 2020-01-24 12:48 UTC (permalink / raw) To: ltp Hi! > > The prctl() system call takes 5 integer arguments but only 3 of them were > > passed in the test. This means that the system call read random garbage > > from stack in place of the two missing arguments and failed even on some > > perfectly valid combinations of arguments on some platforms. > > > > - Change num_invalid to ULONG_MAX > > - Fix arguments in test case 9, 13 and 14 > > - Fix test call of prctl() to have all 5 arguments > looks prctl manpages and kernel code, you are right, Thanks for the fix! > Feel free to add?? > Reviewed-by: xuyang_jy_0410@163.com > Tested-by: xuyang_jy_0410@163.com > > Also, do we should use 5 arguments for other prctl test cases? It depends on the option argument, the PR_CAP_AMBIENT explicitely states that arg4 and arg5 must be set to 0 as well as the PR_GET_SPECULATION_CTRL. Some of the options explicitely say that some arguments are ignored. And some, including PR_SET_NO_NEW_PRIVS does not say anyting. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-24 12:48 ` Cyril Hrubis @ 2020-01-24 13:06 ` Yang Xu 0 siblings, 0 replies; 8+ messages in thread From: Yang Xu @ 2020-01-24 13:06 UTC (permalink / raw) To: ltp Hi! > Hi! >>> The prctl() system call takes 5 integer arguments but only 3 of them were >>> passed in the test. This means that the system call read random garbage >>> from stack in place of the two missing arguments and failed even on some >>> perfectly valid combinations of arguments on some platforms. >>> >>> - Change num_invalid to ULONG_MAX >>> - Fix arguments in test case 9, 13 and 14 >>> - Fix test call of prctl() to have all 5 arguments >> looks prctl manpages and kernel code, you are right, Thanks for the fix! >> Feel free to add?? >> Reviewed-by: xuyang_jy_0410@163.com >> Tested-by: xuyang_jy_0410@163.com >> >> Also, do we should use 5 arguments for other prctl test cases? > > It depends on the option argument, the PR_CAP_AMBIENT explicitely states > that arg4 and arg5 must be set to 0 as well as the > PR_GET_SPECULATION_CTRL. > > Some of the options explicitely say that some arguments are ignored. > > And some, including PR_SET_NO_NEW_PRIVS does not say anyting. Thanks for your answer. I see. > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH v2] Fix prctl02 2020-01-23 15:18 ` [LTP] [PATCH v2] " Martin Doucha 2020-01-23 23:54 ` Jan Stancek 2020-01-24 11:10 ` Yang Xu @ 2020-01-24 14:14 ` Cyril Hrubis 2 siblings, 0 replies; 8+ messages in thread From: Cyril Hrubis @ 2020-01-24 14:14 UTC (permalink / raw) To: ltp Hi! Pushed, thanks. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-01-24 14:14 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-01-23 14:31 [LTP] [PATCH] Fix prctl02 Martin Doucha 2020-01-23 14:55 ` Jan Stancek 2020-01-23 15:18 ` [LTP] [PATCH v2] " Martin Doucha 2020-01-23 23:54 ` Jan Stancek 2020-01-24 11:10 ` Yang Xu 2020-01-24 12:48 ` Cyril Hrubis 2020-01-24 13:06 ` Yang Xu 2020-01-24 14:14 ` Cyril Hrubis
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox