Add test for CVE 2017-10661
PATCH v2 1/1 Add test for CVE 2017-10661
---
Sorry about the tmp expression in v1, the comma at the end was a typo.
Changes since v1:
- typo fixes
- code style fixes
- move test from cve/ to kernel/syscall/timerfd/
- add test to cve runfile
runtest/cve | 1 + testcases/kernel/syscalls/timerfd/Makefile | 3 +- .../syscalls/timerfd/timerfd_settime02.c | 110 ++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/timerfd/timerfd_settime02.c
runtest/cve +1 -0
@@ -19,6 +19,7 @@ cve-2017-2671 cve-2017-2671 cve-2017-6951 request_key05 cve-2017-7308 setsockopt02 cve-2017-7472 keyctl04 +cve-2017-10661 timerfd_settime02 cve-2017-12192 keyctl07 cve-2017-12193 add_key04 cve-2017-15274 add_key02
testcases/kernel/syscalls/timerfd/Makefile +2 -1
@@ -20,6 +20,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrt include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/timerfd/timerfd_settime02.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v2 1/1 Add test for CVE 2017-10661
Hi Martin,
Quoted 1 line
Signed-off-by Martin Doucha <[email protected]>
Quoted 5 lines
Changes since v1:
- typo fixes
- code style fixes
- move test from cve/ tokernel/syscall/timerfd/
- add test to cve runfile
Thanks for fixing all Richie's comments.
testcases/kernel/syscalls/timerfd/Makefile top_srcdir ?= ../../../.. · line 24
Quoted 8 lines
+++ b/testcases/kernel/syscalls/timerfd/Makefile
testcases/kernel/syscalls/timerfd/Makefile +2
-1@@ -20,6 +20,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrt
Interesting, I thought -pthread wouldn't be needed to be in LDLIBS (enough to have it in CFLAGS), but old distros (CentOS 6 in our travis: gcc 4.4.7, glibc 2.12).
...
Quoted 1 line
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +0
-0
...
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 38
Quoted 6 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +6
-0+static void setup (void ) +{ +int ttype; + +tst_taint_init (TST_TAINT_W |TST_TAINT_D ); + errno =0 ;
I guess reset errno shouldn't be needed, but sure it's safe.
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 44
Quoted 6 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +6
-0+ fd =timerfd_create (CLOCK_REALTIME ,0 ); + +if (fd <0 ) { + ttype = (errno ==ENOTSUP ?TCONF :TBROK ); +tst_brk (ttype |TERRNO ,"Cannot create timer" ); + }
It looks like we'd benefit from SAFE_TIMERFD_CREATE().
+ I like you take care about ENOTSUP.
...
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 81
Quoted 9 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +9
-0+static void run (void ) +{ +tst_fzsync_pair_reset (&fzsync_pair, thread_run); + +while (tst_fzsync_run_a (&fzsync_pair)) { +TEST (punch_clock (TFD_TIMER_ABSTIME |TFD_TIMER_CANCEL_ON_SET )); + +if (TST_RET ==-1 ) +tst_res (TBROK |TTERRNO ,TIMERFD_FLAGS " failed" );
Now this needs to be tst_res(TFAIL (person who merges this will do).
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 85
Quoted 4 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +4
-0+ +if (TST_RET !=0 ) +tst_res (TBROK |TTERRNO ,"Invalid " TIMERFD_FLAGS +" return value" );
The same here.
Kind regards,
Petr
PATCH v2 1/1 Add test for CVE 2017-10661
Quoted 15 lines
Hi Martin,
Quoted 1 line
Signed-off-by Martin Doucha <[email protected]>Reviewed-by Petr Vorel <[email protected]>Quoted 5 lines
Changes since v1:
- typo fixes
- code style fixes
- move test from cve/ tokernel/syscall/timerfd/
- add test to cve runfileThanks for fixing all Richie's comments.
Quoted 2 lines
+++ b/testcases/kernel/syscalls/timerfd/Makefile
(quoted diff) +0
-0@@ -20,6 +20,7 @@ top_srcdir ?= ../../../..
Quoted 8 lines
testcases/kernel/syscalls/timerfd/Makefile top_srcdir ?= ../../../.. · line 24
Quoted 5 lines
testcases/kernel/syscalls/timerfd/Makefile +2
-1include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrtInteresting, I thought -pthread wouldn't be needed to be in LDLIBS (enough to have it in CFLAGS), but old distros (CentOS 6 in our travis: gcc 4.4.7, glibc 2.12).
OK: it can be just this:timerfd_settime02: CFLAGS += -pthreadtimerfd_settime02: LDLIBS += -lrt
because failure in CentOS 6 is different:
timerfd01.c:36: undefined reference to `clock_gettime'
https://api.travis-ci.org/v3/job/657694167/log.txt
Obviously we need autotools check for it (trivial, I can do it before merge).
Kind regards,
Petr
PATCH v2 1/1 Add test for CVE 2017-10661
Quoted 5 lines · Petr Vorel
because failure in CentOS 6 is different:
timerfd01.c:36: undefined reference to `clock_gettime'
https://api.travis-ci.org/v3/job/657694167/log.txtObviously we need autotools check for it (trivial, I can do it before merge).
Note that this is a compile error in completely different test program.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH v2 1/1 Add test for CVE 2017-10661
In reply to Petr VorelHi!
Quoted 16 lines
Quoted 11 lines
testcases/kernel/syscalls/timerfd/Makefile top_srcdir ?= ../../../.. · line 24
Quoted 8 lines
+++ b/testcases/kernel/syscalls/timerfd/Makefile
testcases/kernel/syscalls/timerfd/Makefile +2
-1@@ -20,6 +20,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrtInteresting, I thought -pthread wouldn't be needed to be in LDLIBS (enough to have it in CFLAGS), but old distros (CentOS 6 in our travis: gcc 4.4.7, glibc 2.12).
OK: it can be just this:
timerfd_settime02: CFLAGS += -pthreadtimerfd_settime02: LDLIBS += -lrt
Quoted 5 lines
because failure in CentOS 6 is different:
timerfd01.c:36: undefined reference to `clock_gettime'
https://api.travis-ci.org/v3/job/657694167/log.txtObviously we need autotools check for it (trivial, I can do it before merge).
-lrt is required in LDLIBS for older libc that had all the posix realtime outside of the glibc.so, and it's harmless on newer glibc so for the time being we just need -lrt in LDLIBS for quite a lot of testcases...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 Add test for CVE 2017-10661
Quoted 8 lines · Cyril Hrubis
Quoted 8 lines
OK: it can be just this:
timerfd_settime02: CFLAGS += -pthreadtimerfd_settime02: LDLIBS += -lrtbecause failure in CentOS 6 is different:
timerfd01.c:36: undefined reference to `clock_gettime'
https://api.travis-ci.org/v3/job/657694167/log.txt
Quoted 7 lines
Quoted 1 line
Obviously we need autotools check for it (trivial, I can do it before merge).
-lrt is required in LDLIBS for older libc that had all the posix realtime outside of the glibc.so, and it's harmless on newer glibc so for the time being we just need -lrt in LDLIBS for quite a lot of testcases...
Ah, right. I broke the Makefile when I deleted the unconditional LDLIBS line... The -lpthread was useless but I didn't realize the -lrt was needed.
I'll resubmit with all fixes mentioned so far then.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH v2 1/1 Add test for CVE 2017-10661
Hi Martin,
Quoted 4 lines
Ah, right. I broke the
Makefilewhen I deleted the unconditional LDLIBS line... The -lpthread was useless but I didn't realize the -lrt was needed.I'll resubmit with all fixes mentioned so far then.
OK, thanks for doing new version.
Kind regards,
Petr
PATCH v2 1/1 Add test for CVE 2017-10661
In reply to Cyril HrubisHi,
Quoted 15 lines
Quoted 14 lines
Quoted 6 lines
testcases/kernel/syscalls/timerfd/Makefile top_srcdir ?= ../../../.. · line 24
Quoted 3 lines
testcases/kernel/syscalls/timerfd/Makefile +2
-1-LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrtInteresting, I thought -pthread wouldn't be needed to be in LDLIBS (enough to have it in CFLAGS), but old distros (CentOS 6 in our travis: gcc 4.4.7, glibc 2.12).
OK: it can be just this:
timerfd_settime02: CFLAGS += -pthreadtimerfd_settime02: LDLIBS += -lrtbecause failure in CentOS 6 is different:
timerfd01.c:36: undefined reference to `clock_gettime'
https://api.travis-ci.org/v3/job/657694167/log.txt
Quoted 6 lines
Quoted 1 line
Obviously we need autotools check for it (trivial, I can do it before merge).
-lrt is required in LDLIBS for older libc that had all the posix realtime outside of the glibc.so, and it's harmless on newer glibc so for the time being we just need -lrt in LDLIBS for quite a lot of testcases...
Thanks, that's documented. I was mentioning -pthread.
Kind regards,
Petr
PATCH v2 1/1 Add test for CVE 2017-10661
In reply to Cyril HrubisHi,
Quoted 4 lines
-lrt is required in LDLIBS for older libc that had all the posix realtime outside of the glibc.so, and it's harmless on newer glibc so for the time being we just need -lrt in LDLIBS for quite a lot of testcases...
I mean I'd put in the Makefile:
CFLAGS += -pthread
LDLIBS += -lrt
Kind regards,
Petr
PATCH v2 1/1 Add test for CVE 2017-10661
In reply to Petr Vorel(Resending because I forgot to CC the LTP mailing list in the original message to Petr Vorel.)
Quoted 6 lines · Petr Vorel
testcases/kernel/syscalls/timerfd/Makefile top_srcdir ?= ../../../.. · line 24
Quoted 3 lines
testcases/kernel/syscalls/timerfd/Makefile +2
-1-LDLIBS += -lpthread -lrt +timerfd_settime02: CFLAGS += -pthread +timerfd_settime02: LDLIBS += -pthread -lrtInteresting, I thought -pthread wouldn't be needed to be in LDLIBS (enough to have it in CFLAGS), but old distros (CentOS 6 in our travis: gcc 4.4.7, glibc 2.12).
pthread_create() man page say "compile AND link with -pthread". ?\_(?)_/?
Quoted 7 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 81
Quoted 5 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c new file +5
-0+while (tst_fzsync_run_a (&fzsync_pair)) { +TEST (punch_clock (TFD_TIMER_ABSTIME |TFD_TIMER_CANCEL_ON_SET )); + +if (TST_RET ==-1 ) +tst_res (TBROK |TTERRNO ,TIMERFD_FLAGS " failed" );Now this needs to be tst_res(TFAIL (person who merges this will do).
Quoted 5 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c line 85
Quoted 4 lines
testcases/kernel/syscalls/timerfd/timerfd_settime02.c new file +4
-0+ +if (TST_RET !=0 ) +tst_res (TBROK |TTERRNO ,"Invalid " TIMERFD_FLAGS +" return value" );The same here.
No, both should be tst_brk(). There's no point continuing the test if setting the CANCEL_ON_SET flag fails. Sorry about the typo, I need more coffee.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic