Skip to contentSkip to conversation

fstests: test dirty pipe vulnerability issue of CVE-2022-0847

PATCH New Zorro Lang 1 participant 1 message Mar 20, 2022

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v2 1/1 fstests: test dirty pipe vulnerability issue of CVE-2022-0847

Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an uninitialized "pipe_buffer.flags" variable. The bug cause a file can be overwritten even if a user/process is not permitted to write it. It's fixed by 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer").

Cc Max Kellermann <[email protected]>

---

Thanks review points from Darrick, V2 did below changes:
1) change src/splice2pipe.c:prepare_pipe(), print some messages if pipe() syscall fails.
2) remove $TEST_DIR/testfile.$seq in _cleanup

I'll replace *hexdump* with *od* in another patch, as suggestion from Darrick and Dave.

Thanks,
Zorro

 .gitignore            |   1 +
 src/Makefile          |   2 +-
 src/splice2pipe.c     | 158 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/676     |  54 +++++++++++++++
 tests/generic/676.out |   9 +++
 5 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 src/splice2pipe.c
 create mode 100755 tests/generic/676
 create mode 100644 tests/generic/676.out
.gitignore +1 -0
index ba0c572b..a05c6058 100644
@@ -125,6 +125,7 @@ tags
 /src/runas
 /src/seek_copy_test
 /src/seek_sanity_test
+/src/splice2pipe
 /src/splice-test
 /src/stale_handle
 /src/stat_test
src/Makefile +1 -1
index 111ce1d9..7725c4aa 100644
@@ -31,7 +31,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	dio-invalidate-cache stat_test t_encrypted_d_revalidate \
 	attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \
 	fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \
-	detached_mounts_propagation ext4_resize
+	detached_mounts_propagation ext4_resize splice2pipe
 
 EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \
 	      btrfs_crc32c_forged_name.py
src/splice2pipe.c new file +158 -0

158 lines not on this page · raw message

tests/generic/676 new file +54 -0

54 lines not on this page · raw message

tests/generic/676.out new file +9 -0
new file mode 100644
index 00000000..f006e659
@@ -0,0 +1,9 @@
+QA output created by 676
+Test privileged user:
+00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
+*
+00001000
+Test unprivileged user:
+00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
+*
+00001000
Signature · 1 line
2.31.1