Skip to contentSkip to conversation

generic/626: add test for detached mount propagation

PATCH In review Christian Brauner 1 participant 2 messages Mar 9, 2021 – Mar 10, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/626: add test for detached mount propagation

Regression test to verify that creating a series of detached mounts, attaching them to the filesystem, and unmounting them does not trigger an integer overflow in ns->mounts causing the kernel to block any new mounts in count_mounts() and returning ENOSPC because it falsely assumes that the maximum number of mounts in the mount namespace has been reached, i.e. it thinks it can't fit the new mounts into the mount namespace anymore.

The test is written in a way that it will leave the host's mount namespace intact so we are sure to never make the host's mount namespace unuseable!

The fix is in [1].

[1]: https://git.kernel.org/brauner/c/ee2e3f50629f17b0752b55b2566c15ce8dafb557

Cc Christoph Hellwig <[email protected]>
Cc David Howells <[email protected]>
---
 .gitignore                        |   1 +
 src/Makefile                      |   3 +-
 src/detached_mounts_propagation.c | 252 ++++++++++++++++++++++++++++++
 tests/generic/626                 |  41 +++++
 tests/generic/626.out             |   2 +
 tests/generic/group               |   1 +
 6 files changed, 299 insertions(+), 1 deletion(-)
 create mode 100644 src/detached_mounts_propagation.c
 create mode 100755 tests/generic/626
 create mode 100644 tests/generic/626.out
.gitignore +1 -0
index f988a44a..f9f8e003 100644
@@ -60,6 +60,7 @@
 /src/bulkstat_unlink_test_modified
 /src/cloner
 /src/dbtest
+/src/detached_mounts_propagation
 /src/devzero
 /src/dio-interleaved
 /src/dio-invalidate-cache
src/Makefile +2 -1
index 811b24e4..e7bd1450 100644
@@ -29,7 +29,8 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	attr-list-by-handle-cursor-test listxattr dio-interleaved t_dir_type \
 	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
+	fscrypt-crypt-util bulkstat_null_ocount splice-test \
+	detached_mounts_propagation
 
 SUBDIRS = log-writes perf
 
src/detached_mounts_propagation.c new file +252 -0

252 lines not on this page · raw message

tests/generic/626 new file +41 -0

41 lines not on this page · raw message

tests/generic/626.out new file +2 -0
new file mode 100644
index 00000000..5afa765d
@@ -0,0 +1,2 @@
+QA output created by 626
+silence is golden
tests/generic/group +1 -0
index 84db3789..685004c2 100644
@@ -628,3 +628,4 @@
 623 auto quick shutdown
 624 auto quick verity
 625 auto quick verity
+626 auto quick mount

base-commit: 52a3700b26e15a7267527463766ef1f22768ae25

Signature · 1 line
2.27.0
#1 lore raw
Quoted 7 lines · Christian Brauner

Regression test to verify that creating a series of detached mounts, attaching them to the filesystem, and unmounting them does not trigger an integer overflow in ns->mounts causing the kernel to block any new mounts in count_mounts() and returning ENOSPC because it falsely assumes that the maximum number of mounts in the mount namespace has been reached, i.e. it thinks it can't fit the new mounts into the mount namespace anymore.

Quoted 7 lines

The test is written in a way that it will leave the host's mount namespace intact so we are sure to never make the host's mount namespace unuseable!

The fix is in [1].

[1]: https://git.kernel.org/brauner/c/ee2e3f50629f17b0752b55b2566c15ce8dafb557

The fix is now in mainline so this should be good to pick up/review if people think it's useful to have!

Thanks!
Christian