Files
apfstests/tests/generic/632
T
Christian Brauner a7f90c1433 generic: 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!

Link: https://git.kernel.org/torvalds/c/ee2e3f50629f17b0752b55b2566c15ce8dafb557
Cc: Eryu Guan <guan@eryu.me>
Cc: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-04-18 20:53:53 +08:00

47 lines
1.2 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (c) 2021 Christian Brauner <christian.brauner@ubuntu.com>
# All Rights Reserved.
#
# FS QA Test No. 632
#
# 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.
#
# Kernel commit ee2e3f50629f ("mount: fix mounting of detached mounts onto
# targets that reside on shared mounts") fixed the bug.
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
. ./common/rc
rm -f $seqres.full
_supported_fs generic
_require_test
_require_test_program "detached_mounts_propagation"
$here/src/detached_mounts_propagation $TEST_DIR >> $seqres.full
status=$?
echo silence is golden
exit