public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04
@ 2017-09-06  9:56 Guangwen Feng
  2017-09-06  9:56 ` [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h Guangwen Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Guangwen Feng @ 2017-09-06  9:56 UTC (permalink / raw)
  To: ltp

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/creat/creat01.c | 4 ++--
 testcases/kernel/syscalls/creat/creat04.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/creat/creat01.c b/testcases/kernel/syscalls/creat/creat01.c
index 571c771..6b70be2 100644
--- a/testcases/kernel/syscalls/creat/creat01.c
+++ b/testcases/kernel/syscalls/creat/creat01.c
@@ -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},
diff --git a/testcases/kernel/syscalls/creat/creat04.c b/testcases/kernel/syscalls/creat/creat04.c
index c973108..ebcaa17 100644
--- a/testcases/kernel/syscalls/creat/creat04.c
+++ b/testcases/kernel/syscalls/creat/creat04.c
@@ -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;
-- 
2.9.4




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

* [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h
  2017-09-06  9:56 [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Guangwen Feng
@ 2017-09-06  9:56 ` Guangwen Feng
  2017-09-06 12:28   ` Cyril Hrubis
  2017-09-06  9:56 ` [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h Guangwen Feng
  2017-09-06 12:22 ` [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Cyril Hrubis
  2 siblings, 1 reply; 8+ messages in thread
From: Guangwen Feng @ 2017-09-06  9:56 UTC (permalink / raw)
  To: ltp

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 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(-)

diff --git a/testcases/kernel/syscalls/add_key/Makefile b/testcases/kernel/syscalls/add_key/Makefile
index 2ef86f0..c3e9ac1 100644
--- a/testcases/kernel/syscalls/add_key/Makefile
+++ b/testcases/kernel/syscalls/add_key/Makefile
@@ -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
diff --git a/testcases/kernel/syscalls/add_key/add_key01.c b/testcases/kernel/syscalls/add_key/add_key01.c
index ac561d7..6756702 100644
--- a/testcases/kernel/syscalls/add_key/add_key01.c
+++ b/testcases/kernel/syscalls/add_key/add_key01.c
@@ -24,28 +24,18 @@
  *	      Manas Kumar Nayak maknayak@in.ibm.com>
  */
 
-#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 = {
diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c
index a742824..ce46730 100644
--- a/testcases/kernel/syscalls/add_key/add_key02.c
+++ b/testcases/kernel/syscalls/add_key/add_key02.c
@@ -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_H
 struct 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 = {
-- 
2.9.4




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

* [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
  2017-09-06  9:56 [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Guangwen Feng
  2017-09-06  9:56 ` [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h Guangwen Feng
@ 2017-09-06  9:56 ` Guangwen Feng
  2017-09-06 12:29   ` Cyril Hrubis
  2017-09-06 12:22 ` [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Cyril Hrubis
  2 siblings, 1 reply; 8+ messages in thread
From: Guangwen Feng @ 2017-09-06  9:56 UTC (permalink / raw)
  To: ltp

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 testcases/cve/Makefile        |  1 +
 testcases/cve/cve-2016-7042.c | 12 ++++--------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile
index 04abc1f..db87299 100644
--- a/testcases/cve/Makefile
+++ b/testcases/cve/Makefile
@@ -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
diff --git a/testcases/cve/cve-2016-7042.c b/testcases/cve/cve-2016-7042.c
index ff9c057..8719eba 100644
--- a/testcases/cve/cve-2016-7042.c
+++ b/testcases/cve/cve-2016-7042.c
@@ -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)
-- 
2.9.4




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

* [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04
  2017-09-06  9:56 [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Guangwen Feng
  2017-09-06  9:56 ` [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h Guangwen Feng
  2017-09-06  9:56 ` [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h Guangwen Feng
@ 2017-09-06 12:22 ` Cyril Hrubis
  2 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-06 12:22 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h
  2017-09-06  9:56 ` [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h Guangwen Feng
@ 2017-09-06 12:28   ` Cyril Hrubis
  0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-06 12:28 UTC (permalink / raw)
  To: ltp

Hi!
Pushed as well, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
  2017-09-06  9:56 ` [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h Guangwen Feng
@ 2017-09-06 12:29   ` Cyril Hrubis
  2017-09-07  2:11     ` [LTP] [PATCH v2] " Guangwen Feng
  0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-06 12:29 UTC (permalink / raw)
  To: ltp

Hi!
> +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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
  2017-09-06 12:29   ` Cyril Hrubis
@ 2017-09-07  2:11     ` Guangwen Feng
  2017-09-07 10:11       ` Cyril Hrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Guangwen Feng @ 2017-09-07  2:11 UTC (permalink / raw)
  To: ltp

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 testcases/cve/Makefile        |  2 ++
 testcases/cve/cve-2016-7042.c | 12 ++++--------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile
index 04abc1f..0905fd9 100644
--- a/testcases/cve/Makefile
+++ b/testcases/cve/Makefile
@@ -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
 
diff --git a/testcases/cve/cve-2016-7042.c b/testcases/cve/cve-2016-7042.c
index ff9c057..8719eba 100644
--- a/testcases/cve/cve-2016-7042.c
+++ b/testcases/cve/cve-2016-7042.c
@@ -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)
-- 
2.9.4




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

* [LTP] [PATCH v2] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h
  2017-09-07  2:11     ` [LTP] [PATCH v2] " Guangwen Feng
@ 2017-09-07 10:11       ` Cyril Hrubis
  0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-07 10:11 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:[~2017-09-07 10:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06  9:56 [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Guangwen Feng
2017-09-06  9:56 ` [LTP] [PATCH 2/3] syscalls/add_key: Make use of lapi/keyctl.h Guangwen Feng
2017-09-06 12:28   ` Cyril Hrubis
2017-09-06  9:56 ` [LTP] [PATCH 3/3] cve/cve-2016-7042: Make use of the fallback functions in lapi/keyctl.h Guangwen Feng
2017-09-06 12:29   ` Cyril Hrubis
2017-09-07  2:11     ` [LTP] [PATCH v2] " Guangwen Feng
2017-09-07 10:11       ` Cyril Hrubis
2017-09-06 12:22 ` [LTP] [PATCH 1/3] syscalls/creat: Add "static" in creat01 and creat04 Cyril Hrubis

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