Add test for possible writev() issues with NULL buffer in iovec
PATCH v2 1/1 Add test for possible writev() issues with NULL buffer in iovec
Fixes #790
---
This test triggers temporary write of invalid data into test file on some file systems on kernel 4.4.21 and older.
Changes since v1:
- Simplify main thread
- Use atomic load/store when passing read limit between threads (I hope I'm doing it correctly)
- Check for too big writes just in case
- Require at least 2 CPUs, the bugs are not reproducible on single-CPU systems
runtest/syscalls | 1 + testcases/kernel/syscalls/writev/.gitignore | 1 + testcases/kernel/syscalls/writev/Makefile | 3 + testcases/kernel/syscalls/writev/writev03.c | 145 ++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 testcases/kernel/syscalls/writev/writev03.c
runtest/syscalls +1 -0
@@ -1675,6 +1675,7 @@ write05 write05 writev01 writev01 writev02 writev02 +writev03 writev03 writev05 writev05 writev06 writev06 writev07 writev07
testcases/kernel/syscalls/writev/.gitignore +1 -0
@@ -1,5 +1,6 @@ /writev01 /writev02 +/writev03 /writev05 /writev06 /writev07
testcases/kernel/syscalls/writev/Makefile +3 -0
@@ -9,4 +9,7 @@ endif include $(top_srcdir)/include/mk/testcases.mk +writev03: CFLAGS += -pthread +writev03: LDLIBS += -lrt + include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/writev/writev03.c new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH v2 1/1 Add test for possible writev() issues with NULL buffer in iovec
Hi Martin,
Quoted 8 lines
Fixes #790
Signed-off-by Martin Doucha <[email protected]>---
This test triggers temporary write of invalid data into test file on some file systems on kernel 4.4.21 and older.
Quoted 6 lines
Changes since v1:
- Simplify main thread
- Use atomic load/store when passing read limit between threads (I hope I'm doing it correctly)
- Check for too big writes just in case
- Require at least 2 CPUs, the bugs are not reproducible on single-CPU systems
It takes some time to run due .all_filesystems, but I guess there is a reason to test it on all available fs.
...
Quoted 6 lines
testcases/kernel/syscalls/writev/writev03.c new file +0
-0
testcases/kernel/syscalls/writev/writev03.c line 9
Quoted 9 lines
testcases/kernel/syscalls/writev/writev03.c new file +9
-0@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2021 SUSE LLC <[email protected]> +* +* Check for potential issues in writev() if the first iovec entry is NULL +* and the next one is not present in RAM. This can result in a brief window +* where writev() first writes uninitialized data into the file (possibly +* exposing internal kernel structures) and then overwrites it with the real +* iovec contents later. Bugs fixed in:
Maybe this doc part should be in * [DESCRIPTION] to get into docparse.
The rest LGTM.
Kind regards,
Petr
PATCH v2 1/1 Add test for possible writev() issues with NULL buffer in iovec
Quoted 2 lines · Petr Vorel
It takes some time to run due .all_filesystems, but I guess there is a reason to test it on all available fs.
Yes, test results depend on FS-specific backend implementation bugs. ext2, ext3 and vfat fail; ext4, xfs and btrfs pass on unpatched kernels.
Quoted 17 lines
...
Quoted 6 lines
testcases/kernel/syscalls/writev/writev03.c new file +0
-0testcases/kernel/syscalls/writev/writev03.c line 9
Quoted 9 lines
testcases/kernel/syscalls/writev/writev03.c new file +9
-0@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2021 SUSE LLC <[email protected]> +* +* Check for potential issues in writev() if the first iovec entry is NULL +* and the next one is not present in RAM. This can result in a brief window +* where writev() first writes uninitialized data into the file (possibly +* exposing internal kernel structures) and then overwrites it with the real +* iovec contents later. Bugs fixed in: Maybe this doc part should be in * [DESCRIPTION] to get into docparse.
Yes, please add it before pushing the patch.
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 possible writev() issues with NULL buffer in iovec
In reply to Martin DouchaPATCH v2 1/1 Add test for possible writev() issues with NULL buffer in iovec
Hi Martin, Richie,
Quoted 5 lines
Hello,
LGTM.
Reviewed-by Richard Palethorpe <[email protected]>
Thanks for your review!
Martin, thanks for your patch, merged!
Kind regards,
Petr