lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  5 Jan 2021 20:01:42 +0530
From:   Ritesh Harjani <riteshh@...ux.ibm.com>
To:     fstests@...r.kernel.org
Cc:     linux-xfs@...r.kernel.org, linux-ext4@...r.kernel.org,
        anju@...ux.vnet.ibm.com, guan@...u.me, darrick.wong@...cle.com,
        Ritesh Harjani <riteshh@...ux.ibm.com>
Subject: [PATCHv3 1/2] common/rc: swapon should not fail for given FS in _require_scratch_swapfile()

Filesystems e.g. ext* and XFS supports swapon by default and an error
returned with swapon should be treated as a failure.

Signed-off-by: Ritesh Harjani <riteshh@...ux.ibm.com>
---
v2 -> v3:
1. Removed whitelisted naming convention.
2. Added ext2/ext3 as well as supported FS for swapon.
3. Removed local variable $fstyp, instead used $FSTYP directly in switch case.

 common/rc | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/common/rc b/common/rc
index 33b5b598a198..649b1cfd884a 100644
--- a/common/rc
+++ b/common/rc
@@ -2401,10 +2401,22 @@ _require_scratch_swapfile()
 	# Minimum size for mkswap is 10 pages
 	_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))

-	if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-		_scratch_unmount
-		_notrun "swapfiles are not supported"
-	fi
+	# ext* and xfs have supported all variants of swap files since their
+	# introduction, so swapon should not fail.
+	case "$FSTYP" in
+	ext2|ext3|ext4|xfs)
+		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
+			_scratch_unmount
+			_fail "swapon failed for $FSTYP"
+		fi
+		;;
+	*)
+		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
+			_scratch_unmount
+			_notrun "swapfiles are not supported"
+		fi
+		;;
+	esac

 	swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
 	_scratch_unmount
--
2.26.2

Powered by blists - more mailing lists