Add a regression test for CVE-2017-1000380
PATCH v4 1/1 Add a regression test for CVE-2017-1000380
A race condition was present in the linux kernel, which could lead to a leak of arbitrary kernel memory to userspace applications.
The issue was fixed in those kernel commits:
http://git.kernel.org/linus/d11662f4f798b50d8c8743f433842c3e40fe3378
http://git.kernel.org/linus/ba3021b2c79b2fa9114f92790a99deb27a65b728
This patch adds a regression test triggering this race condition.
---
Changes to v2:
- remove leftover declarion of unused variable in ioctl_thread()
- reduced iov_len by 1, so the strlen command hits a valid \0 for sure in any case.
- fix whitespace before tab in Makefile
Changes to v1:
- Initialize buffers in ioctl_thread() outside of the loop
- use return unused() instead of a void* cast of NULL in ioctl_thread()
- reset non-zero flag in run() for every iteration of the main loop
--- runtest/cve | 1 + testcases/kernel/Makefile | 1 + testcases/kernel/sound/.gitignore | 1 + testcases/kernel/sound/Makefile | 12 +++ testcases/kernel/sound/snd_timer01.c | 139 +++++++++++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 testcases/kernel/sound/.gitignore create mode 100644 testcases/kernel/sound/Makefile create mode 100644 testcases/kernel/sound/snd_timer01.c
runtest/cve +1 -0
@@ -36,6 +36,7 @@ cve-2017-17052 cve-2017-17052 cve-2017-16939 cve-2017-16939 cve-2017-17053 cve-2017-17053 cve-2017-18075 pcrypt_aead01 +cve-2017-1000380 snd_timer01 cve-2018-5803 sctp_big_chunk cve-2018-1000001 realpath01 cve-2018-19854 crypto_user01
testcases/kernel/Makefile +1 -0
@@ -52,6 +52,7 @@ SUBDIRS += connectors \ pty \ sched \ security \ + sound \ timers \ tracing \
testcases/kernel/sound/.gitignore new file +1 -0
@@ -0,0 +1 @@ +snd_timer
testcases/kernel/sound/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir := ../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +CPPFLAGS += -D_GNU_SOURCE + +LDLIBS += -pthread + + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/sound/snd_timer01.c new file +139 -0
139 lines not on this page · raw message
Signature · 1 line
2.22.0
PATCH v4 1/1 Add a regression test for CVE-2017-1000380
Hi!
Pushed with a minor change, thanks.
testcases/kernel/sound/snd_timer01.c line 78
Quoted 3 lines
testcases/kernel/sound/snd_timer01.c new file +3
-0+static void cleanup (void ) +{ +tst_fzsync_pair_cleanup (&fzsync_pair);
I've removed the tst_fzsync_pair_cleanup() here because the function is no-op unless you started the second thread by the fzsync reste call.
Quoted 2 lines
(quoted diff) +2
-0+ SAFE_CLOSE(snd_fd); +}
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 1/1 Add a regression test for CVE-2017-1000380
In reply to Michael Moesetestcases/kernel/sound/snd_timer01.c line 73
Quoted 9 lines · Michael Moese
...
testcases/kernel/sound/snd_timer01.c new file +7
-0+ +static void setup (void ) +{ +tst_fzsync_pair_init (&fzsync_pair); +tst_taint_init (TST_TAINT_W |TST_TAINT_D ); + snd_fd =SAFE_OPEN ("/dev/snd/timer" , +O_RDONLY |O_CREAT |O_NOCTTY |O_SYNC |O_LARGEFILE ,0 );
Should we check if the file exists before opening it?
Otherwise, snd_timer01 failed as:
# ./snd_timer01 tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s safe_macros.c:225: BROK: snd_timer01.c:73: open(/dev/snd/timer,1052992,00) failed: ENOENT
# lsmod |grep -i snd
# grep -i snd /boot/config-4.18.0-107.el8.s390x
# ls /dev/snd/timer ls: cannot access '/dev/snd/timer': No such file or directory
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20190716/3c171fad/attachment.htm>
PATCH v4 1/1 Add a regression test for CVE-2017-1000380
Hi!
Quoted 9 lines
testcases/kernel/sound/snd_timer01.c line 73
Quoted 7 lines
testcases/kernel/sound/snd_timer01.c new file +6
-0+static void setup (void ) +{ +tst_fzsync_pair_init (&fzsync_pair); +tst_taint_init (TST_TAINT_W |TST_TAINT_D ); + snd_fd =SAFE_OPEN ("/dev/snd/timer" , +O_RDONLY |O_CREAT |O_NOCTTY |O_SYNC |O_LARGEFILE ,0 );Should we check if the file exists before opening it?
Yes we should. We should add access("/dev/snd/timer", F_OK) to the test setup.
Quoted 7 lines
Otherwise,
snd_timer01failed as:# ./snd_timer01 tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s safe_macros.c:225: BROK: snd_timer01.c:73: open(/dev/snd/timer,1052992,00) failed: ENOENT
Quoted 6 lines
# lsmod |grep -i snd# grep -i snd /boot/config-4.18.0-107.el8.s390x# ls /dev/snd/timer ls: cannot access '/dev/snd/timer': No such file or directory
I guess that there is no soundcard on mainframe :-).
Signature · 2 lines
Cyril Hrubis [email protected]