Add SAFE_TIMER_*() functions to tst_safe_clocks.h
PATCH v2 1/2 Add SAFE_TIMER_*() functions to tst_safe_clocks.h
Signed-off-by Martin Doucha <[email protected]>
---
Changes since v1: None
include/tst_safe_clocks.h | 90 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
include/tst_safe_clocks.h +90 -0
@@ -55,6 +55,83 @@ static inline void safe_clock_settime(const char *file, const int lineno, } } +static inline int safe_timer_create (const char *file,const int lineno, +clockid_t clockid,struct sigevent *sevp,timer_t *timerid) +{ +int ret; + + errno =0 ; + ret =timer_create (clockid, sevp, timerid); + +if (ret ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"timer_create(%s) failed" ,tst_clock_name (clockid)); + }else if (ret) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid timer_create(%s) return value %d" , +tst_clock_name (clockid), ret); + } + +return ret; +} + +static inline int safe_timer_settime (const char *file,const int lineno, +timer_t timerid,int flags,const struct itimerspec *new_value, +struct itimerspec *old_value) +{ +int ret; + + errno =0 ; + ret =timer_settime (timerid, flags, new_value, old_value); + +if (ret ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"timer_settime() failed" ); + }else if (ret) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid timer_settime() return value %d" , ret); + } + +return ret; +} + +static inline int safe_timer_gettime (const char *file,const int lineno, +timer_t timerid,struct itimerspec *curr_value) +{ +int ret; + + errno =0 ; + ret =timer_gettime (timerid, curr_value); + +if (ret ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"timer_gettime() failed" ); + }else if (ret) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid timer_gettime() return value %d" , ret); + } + +return ret; +} + +static inline int safe_timer_delete (const char *file,const int lineno, +timer_t timerid) +{ +int ret; + + errno =0 ; + ret =timer_delete (timerid); + +if (ret ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO ,"timer_delete() failed" ); + }else if (ret) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid timer_delete() return value %d" , ret); + } + +return ret; +} +#define SAFE_CLOCK_GETRES (clk_id, res)\ safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))
@@ -64,4 +141,17 @@ static inline void safe_clock_settime(const char *file, const int lineno,#define SAFE_CLOCK_SETTIME (clk_id, tp)\ safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp)) +#define SAFE_TIMER_CREATE (clockid, sevp, timerid)\ + safe_timer_create(__FILE__, __LINE__, (clockid), (sevp), (timerid)) + +#define SAFE_TIMER_SETTIME (timerid, flags, new_value, old_value)\ + safe_timer_settime(__FILE__, __LINE__, (timerid), (flags),\ + (new_value), (old_value)) + +#define SAFE_TIMER_GETTIME (timerid, curr_value)\ + safe_timer_gettime(__FILE__, __LINE__, (timerid), (curr_value)) + +#define SAFE_TIMER_DELETE (timerid)\ + safe_timer_delete(__FILE__, __LINE__, timerid) +#endif /* SAFE_CLOCKS_H__ */
Signature · 1 line
2.28.0
PATCH v2 2/2 Add test for CVE 2018-12896
Fixes #353
Signed-off-by Martin Doucha <[email protected]>
---
Changes since v1:
- Fix running the test with -i parameter
- Move checks out of signal handler to make it async safe
runtest/cve | 1 + runtest/syscalls | 1 + .../kernel/syscalls/timer_settime/.gitignore | 1 + .../syscalls/timer_settime/timer_settime03.c | 123 ++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 testcases/kernel/syscalls/timer_settime/timer_settime03.c
runtest/cve +1 -0
@@ -52,6 +52,7 @@ cve-2018-9568 connect02 cve-2018-1000001 realpath01 cve-2018-1000199 ptrace08 cve-2018-1000204 ioctl_sg01 +cve-2018-12896 timer_settime03 cve-2018-18445 bpf_prog04 cve-2018-18559 bind06 cve-2018-19854 crypto_user01
runtest/syscalls +1 -0
@@ -1543,6 +1543,7 @@ timer_gettime01 timer_gettime01 timer_settime01 timer_settime01 timer_settime02 timer_settime02 +timer_settime03 timer_settime03 tkill01 tkill01 tkill02 tkill02
testcases/kernel/syscalls/timer_settime/.gitignore +1 -0
@@ -1,2 +1,3 @@ /timer_settime01 /timer_settime02 +/timer_settime03
testcases/kernel/syscalls/timer_settime/timer_settime03.c new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH v2 2/2 Add test for CVE 2018-12896
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]