diff mbox series

[3/3] check: don't allow TEST_DIR/SCRATCH_MNT to be in /tmp

Message ID 174182089161.1400713.6024925682002640886.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/3] xfs/614: determine the sector size of the fs image by doing a test format | expand

Commit Message

Darrick J. Wong March 12, 2025, 11:12 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

If we're running in a private mount namespace, /tmp is a private tmpfs
mount.  Using TEST_DIR/SCRATCH_MNT that point there is a bad idea
because anyone can write to there.  Let's just stop that.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 check |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Darrick J. Wong March 21, 2025, 9:22 p.m. UTC | #1
On Wed, Mar 12, 2025 at 04:12:04PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> If we're running in a private mount namespace, /tmp is a private tmpfs

Since we're dropping privatens for ./check, there's no need for this
patch anymore.  I'll roll up and resend this series without this patch
and with the rvbs that have trickled in since then.

--D

> mount.  Using TEST_DIR/SCRATCH_MNT that point there is a bad idea
> because anyone can write to there.  Let's just stop that.
> 
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
>  check |   14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> 
> diff --git a/check b/check
> index 33eb3e0859e578..09134ee63e41e2 100755
> --- a/check
> +++ b/check
> @@ -815,6 +815,20 @@ function run_section()
>  		echo "SECTION       -- $section"
>  	fi
>  
> +	# If we're running in a private mount namespace, /tmp is a private
> +	# directory.  We /could/ just mkdir it, but we'd rather have people
> +	# set those paths elsewhere.
> +	if [ "$HAVE_PRIVATENS" = yes ] && [[ $TEST_DIR =~ ^\/tmp ]]; then
> +		echo "$TEST_DIR: TEST_DIR must not be in /tmp"
> +		status=1
> +		exit
> +	fi
> +	if [ "$HAVE_PRIVATENS" = yes ] && [[ $SCRATCH_MNT =~ ^\/tmp ]]; then
> +		echo "$SCRATCH_MNT: SCRATCH_MNT must not be in /tmp"
> +		status=1
> +		exit
> +	fi
> +
>  	sect_start=`_wallclock`
>  	if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
>  		echo "RECREATING    -- $FSTYP on $TEST_DEV"
> 
>
diff mbox series

Patch

diff --git a/check b/check
index 33eb3e0859e578..09134ee63e41e2 100755
--- a/check
+++ b/check
@@ -815,6 +815,20 @@  function run_section()
 		echo "SECTION       -- $section"
 	fi
 
+	# If we're running in a private mount namespace, /tmp is a private
+	# directory.  We /could/ just mkdir it, but we'd rather have people
+	# set those paths elsewhere.
+	if [ "$HAVE_PRIVATENS" = yes ] && [[ $TEST_DIR =~ ^\/tmp ]]; then
+		echo "$TEST_DIR: TEST_DIR must not be in /tmp"
+		status=1
+		exit
+	fi
+	if [ "$HAVE_PRIVATENS" = yes ] && [[ $SCRATCH_MNT =~ ^\/tmp ]]; then
+		echo "$SCRATCH_MNT: SCRATCH_MNT must not be in /tmp"
+		status=1
+		exit
+	fi
+
 	sect_start=`_wallclock`
 	if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
 		echo "RECREATING    -- $FSTYP on $TEST_DEV"