@@ -9,7 +9,24 @@ set -e -o pipefail
9
9
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
10
10
11
11
# non root users are not able to access some kernel params, so they get blacklisted
12
- SYSCTL_BLACKLIST=' stable_secret\|vm.stat_refresh\|fs.protected_hardlinks\|fs.protected_symlinks\|kernel.cad_pid\|kernel.unprivileged_userns_apparmor_policy\|kernel.usermodehelper.bset\|kernel.usermodehelper.inheritable\|net.core.bpf_jit_harden\|net.core.bpf_jit_kallsyms\|net.ipv4.tcp_fastopen_key\|vm.mmap_rnd_bits\|vm.mmap_rnd_compat_bits'
12
+ SYSCTL_BLACKLIST='
13
+ fs.protected_hardlinks
14
+ fs.protected_symlinks
15
+ kernel.cad_pid
16
+ kernel.unprivileged_userns_apparmor_policy
17
+ kernel.usermodehelper.bset
18
+ kernel.usermodehelper.inheritable
19
+ net.core.bpf_jit_harden
20
+ net.core.bpf_jit_kallsyms
21
+ net.ipv4.tcp_fastopen_key
22
+ stable_secret
23
+ vm.mmap_rnd_bits
24
+ vm.mmap_rnd_compat_bits
25
+ vm.stat_refresh'
26
+
27
+ SYSCTL_BLACKLIST_REGEX=" $( printf ' \|%s' $SYSCTL_BLACKLIST ) "
28
+ # strip leading '\|'
29
+ SYSCTL_BLACKLIST_REGEX=${SYSCTL_BLACKLIST_REGEX: 2}
13
30
14
31
function perform_test {
15
32
probecheck " sysctl" || return 255
@@ -31,9 +48,9 @@ $OSCAP oval eval --results $result $srcdir/test_sysctl_probe_all.oval.xml > /dev
31
48
# sysctl has duplicities in output
32
49
# hide permission errors like: "sysctl: permission denied on key 'fs.protected_hardlinks'"
33
50
# kernel parameters might use "/" and "." separators interchangeably - normalizing
34
- sysctl -aN --deprecated 2> /dev/null | grep -v $SYSCTL_BLACKLIST | tr " /" " ." | sort -u > " $sysctlNames "
51
+ sysctl -aN --deprecated 2> /dev/null | grep -v $SYSCTL_BLACKLIST_REGEX | tr " /" " ." | sort -u > " $sysctlNames "
35
52
36
- grep unix-sys:name " $result " | grep -v $SYSCTL_BLACKLIST | sed -E ' s;.*>(.*)<.*;\1;g' | sort > " $ourNames "
53
+ grep unix-sys:name " $result " | grep -v $SYSCTL_BLACKLIST_REGEX | sed -E ' s;.*>(.*)<.*;\1;g' | sort > " $ourNames "
37
54
38
55
# If procps_ver > 3.3.12 we need to filter *stable_secret and vm.stat_refresh
39
56
# options from the sysctl output, for more details see
0 commit comments