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  linux-cve-announce  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:   Mon,  8 Nov 2021 16:19:15 +0100
From:   Lukas Czerner <lczerner@...hat.com>
To:     fstests@...r.kernel.org
Cc:     linux-ext4@...r.kernel.org, tytso@....edu, guan@...u.me
Subject: [PATCH 1/2] common/rc: add _require_kernel_config and _has_kernel_config

Add _require_kernel_config() and _has_kernel_config() helpers to check
whether a specific kernel configuration is enabled on the kernel.

Signed-off-by: Lukas Czerner <lczerner@...hat.com>
---
 common/config |  1 +
 common/rc     | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/common/config b/common/config
index 164381b7..e0a5c5df 100644
--- a/common/config
+++ b/common/config
@@ -226,6 +226,7 @@ export OPENSSL_PROG="$(type -P openssl)"
 export ACCTON_PROG="$(type -P accton)"
 export E2IMAGE_PROG="$(type -P e2image)"
 export BLKZONE_PROG="$(type -P blkzone)"
+export GZIP_PROG="$(type -P gzip)"
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
diff --git a/common/rc b/common/rc
index 0d261184..84154868 100644
--- a/common/rc
+++ b/common/rc
@@ -4703,6 +4703,35 @@ _require_names_are_bytes() {
         esac
 }
 
+_has_kernel_config()
+{
+	option=$1
+	uname=$(uname -r)
+	config_list="$KCONFIG_PATH
+		     /proc/config.gz
+		     /lib/modules/$uname/build/.config
+		     /boot/config-$uname
+		     /lib/kernel/config-$uname"
+
+	for config in $config_list; do
+		[ ! -f $config ] && continue
+		[ $config = "/proc/config.gz" ] && break
+		grep -qE "^${option}=[my]" $config
+		return
+	done
+
+	[ ! -f $config ] && _notrun "Could not locate kernel config file"
+
+	# We can only get here with /proc/config.gz
+	_require_command "$GZIP_PROG" gzip
+	$GZIP_PROG -cd $config | grep -qE "^${option}=[my]"
+}
+
+_require_kernel_config()
+{
+	_has_kernel_config $1 || _notrun "Installed kernel not built with $1"
+}
+
 init_rc
 
 ################################################################################
-- 
2.31.1

Powered by blists - more mailing lists