aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2024-02-16 18:22:30 +0100
committerGitHub <noreply@github.com>2024-02-16 18:22:30 +0100
commiteee78077e2708941154709773bb3c298b895901e (patch)
tree35656882852e215793a292087dfff86506da3c5e
parentebdb71aeb0c6da8a6782c377b43e9fc954cc5f45 (diff)
parentca91d3fbc0c135a0217f01fa536298f69e5ba3a8 (diff)
downloadafl++-eee78077e2708941154709773bb3c298b895901e.tar.gz
Merge pull request #1998 from trail-of-forks/grub-cmdline
afl-persistent-config: Use GRUB_CMDLINE_LINUX instead of GRUB_CMDLINE_LINUX_DEFAULT
-rwxr-xr-xafl-persistent-config23
1 files changed, 16 insertions, 7 deletions
diff --git a/afl-persistent-config b/afl-persistent-config
index d1649468..dede032f 100755
--- a/afl-persistent-config
+++ b/afl-persistent-config
@@ -124,17 +124,26 @@ kernel.sched_latency_ns=250000000
EOF
}
- grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null || echo Error: /etc/default/grub with GRUB_CMDLINE_LINUX_DEFAULT is not present, cannot set boot options
- grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub 2>/dev/null && {
- grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | grep -E -q 'noibrs pcid nopti' || {
+ grub_try_disable_mitigation () {
+ KEY="$1"
+ if ! grep -E "^$KEY=" /etc/default/grub | grep -E -q 'noibrs pcid nopti'; then
echo "Configuring performance boot options"
- LINE=`grep -E '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub | sed 's/^GRUB_CMDLINE_LINUX_DEFAULT=//' | tr -d '"'`
+ LINE=`grep -E "^$KEY=" /etc/default/grub | sed "s/^$KEY=//" | tr -d '"'`
OPTIONS="$LINE ibpb=off ibrs=off kpti=off l1tf=off spec_rstack_overflow=off mds=off no_stf_barrier noibpb noibrs pcid nopti nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=on pti=off spec_store_bypass_disable=off spectre_v2=off stf_barrier=off srbds=off noexec=off noexec32=off tsx=on tsx=on tsx_async_abort=off mitigations=off audit=0 hardened_usercopy=off ssbd=force-off"
- echo Setting boot options in /etc/default/grub to GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\"
- sed -i "s|^GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT=\"$OPTIONS\"|" /etc/default/grub
- }
+ echo Setting boot options in /etc/default/grub to $KEY=\"$OPTIONS\"
+ sed -i "s|^$KEY=.*|$KEY=\"$OPTIONS\"|" /etc/default/grub
+ fi
}
+
+ if grep -E -q '^GRUB_CMDLINE_LINUX=' /etc/default/grub || grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=' /etc/default/grub; then
+ grub_try_disable_mitigation "GRUB_CMDLINE_LINUX_DEFAULT"
+ # We also overwrite GRUB_CMDLINE_LINUX because some distributions already overwrite GRUB_CMDLINE_LINUX_DEFAULT
+ grub_try_disable_mitigation "GRUB_CMDLINE_LINUX"
+ else
+ echo "Error: /etc/default/grub with GRUB_CMDLINE_LINUX is not present, cannot set boot options"
+ fi
+
echo
echo "Reboot and enjoy your fuzzing"
exit 0