factory
cover factory
Wei Gao (2):
seccomp01.c: Add SECCOMP_RET_USER_NOTIF check
d
configure.ac | 1 + include/lapi/seccomp.h | 7 + runtest/syscalls | 2 + testcases/kernel/syscalls/ptrace/ptrace05.c | 147 ++---- testcases/kernel/syscalls/ptrace/ptrace06.c | 306 +++++++----- testcases/kernel/syscalls/seccomp/.gitignore | 1 + testcases/kernel/syscalls/seccomp/Makefile | 8 + testcases/kernel/syscalls/seccomp/seccomp01.c | 456 ++++++++++++++++++ 8 files changed, 689 insertions(+), 239 deletions(-) create mode 100644 testcases/kernel/syscalls/seccomp/.gitignore create mode 100644 testcases/kernel/syscalls/seccomp/Makefile create mode 100644 testcases/kernel/syscalls/seccomp/seccomp01.c
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/2 seccomp01.c: Add SECCOMP_RET_USER_NOTIF check
This case will report EINVAL error when execute SAFE_IOCTL(notifyFd, SECCOMP_IOCTL_NOTIF_RECV, req) such as 5.6.19, so i put current case's .min_kver = "5.7.19"
NOTE: If your old kernel compile env is ubuntu 22.04 LTS, better use old gcc-8 and also apply patch base following link:
https://www.spinics.net/lists/kernel/msg3797871.html
--- configure.ac | 1 + include/lapi/seccomp.h | 7 + runtest/syscalls | 2 + testcases/kernel/syscalls/seccomp/.gitignore | 1 + testcases/kernel/syscalls/seccomp/Makefile | 8 + testcases/kernel/syscalls/seccomp/seccomp01.c | 456 ++++++++++++++++++ 6 files changed, 475 insertions(+) create mode 100644 testcases/kernel/syscalls/seccomp/.gitignore create mode 100644 testcases/kernel/syscalls/seccomp/Makefile create mode 100644 testcases/kernel/syscalls/seccomp/seccomp01.c
configure.ac +1 -0
@@ -138,6 +138,7 @@ AC_CHECK_FUNCS_ONCE([ \ renameat \ renameat2 \ sched_getcpu \ + seccomp \ sendmmsg \ sethostid \ setns \
include/lapi/seccomp.h +7 -0
@@ -37,4 +37,11 @@ struct seccomp_data { };#endif /* HAVE_LINUX_SECCOMP_H*/ + +# ifndef HAVE_SECCOMP +int seccomp (unsigned int operation,unsigned int flags,void *args) +{ +return syscall (__NR_seccomp, operation, flags, args); +} +# endif /* HAVE_SECCOMP */ #endif /* LAPI_SECCOMP_H__ */
runtest/syscalls +2 -0
@@ -1242,6 +1242,8 @@ select02 select02 select03 select03 select04 select04 +seccomp01 seccomp01 + semctl01 semctl01 semctl02 semctl02 semctl03 semctl03
testcases/kernel/syscalls/seccomp/.gitignore new file +1 -0
@@ -0,0 +1 @@ +seccomp01
testcases/kernel/syscalls/seccomp/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2023 Wei Gao <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/seccomp/seccomp01.c new file +456 -0
456 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v1 1/2] seccomp01.c: Add SECCOMP_RET_USER_NOTIF check
Sorry for the garbage email, please SKIP this email.
-----Original Message-----
From: Wei Gao <[email protected]>
Sent: Monday, September 25, 2023 7:04 PM
To: Wei Gao <[email protected]>; [email protected]
Subject: [PATCH v1 1/2] seccomp01.c: Add SECCOMP_RET_USER_NOTIF check
This case will report EINVAL error when execute SAFE_IOCTL(notifyFd, SECCOMP_IOCTL_NOTIF_RECV, req) such as 5.6.19, so i put current case's .min_kver = "5.7.19"
NOTE: If your old kernel compile env is ubuntu 22.04 LTS, better use old gcc-8 and also apply patch base following link:
https://www.spinics.net/lists/kernel/msg3797871.html
--- configure.ac | 1 + include/lapi/seccomp.h | 7 + runtest/syscalls | 2 + testcases/kernel/syscalls/seccomp/.gitignore | 1 + testcases/kernel/syscalls/seccomp/Makefile | 8 + testcases/kernel/syscalls/seccomp/seccomp01.c | 456 ++++++++++++++++++ 6 files changed, 475 insertions(+) create mode 100644 testcases/kernel/syscalls/seccomp/.gitignore create mode 100644 testcases/kernel/syscalls/seccomp/Makefile create mode 100644 testcases/kernel/syscalls/seccomp/seccomp01.c
configure.ac +1 -0
@@ -138,6 +138,7 @@ AC_CHECK_FUNCS_ONCE([ \ renameat \ renameat2 \ sched_getcpu \ + seccomp \ sendmmsg \ sethostid \ setns \
include/lapi/seccomp.h +5 -0
@@ -37,4 +37,11 @@ struct seccomp_data { };#endif /* HAVE_LINUX_SECCOMP_H*/ + +# ifndef HAVE_SECCOMP +int seccomp (unsigned int operation,unsigned int flags,void *args) { +return syscall (__NR_seccomp, operation, flags, args); }# endif /* +HAVE_SECCOMP */ #endif /* LAPI_SECCOMP_H__ */
runtest/syscalls +2 -0
@@ -1242,6 +1242,8 @@ select02 select02 select03 select03 select04 select04 +seccomp01 seccomp01 + semctl01 semctl01 semctl02 semctl02 semctl03 semctl03
testcases/kernel/syscalls/seccomp/.gitignore new file +1 -0
@@ -0,0 +1 @@ +seccomp01
testcases/kernel/syscalls/seccomp/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2023 Wei Gao +<[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/seccomp/seccomp01.c new file +453 -0
453 lines not on this page · raw message
--
2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 d
In reply to Wei Gao via ltp--- testcases/kernel/syscalls/ptrace/ptrace05.c | 147 +++------- testcases/kernel/syscalls/ptrace/ptrace06.c | 306 +++++++++++--------- 2 files changed, 214 insertions(+), 239 deletions(-)
testcases/kernel/syscalls/ptrace/ptrace05.c +39 -108
@@ -1,122 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-only /* -****************************************************************************** -* -* ptrace05 - an app which ptraces itself as per arbitrarily specified signals, -* over a user specified range. -* -* Copyright (C) 2009, Ngie Cooper -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. +* Copyright (C) 2009, Ngie Cooper +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] * -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* ptrace05 - an app which ptraces itself as per arbitrarily specified signals * -****************************************************************************** */ -#include <sys/types.h> -#include <sys/wait.h> -#include <signal.h> -#include <errno.h> -#include <libgen.h> -#include <math.h> #include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <config.h> #include "ptrace.h" -#include "test.h" #include "lapi/signal.h" +#include "tst_test.h" -char *TCID ="ptrace05" ; -int TST_TOTAL =0 ; - -int usage (const char *); - -int usage (const char *argv0) -{ -fprintf (stderr,"usage: %s [start-signum] [end-signum]\n" , argv0); -return 1 ; -} - -int main (int argc,char **argv) +static void run (void ) { -int end_signum =-1 ; -int signum; -int start_signum =-1 ; +int end_signum =SIGRTMAX ; +int signum =0 ; +int start_signum =0 ;int status;pid_t child; -tst_parse_opts (argc, argv,NULL ,NULL ); - -if (start_signum ==-1 ) { - start_signum =0 ; - } -if (end_signum ==-1 ) { - end_signum =SIGRTMAX ; - } -for (signum = start_signum; signum <= end_signum; signum++) { -if (signum >= __SIGRTMIN && signum <SIGRTMIN ) -continue ; - -switch (child =fork ()) { +switch (child =SAFE_FORK ()) {case -1 : -tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" ); +tst_brk (TBROK |TERRNO ,"fork() failed" );case 0 : -if (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL ) !=-1 ) { -tst_resm (TINFO ,"[child] Sending kill(.., %d)" , - signum); -if (kill (getpid (), signum) <0 ) { -tst_resm (TINFO |TERRNO , -"[child] kill(.., %d) failed." , - signum); - } +TEST (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL )); +if (TST_RET !=-1 ) { +tst_res (TINFO ,"[child] Sending kill(.., %d)" , + signum); +SAFE_KILL (getpid (), signum); }else { - -/* -* This won't increment the TST_COUNT var. -* properly, but it'll show up as a failure -* nonetheless. -*/ -tst_resm (TFAIL |TERRNO , +tst_brk (TFAIL |TERRNO ,"Failed to ptrace(PTRACE_TRACEME, ...) " "properly" ); - } -/* Shouldn't get here if signum == 0. */ -exit ((signum ==0 ?0 :2 )); + +exit (0 );break ;default : -waitpid (child, &status,0 ); +SAFE_WAITPID (child, &status,0 );switch (signum) {case 0 :if (WIFEXITED (status) &&WEXITSTATUS (status) ==0 ) { -tst_resm (TPASS , +tst_res (TPASS ,"kill(.., 0) exited " "with 0, as expected." ); }else { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"kill(.., 0) didn't exit " "with 0." ); }
@@ -125,20 +70,20 @@ int main(int argc, char **argv)if (WIFSIGNALED (status)) {/* SIGKILL must be uncatchable. */ if (WTERMSIG (status) ==SIGKILL ) { -tst_resm (TPASS , +tst_res (TPASS ,"Killed with SIGKILL, " "as expected." ); }else { -tst_resm (TPASS , +tst_brk (TFAIL |TERRNO ,"Didn't die with " "SIGKILL (?!) " ); } }else if (WIFEXITED (status)) { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"Exited unexpectedly instead " "of dying with SIGKILL." ); }else if (WIFSTOPPED (status)) { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"Stopped instead of dying " "with SIGKILL." ); }
@@ -146,35 +91,21 @@ int main(int argc, char **argv)/* All other processes should be stopped. */ default :if (WIFSTOPPED (status)) { -tst_resm (TPASS ,"Stopped as expected" ); +tst_res (TPASS ,"Stopped as expected" ); }else { -tst_resm (TFAIL ,"Didn't stop as " +tst_brk (TFAIL |TERRNO ,"Didn't stop as " "expected." ); -if (kill (child,0 )) { -tst_resm (TINFO , -"Is still alive!?" ); - }else if (WIFEXITED (status)) { -tst_resm (TINFO , -"Exited normally" ); - }else if (WIFSIGNALED (status)) { -tst_resm (TINFO , -"Was signaled with " -"signum=%d" , -WTERMSIG (status)); - } - } -break ; - } - } -/* Make sure the child dies a quick and painless death ... */ -kill (child,9 ); +if (signum !=0 && signum !=9 ) +SAFE_PTRACE (PTRACE_CONT , child,NULL ,NULL ); } - -tst_exit (); - } + +static struct tst_test test = { + .test_all = run, + .forks_child =1 , +};
testcases/kernel/syscalls/ptrace/ptrace06.c +175 -131
375 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v1 2/2] d
Sorry for the garbage email, please SKIP this email.
-----Original Message-----
From: Wei Gao <[email protected]>
Sent: Monday, September 25, 2023 7:04 PM
To: Wei Gao <[email protected]>; [email protected]
Subject: [PATCH v1 2/2] d
--- testcases/kernel/syscalls/ptrace/ptrace05.c | 147 +++------- testcases/kernel/syscalls/ptrace/ptrace06.c | 306 +++++++++++--------- 2 files changed, 214 insertions(+), 239 deletions(-)
testcases/kernel/syscalls/ptrace/ptrace05.c +39 -108
@@ -1,122 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-only /* -****************************************************************************** -* -* ptrace05 - an app which ptraces itself as per arbitrarily specified signals, -* over a user specified range. -* -* Copyright (C) 2009, Ngie Cooper -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. +* Copyright (C) 2009, Ngie Cooper +* Copyright (c) 2023 Wei Gao <[email protected]> */ + +/*\ +* [Description] * -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* ptrace05 - an app which ptraces itself as per arbitrarily specified +signals * -****************************************************************************** */ -#include <sys/types.h> -#include <sys/wait.h> -#include <signal.h> -#include <errno.h> -#include <libgen.h> -#include <math.h> #include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <config.h> #include "ptrace.h" -#include "test.h" #include "lapi/signal.h" +#include "tst_test.h" -char *TCID ="ptrace05" ; -int TST_TOTAL =0 ; - -int usage (const char *); - -int usage (const char *argv0) -{ -fprintf (stderr,"usage: %s [start-signum] [end-signum]\n" , argv0); -return 1 ; -} - -int main (int argc,char **argv) +static void run (void ) { -int end_signum =-1 ; -int signum; -int start_signum =-1 ; +int end_signum =SIGRTMAX ; +int signum =0 ; +int start_signum =0 ;int status;pid_t child; -tst_parse_opts (argc, argv,NULL ,NULL ); - -if (start_signum ==-1 ) { - start_signum =0 ; - } -if (end_signum ==-1 ) { - end_signum =SIGRTMAX ; - } -for (signum = start_signum; signum <= end_signum; signum++) { -if (signum >= __SIGRTMIN && signum <SIGRTMIN ) -continue ; - -switch (child =fork ()) { +switch (child =SAFE_FORK ()) {case -1 : -tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" ); +tst_brk (TBROK |TERRNO ,"fork() failed" );case 0 : -if (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL ) !=-1 ) { -tst_resm (TINFO ,"[child] Sending kill(.., %d)" , - signum); -if (kill (getpid (), signum) <0 ) { -tst_resm (TINFO |TERRNO , -"[child] kill(.., %d) failed." , - signum); - } +TEST (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL )); +if (TST_RET !=-1 ) { +tst_res (TINFO ,"[child] Sending kill(.., %d)" , + signum); +SAFE_KILL (getpid (), signum); }else { - -/* -* This won't increment the TST_COUNT var. -* properly, but it'll show up as a failure -* nonetheless. -*/ -tst_resm (TFAIL |TERRNO , +tst_brk (TFAIL |TERRNO ,"Failed to ptrace(PTRACE_TRACEME, ...) " "properly" ); - } -/* Shouldn't get here if signum == 0. */ -exit ((signum ==0 ?0 :2 )); + +exit (0 );break ;default : -waitpid (child, &status,0 ); +SAFE_WAITPID (child, &status,0 );switch (signum) {case 0 :if (WIFEXITED (status) &&WEXITSTATUS (status) ==0 ) { -tst_resm (TPASS , +tst_res (TPASS ,"kill(.., 0) exited " "with 0, as expected." ); }else { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"kill(.., 0) didn't exit " "with 0." ); }
@@ -125,20 +70,20 @@ int main(int argc, char **argv)if (WIFSIGNALED (status)) {/* SIGKILL must be uncatchable. */ if (WTERMSIG (status) ==SIGKILL ) { -tst_resm (TPASS , +tst_res (TPASS ,"Killed with SIGKILL, " "as expected." ); }else { -tst_resm (TPASS , +tst_brk (TFAIL |TERRNO ,"Didn't die with " "SIGKILL (?!) " ); } }else if (WIFEXITED (status)) { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"Exited unexpectedly instead " "of dying with SIGKILL." ); }else if (WIFSTOPPED (status)) { -tst_resm (TFAIL , +tst_brk (TFAIL |TERRNO ,"Stopped instead of dying " "with SIGKILL." ); }
@@ -146,35 +91,21 @@ int main(int argc, char **argv)/* All other processes should be stopped. */ default :if (WIFSTOPPED (status)) { -tst_resm (TPASS ,"Stopped as expected" ); +tst_res (TPASS ,"Stopped as expected" ); }else { -tst_resm (TFAIL ,"Didn't stop as " +tst_brk (TFAIL |TERRNO ,"Didn't stop as " "expected." ); -if (kill (child,0 )) { -tst_resm (TINFO , -"Is still alive!?" ); - }else if (WIFEXITED (status)) { -tst_resm (TINFO , -"Exited normally" ); - }else if (WIFSIGNALED (status)) { -tst_resm (TINFO , -"Was signaled with " -"signum=%d" , -WTERMSIG (status)); - } - } -break ; - } - } -/* Make sure the child dies a quick and painless death ... */ -kill (child,9 ); +if (signum !=0 && signum !=9 ) +SAFE_PTRACE (PTRACE_CONT , child,NULL ,NULL ); } - -tst_exit (); - } + +static struct tst_test test = { + .test_all = run, + .forks_child =1 , +};
testcases/kernel/syscalls/ptrace/ptrace06.c +173 -131
373 lines not on this page · raw message
--
2.35.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Wei Gao
Wei Gao (2):
seccomp01.c: AddSECCOMP_RET_USER_NOTIFcheck
d
Quoted 16 lines
configure.ac | 1 + include/lapi/seccomp.h | 7 + runtest/syscalls | 2 + testcases/kernel/syscalls/ptrace/ptrace05.c | 147 ++---- testcases/kernel/syscalls/ptrace/ptrace06.c | 306 +++++++----- testcases/kernel/syscalls/seccomp/.gitignore | 1 + testcases/kernel/syscalls/seccomp/Makefile | 8 + testcases/kernel/syscalls/seccomp/seccomp01.c | 456 ++++++++++++++++++ 8 files changed, 689 insertions(+), 239 deletions(-) create mode 100644 testcases/kernel/syscalls/seccomp/.gitignore create mode 100644 testcases/kernel/syscalls/seccomp/Makefile create mode 100644 testcases/kernel/syscalls/seccomp/seccomp01.cSignature · 1 line
2.35.3
Sorry for the garbage email, please skip this serial email
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp