lib: Add SAFE_CHROOT(path) macro
PATCH v3 1/3 lib: Add SAFE_CHROOT(path) macro
--- include/tst_safe_macros.h | 6 +++++- lib/tst_safe_macros.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
include/tst_safe_macros.h +5 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2010-2015 Linux Test Project +* Copyright (c) 2010-2018 Linux Test Project * Copyright (c) 2011-2015 Cyril Hrubis <[email protected]> * * This program is free software: you can redistribute it and/or modify
@@ -48,6 +48,10 @@#define SAFE_CREAT (pathname, mode) \ safe_creat(__FILE__, __LINE__, NULL, (pathname), (mode)) +#define SAFE_CHROOT (path) \ + safe_chroot(__FILE__, __LINE__, (path)) +int safe_chroot (const char *file,const int lineno,const char *path); +#define SAFE_DIRNAME (path) \ safe_dirname(__FILE__, __LINE__, NULL, (path))
lib/tst_safe_macros.c +13 -0
@@ -152,3 +152,16 @@ struct group *safe_getgrnam(const char *file, const int lineno,return rval; } + +int safe_chroot (const char *file,const int lineno,const char *path) +{ +int rval; + + rval =chroot (path); +if (rval ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"chroot(%s) failed" , path); + } + +return rval; +}
Signature · 1 line
2.17.1
PATCH v3 2/3 lib: Introduce TESTPTR()
useful for testing with pointers.
NOTE: variable TST_RET_PTR has new format (TST_*), to confirm gh#336.
--- include/tst_test.h | 9 +++++++++ lib/tst_res.c | 1 + 2 files changed, 10 insertions(+)
include/tst_test.h +9 -0
@@ -195,6 +195,15 @@ void tst_reinit(void);extern long TEST_RETURN ;extern int TEST_ERRNO ; +extern void *TST_RET_PTR ; + +#define TESTPTR (SCALL ) \ + do { \ + errno = 0; \ + TST_RET_PTR = (void*)SCALL; \ + TEST_ERRNO = errno; \ + } while (0) +/* * Functions to convert ERRNO to its name and SIGNAL to its name. */
lib/tst_res.c +1 -0
@@ -55,6 +55,7 @@long TEST_RETURN ;int TEST_ERRNO ; +void *TST_RET_PTR ;#define VERBOSE 1#define NOPASS 3
Signature · 1 line
2.17.1
PATCH v3 3/3 cve/cve-2018-1000001: Add Realpath Buffer Underflow test
In reply to Petr VorelIdea based on glibc source io/tst-getcwd-abspath.c, contributed by Dmitry V. Levin [1]
---
Changes v2->v3:
* Put source into testcases/kernel/syscalls/getcwd/getcwd05.c.
* Put record in several runtest files.
* Minor code simplification.
Kind regards,
Petr
--- runtest/cve | 1 + runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/cve/Makefile | 2 +- testcases/kernel/syscalls/getcwd/.gitignore | 1 + testcases/kernel/syscalls/getcwd/getcwd05.c | 56 +++++++++++++++++++++ 7 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/getcwd/getcwd05.c
runtest/cve +1 -0
@@ -33,3 +33,4 @@ cve-2017-17052 cve-2017-17052 cve-2017-16939 cve-2017-16939 cve-2017-17053 cve-2017-17053 cve-2018-5803 sctp_big_chunk +cve-2018-1000001 getcwd05
runtest/ltplite +1 -0
@@ -281,6 +281,7 @@ getcwd01 getcwd01 getcwd02 getcwd02 getcwd03 getcwd03 getcwd04 getcwd04 +getcwd05 getcwd05 getdents01 getdents01 getdents02 getdents02
runtest/stress.part3 +1 -0
@@ -220,6 +220,7 @@ getcwd01 getcwd01 getcwd02 getcwd02 getcwd03 getcwd03 getcwd04 getcwd04 +getcwd05 getcwd05 getdents01 getdents01 getdents02 getdents02
runtest/syscalls +1 -0
@@ -348,6 +348,7 @@ getcwd01 getcwd01 getcwd02 getcwd02 getcwd03 getcwd03 getcwd04 getcwd04 +getcwd05 getcwd05 getdents01 getdents01 getdents02 getdents02
testcases/cve/Makefile +1 -1
@@ -41,4 +41,4 @@ cve-2017-17053: CFLAGS += -pthread cve-2015-3290: CFLAGS += -pthread -include $(top_srcdir)/include/mk/generic_leaf_target.mk +include $(top_srcdir)/include/mk/generic_trunk_target.mk
testcases/kernel/syscalls/getcwd/.gitignore +1 -0
@@ -2,3 +2,4 @@ /getcwd02 /getcwd03 /getcwd04 +/getcwd05
testcases/kernel/syscalls/getcwd/getcwd05.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 3/3 cve/cve-2018-1000001: Add Realpath Buffer Underflow test
Hi!
testcases/cve/Makefile cve-2017-17053: CFLAGS += -pthread · line 44
Quoted 10 lines
testcases/cve/Makefile +1
-1@@ -41,4 +41,4 @@ cve-2017-17053: CFLAGS += -pthread cve-2015-3290: CFLAGS += -pthread -include $(top_srcdir)/include/mk/generic_leaf_target.mk +include $(top_srcdir)/include/mk/generic_trunk_target.mk
This change is useless now.
Other than that the patchset looks fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 3/3 cve/cve-2018-1000001: Add Realpath Buffer Underflow test
Hi Cyril,
Quoted 6 lines
Quoted 5 lines
testcases/cve/Makefile +0
-0@@ -41,4 +41,4 @@ cve-2017-17053: CFLAGS += -pthread
Quoted 6 lines
testcases/cve/Makefile cve-2017-17053: CFLAGS += -pthread · line 44
Quoted 4 lines
testcases/cve/Makefile +1
-1cve-2015-3290: CFLAGS += -pthread -include $(top_srcdir)/include/mk/generic_leaf_target.mk +include $(top_srcdir)/include/mk/generic_trunk_target.mkThis change is useless now.
Sorry for leaving this. Removed it and pushed, with your ack.
Quoted 1 line
Other than that the patchset looks fine.
Kind regards,
Petr