syscalls/creat: Add "static" in creat01 and creat04
PATCH 1/3 syscalls/creat: Add "static" in creat01 and creat04
--- testcases/kernel/syscalls/creat/creat01.c | 4 ++-- testcases/kernel/syscalls/creat/creat04.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/creat/creat01.c +2 -2
@@ -36,12 +36,12 @@static char filename[40 ];static int fd; -void setup (void ) +static void setup (void ) {sprintf (filename,"creat01.%d" ,getpid ()); } -struct tcase { +static struct tcase {int mode; } tcases[] = { {0644 },
testcases/kernel/syscalls/creat/creat04.c +1 -1
@@ -68,7 +68,7 @@ static void verify_creat(unsigned int i)child_fn (i); } -void setup (void ) +static void setup (void ) {struct passwd *pw;int fd;
Signature · 1 line
2.9.4
PATCH 2/3 syscalls/add_key: Make use of lapi/keyctl.h
--- testcases/kernel/syscalls/add_key/Makefile | 2 ++ testcases/kernel/syscalls/add_key/add_key01.c | 18 ++++-------------- testcases/kernel/syscalls/add_key/add_key02.c | 18 +++++------------- 3 files changed, 11 insertions(+), 27 deletions(-)
testcases/kernel/syscalls/add_key/Makefile +2 -0
@@ -20,4 +20,6 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk +LDLIBS += $(KEYUTILS_LIBS) + include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/add_key/add_key01.c +4 -14
@@ -24,28 +24,18 @@* Manas Kumar Nayak [email protected]> */ -#include "config.h" -#ifdef HAVE_LINUX_KEYCTL_H -# include <linux/keyctl.h> -#endif +#include <errno.h> +#include "tst_test.h" -#include "lapi/syscalls.h" +#include "lapi/keyctl.h" static void verify_add_key (void ) { -#ifdef HAVE_LINUX_KEYCTL_H - -TEST (tst_syscall (__NR_add_key,"keyring" ,"wjkey" ,NULL ,0 , -KEY_SPEC_THREAD_KEYRING )); - +TEST (add_key ("keyring" ,"wjkey" ,NULL ,0 ,KEY_SPEC_THREAD_KEYRING ));if (TEST_RETURN ==-1 )tst_res (TFAIL |TTERRNO ,"add_key call failed" );else tst_res (TPASS ,"add_key call succeeded" ); - -#else -tst_brk (TCONF ,"linux/keyctl.h was missing upon compilation." ); -#endif /* HAVE_LINUX_KEYCTL_H */ }static struct tst_test test = {
testcases/kernel/syscalls/add_key/add_key02.c +5 -13
@@ -32,14 +32,11 @@* than dereferencing NULL. */ -#include "config.h" -#ifdef HAVE_LINUX_KEYCTL_H -# include <linux/keyctl.h> -#endif +#include <errno.h> +#include "tst_test.h" -#include "lapi/syscalls.h" +#include "lapi/keyctl.h" -#ifdef HAVE_LINUX_KEYCTL_Hstruct tcase {const char *type;size_t plen;
@@ -58,13 +55,11 @@ struct tcase { { "user", 64 }, { "logon", 64 }, }; -#endif /* HAVE_LINUX_KEYCTL_H */static void verify_add_key (unsigned int i) { -#ifdef HAVE_LINUX_KEYCTL_H - TEST(tst_syscall(__NR_add_key, tcases[i].type, "abc:def", - NULL, tcases[i].plen, KEY_SPEC_PROCESS_KEYRING)); +TEST (add_key (tcases[i].type, +"abc:def" ,NULL , tcases[i].plen,KEY_SPEC_PROCESS_KEYRING ));if (TEST_RETURN !=-1 ) { tst_res(TFAIL,
@@ -97,9 +92,6 @@ static void verify_add_key(unsigned int i)tst_res (TFAIL |TTERRNO ,"unexpected error with key type '%s'" , tcases[i].type); -#else -tst_brk (TCONF ,"linux/keyctl.h was missing upon compilation." ); -#endif /* HAVE_LINUX_KEYCTL_H */ }static struct tst_test test = {
Signature · 1 line
2.9.4
PATCH 2/3 syscalls/add_key: Make use of lapi/keyctl.h
Hi!
Pushed as well, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 3/3 cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
In reply to Guangwen Feng--- testcases/cve/Makefile | 1 + testcases/cve/cve-2016-7042.c | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-)
testcases/cve/Makefile +1 -0
@@ -17,6 +17,7 @@ top_srcdir ?= ../.. include $(top_srcdir)/include/mk/testcases.mk +LDLIBS += $(KEYUTILS_LIBS) CFLAGS += -D_GNU_SOURCE cve-2016-7117: CFLAGS += -pthread
testcases/cve/cve-2016-7042.c +4 -8
@@ -31,7 +31,6 @@#include <stdio.h> #include "tst_test.h" -#include "lapi/syscalls.h" #include "lapi/keyctl.h" #define PATH_KEYS "/proc/keys"
@@ -43,12 +42,11 @@ static void do_test(void) {char buf[BUFSIZ ]; - key =tst_syscall (__NR_add_key, -"user" ,"ltptestkey" ,"a" ,1 ,KEY_SPEC_SESSION_KEYRING ); + key =add_key ("user" ,"ltptestkey" ,"a" ,1 ,KEY_SPEC_SESSION_KEYRING );if (key ==-1 )tst_brk (TBROK ,"Failed to add key" ); -if (tst_syscall (__NR_keyctl,KEYCTL_UPDATE , key,"b" ,1 )) +if (keyctl (KEYCTL_UPDATE , key,"b" ,1 ))tst_brk (TBROK ,"Failed to update key" ); fd =SAFE_OPEN (PATH_KEYS ,O_RDONLY );
@@ -61,8 +59,7 @@ static void do_test(void)SAFE_CLOSE (fd); -if (tst_syscall (__NR_keyctl,KEYCTL_UNLINK , key, -KEY_SPEC_SESSION_KEYRING )) +if (keyctl (KEYCTL_UNLINK , key,KEY_SPEC_SESSION_KEYRING ))tst_brk (TBROK ,"Failed to unlink key" ); key =0 ; }
@@ -75,8 +72,7 @@ static void setup(void)static void cleanup (void ) { -if (key >0 &&tst_syscall (__NR_keyctl,KEYCTL_UNLINK , key, -KEY_SPEC_SESSION_KEYRING )) +if (key >0 &&keyctl (KEYCTL_UNLINK , key,KEY_SPEC_SESSION_KEYRING ))tst_res (TWARN ,"Failed to unlink key" );if (fd >0 )
Signature · 1 line
2.9.4
PATCH 3/3 cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
Hi!
Quoted 1 line
+LDLIBS += $(KEYUTILS_LIBS)
This should be set only for the particular test and not for all of them, like we do with -lrt and -lutil for the rest of the test.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
--- testcases/cve/Makefile | 2 ++ testcases/cve/cve-2016-7042.c | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-)
testcases/cve/Makefile +2 -0
@@ -19,6 +19,8 @@ include $(top_srcdir)/include/mk/testcases.mk CFLAGS += -D_GNU_SOURCE +cve-2016-7042: LDLIBS += $(KEYUTILS_LIBS) + cve-2016-7117: CFLAGS += -pthread cve-2016-7117: LDLIBS += -lrt
testcases/cve/cve-2016-7042.c +4 -8
@@ -31,7 +31,6 @@#include <stdio.h> #include "tst_test.h" -#include "lapi/syscalls.h" #include "lapi/keyctl.h" #define PATH_KEYS "/proc/keys"
@@ -43,12 +42,11 @@ static void do_test(void) {char buf[BUFSIZ ]; - key =tst_syscall (__NR_add_key, -"user" ,"ltptestkey" ,"a" ,1 ,KEY_SPEC_SESSION_KEYRING ); + key =add_key ("user" ,"ltptestkey" ,"a" ,1 ,KEY_SPEC_SESSION_KEYRING );if (key ==-1 )tst_brk (TBROK ,"Failed to add key" ); -if (tst_syscall (__NR_keyctl,KEYCTL_UPDATE , key,"b" ,1 )) +if (keyctl (KEYCTL_UPDATE , key,"b" ,1 ))tst_brk (TBROK ,"Failed to update key" ); fd =SAFE_OPEN (PATH_KEYS ,O_RDONLY );
@@ -61,8 +59,7 @@ static void do_test(void)SAFE_CLOSE (fd); -if (tst_syscall (__NR_keyctl,KEYCTL_UNLINK , key, -KEY_SPEC_SESSION_KEYRING )) +if (keyctl (KEYCTL_UNLINK , key,KEY_SPEC_SESSION_KEYRING ))tst_brk (TBROK ,"Failed to unlink key" ); key =0 ; }
@@ -75,8 +72,7 @@ static void setup(void)static void cleanup (void ) { -if (key >0 &&tst_syscall (__NR_keyctl,KEYCTL_UNLINK , key, -KEY_SPEC_SESSION_KEYRING )) +if (key >0 &&keyctl (KEYCTL_UNLINK , key,KEY_SPEC_SESSION_KEYRING ))tst_res (TWARN ,"Failed to unlink key" );if (fd >0 )
Signature · 1 line
2.9.4
PATCH v2 1/1 cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/3 syscalls/creat: Add "static" in creat01 and creat04
In reply to Guangwen FengHi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]