killswitch: add per-function short-circuit mitigation primitive
Subsystems (5)
PATCH 1/1 killswitch: add per-function short-circuit mitigation primitive
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \
> /sys/kernel/security/killswitch/controlAfter this, af_alg_sendmsg() returns -EPERM on every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.
A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users: AF_ALG, ksmbd, nf_tables, vsock, ax25, and friends.
For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
--- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/killswitch.rst | 159 ++++ Documentation/admin-guide/tainted-kernels.rst | 8 + MAINTAINERS | 11 + include/linux/killswitch.h | 19 + include/linux/panic.h | 3 +- init/Kconfig | 2 + kernel/Kconfig.killswitch | 31 + kernel/Makefile | 1 + kernel/killswitch.c | 798 ++++++++++++++++++ kernel/panic.c | 1 + lib/Kconfig.debug | 13 + lib/Makefile | 1 + lib/test_killswitch.c | 85 ++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/killswitch/.gitignore | 1 + tools/testing/selftests/killswitch/Makefile | 8 + .../selftests/killswitch/cve_31431_test.c | 162 ++++ .../selftests/killswitch/killswitch_test.sh | 147 ++++ 19 files changed, 1451 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/killswitch.rst create mode 100644 include/linux/killswitch.h create mode 100644 kernel/Kconfig.killswitch create mode 100644 kernel/killswitch.c create mode 100644 lib/test_killswitch.c create mode 100644 tools/testing/selftests/killswitch/.gitignore create mode 100644 tools/testing/selftests/killswitch/Makefile create mode 100644 tools/testing/selftests/killswitch/cve_31431_test.c create mode 100755 tools/testing/selftests/killswitch/killswitch_test.sh
Documentation/admin-guide/index.rst +1 -0
@@ -70,6 +70,7 @@ problems and bugs in particular. bug-hunting bug-bisect tainted-kernels + killswitch ramoops dynamic-debug-howto init
Documentation/admin-guide/killswitch.rst new file +159 -0
159 lines not on this page · raw message
Documentation/admin-guide/tainted-kernels.rst +8 -0
@@ -102,6 +102,7 @@ Bit Log Number Reason that got the kernel tainted 17 _/T 131072 kernel was built with the struct randomization plugin 18 _/N 262144 an in-kernel test has been run 19 _/J 524288 userspace used a mutating debug operation in fwctl + 20 _/H 1048576 killswitch override engaged (function short-circuited) === === ====== ======================================================== Note: The character ``_`` is representing a blank in this table to make reading
@@ -189,3 +190,10 @@ More detailed explanation for tainting 19) ``J`` if userspace opened /dev/fwctl/* and performed a FWTCL_RPC_DEBUG_WRITE to use the devices debugging features. Device debugging features could cause the device to malfunction in undefined ways. + + 20) ``H`` if the killswitch primitive (see + Documentation/admin-guide/killswitch.rst) has been engaged on at least + one function. The kernel is no longer running its source: at least one + function has been short-circuited to return a fixed value. The taint + persists across ``disengage`` until the next reboot — once the running + image has been modified, oops triage must reflect that.
MAINTAINERS +11 -0
@@ -14347,6 +14347,17 @@ F: lib/Kconfig.kmsan F: mm/kmsan/ F: scripts/Makefile.kmsan +KILLSWITCH (function short-circuit mitigation) +M: Sasha Levin <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/admin-guide/killswitch.rst +F: include/linux/killswitch.h +F: kernel/Kconfig.killswitch +F: kernel/killswitch.c +F: lib/test_killswitch.c +F: tools/testing/selftests/killswitch/ + KPROBES M: Naveen N Rao <[email protected]> M: "David S. Miller" <[email protected]>
include/linux/killswitch.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2026 Sasha Levin <[email protected]> +*/ +#ifndef _LINUX_KILLSWITCH_H +#define _LINUX_KILLSWITCH_H + +#ifdef CONFIG_KILLSWITCH +int killswitch_engage (const char *symbol,long retval); +int killswitch_disengage (const char *symbol); +bool killswitch_is_engaged (const char *symbol); +#else +static inline int killswitch_engage (const char *symbol,long retval) +{return -ENOSYS ; } +static inline int killswitch_disengage (const char *symbol) {return -ENOSYS ; } +static inline bool killswitch_is_engaged (const char *symbol) {return false; } +#endif + +#endif /* _LINUX_KILLSWITCH_H */
include/linux/panic.h +2 -1
@@ -88,7 +88,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)#define TAINT_RANDSTRUCT 17#define TAINT_TEST 18#define TAINT_FWCTL 19 -#define TAINT_FLAGS_COUNT 20 +#define TAINT_KILLSWITCH 20 +#define TAINT_FLAGS_COUNT 21#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)struct taint_flag {
init/Kconfig +2 -0
@@ -2278,6 +2278,8 @@ config ASN1 source "kernel/Kconfig.locks" +source "kernel/Kconfig.killswitch" + config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE bool
kernel/Kconfig.killswitch new file +31 -0
@@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Killswitch: per-function short-circuit mitigation primitive. +# +# Copyright (C) 2026 Sasha Levin <[email protected]> +# + +config KILLSWITCH + bool "Killswitch: short-circuit a kernel function as a CVE mitigation" + depends on SECURITYFS + depends on KPROBES && HAVE_KPROBES_ON_FTRACE + depends on HAVE_FUNCTION_ERROR_INJECTION + select FUNCTION_ERROR_INJECTION + help + Provide an admin-facing mechanism to make a chosen kernel function + return a fixed value without executing its body, as a temporary + mitigation for a security bug before a real fix is available. + + Operators write "engage <symbol> <retval> [reason]" to + /sys/kernel/security/killswitch/control. The function entry is + redirected via a kprobe whose pre-handler sets the chosen return + value and short-circuits the call. There is no allowlist, + denylist, or return-type validation: if the kprobe layer accepts + the symbol the engagement proceeds, otherwise its error is + returned to userspace. + + This is *not* livepatch: there is no replacement implementation, + the function simply returns the chosen value. Engaging a killswitch + taints the kernel (TAINT_KILLSWITCH, 'H'). Requires CAP_SYS_ADMIN. + + If unsure, say N.
kernel/Makefile +1 -0
@@ -100,6 +100,7 @@ obj-$(CONFIG_GCOV_KERNEL) += gcov/ obj-$(CONFIG_KCOV) += kcov.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_FAIL_FUNCTION) += fail_function.o +obj-$(CONFIG_KILLSWITCH) += killswitch.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
kernel/killswitch.c new file +798 -0
798 lines not on this page · raw message
kernel/panic.c +1 -0
@@ -825,6 +825,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {TAINT_FLAG (RANDSTRUCT ,'T' ,' ' ),TAINT_FLAG (TEST ,'N' ,' ' ),TAINT_FLAG (FWCTL ,'J' ,' ' ), + TAINT_FLAG(KILLSWITCH, 'H', ' '), };#undef TAINT_FLAG
lib/Kconfig.debug +13 -0
@@ -3349,6 +3349,19 @@ config TEST_HMM If unsure, say N. +config TEST_KILLSWITCH + tristate "Test module for the killswitch mitigation primitive" + depends on KILLSWITCH && DEBUG_FS + depends on m + help + Build a module that exposes a deliberately-vulnerable function + ks_test_vuln() and a debugfs trigger /sys/kernel/debug/test_killswitch/fire. + The killswitch selftest in tools/testing/selftests/killswitch/ + uses this to confirm engaging a killswitch suppresses the BUG() + the function would otherwise hit. + + If unsure, say N. + config TEST_FREE_PAGES tristate "Test freeing pages" help
lib/Makefile +1 -0
@@ -100,6 +100,7 @@ obj-$(CONFIG_TEST_MEMCAT_P) += test_memcat_p.o obj-$(CONFIG_TEST_OBJAGG) += test_objagg.o obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o +obj-$(CONFIG_TEST_KILLSWITCH) += test_killswitch.o obj-$(CONFIG_TEST_HMM) += test_hmm.o obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
lib/test_killswitch.c new file +85 -0
85 lines not on this page · raw message
tools/testing/selftests/Makefile +1 -0
@@ -53,6 +53,7 @@ TARGETS += ipc TARGETS += ir TARGETS += kcmp TARGETS += kexec +TARGETS += killswitch TARGETS += kselftest_harness TARGETS += kvm TARGETS += landlock
tools/testing/selftests/killswitch/.gitignore new file +1 -0
@@ -0,0 +1 @@ +cve_31431_test
tools/testing/selftests/killswitch/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026 Sasha Levin <[email protected]> +TEST_GEN_PROGS := cve_31431_test +TEST_PROGS := killswitch_test.sh + +CFLAGS += -O2 -g -std=gnu99 -Wall $(KHDR_INCLUDES) + +include ../lib.mk
tools/testing/selftests/killswitch/cve_31431_test.c new file +162 -0
162 lines not on this page · raw message
tools/testing/selftests/killswitch/killswitch_test.sh new file +147 -0
147 lines not on this page · raw message
Signature · 1 line
2.53.0
Quoted 17 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.
Quoted 6 lines
For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Assisted-by Claude:claude-opus-4-7Signed-off-by Sasha Levin <[email protected]>
This is kind of funny, but understandable. Odds are a distro would want to pick this up so that they can enable this for when their kernel updates do not get out to users quick enough.
One question:
kernel/killswitch.c line 40
Quoted 4 lines
kernel/killswitch.c new file +4
-0+struct ks_attr { +struct list_head list; +struct kprobe kp; +atomic_long_t retval;
Why is this an atomic value? Shouldn't it be whatever the userspace return type is?
kernel/killswitch.c line 46
Quoted 6 lines
kernel/killswitch.c new file +6
-0+/* false once disengaged; per-fn file ops then return -EIDRM. */ +bool engaged; +unsigned long __percpu *hits; +struct dentry *dir; +/* engaged_list holds one ref; each open per-fn fd holds one. */ +refcount_t refcnt;
Why is a refcnt needed? Why not use a kref instead?
thanks,
greg k-h
Quoted 22 lines · Greg KH
Quoted 21 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Quoted 6 lines
Quoted 2 lines
Assisted-by Claude:claude-opus-4-7Signed-off-by Sasha Levin <[email protected]>This is kind of funny, but understandable. Odds are a distro would want to pick this up so that they can enable this for when their kernel updates do not get out to users quick enough.
I figure that even if the new kernel does go out in a timely manner, there are still days (weeks? months?) between when a new kernel is available and when the user reboots.
Might as well try and improve their chances of survival during that period :)
Quoted 9 lines
One question:
kernel/killswitch.c line 40
Quoted 4 lines
kernel/killswitch.c new file +4
-0+struct ks_attr { +struct list_head list; +struct kprobe kp; +atomic_long_t retval;Why is this an atomic value? Shouldn't it be whatever the userspace return type is?
The return register is long on every arch.
While testing this, I added the ability to modify the return value after we create a killswitch, and figured that it could be a useful thing to keep in the code.
But then I got worried about a race between a user changing the return value of the killswitch and some program trying to execute the code, and getting some combination of the old and the new return value.
Is that a real concern? I'm not sure - but making this atomic was cheap enough.
Quoted 8 lines
kernel/killswitch.c line 46
Quoted 6 lines
kernel/killswitch.c new file +6
-0+/* false once disengaged; per-fn file ops then return -EIDRM. */ +bool engaged; +unsigned long __percpu *hits; +struct dentry *dir; +/* engaged_list holds one ref; each open per-fn fd holds one. */ +refcount_t refcnt;Why is a refcnt needed? Why not use a kref instead?
Ugh... no good reason, I can switch to a kref.
Signature · 2 lines
Thanks, Sasha
Quoted 12 lines · Sasha Levin
Quoted 4 lines · Greg KH
kernel/killswitch.c line 40
Quoted 1 line
kernel/killswitch.c new file +1
-0+atomic_long_t retval;Why is this an atomic value? Shouldn't it be whatever the userspace return type is?
The return register is
longon every arch.While testing this, I added the ability to modify the return value after we create a killswitch, and figured that it could be a useful thing to keep in the code.
Quoted 5 lines
But then I got worried about a race between a user changing the return value of the killswitch and some program trying to execute the code, and getting some combination of the old and the new return value.
Is that a real concern? I'm not sure - but making this atomic was cheap enough.
I don't think that a combination should matter all that much here, but at least it makes sense now. You might want to document that somewhere here.
thanks,
greg k-h
Jonathan Corbet
maintainerQuoted 6 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
Quoted 6 lines
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.
A quick look suggests that you're not checking lockdown status. I don't doubt for a second that this thing could be used to bypass lockdown - by shorting out security_locked_down() if nothing else. I'm guessing that might not prove entirely popular.
jon
Quoted 11 lines · Jonathan Corbet
Quoted 9 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/control
Quoted 8 lines
Quoted 3 lines
After this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A quick look suggests that you're not checking lockdown status. I don't doubt for a second that this thing could be used to bypass lockdown - by shorting out
security_locked_down()if nothing else. I'm guessing that might not prove entirely popular.
Hmm... Good point. I'll respin a v2 adressing this and Greg's comments.
Signature · 2 lines
Thanks, Sasha
Quoted 11 lines · Sasha Levin
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.
Quoted 7 lines
A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
I like the concept - but is there any way to ensure that important functions like malloc aren't being patched? Or some way to make sure that what is being patched will not kill the entire kernel?
I know this probably boils down to "operator has to use it correctly", but just wondering if this was considered.
-Josh
Quoted 20 lines · Joshua Peisach
Quoted 11 lines · Sasha Levin
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.Quoted 7 lines
A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Quoted 6 lines
I like the concept - but is there any way to ensure that important functions like malloc aren't being patched? Or some way to make sure that what is being patched will not kill the entire kernel?
I know this probably boils down to "operator has to use it correctly", but just wondering if this was considered.
I like the idea too, it should help prevent a few devops burnouts in the coming weeks.
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.
This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Quoted 21 lines · Mathieu Desnoyers
Quoted 20 lines · Joshua Peisach
Quoted 18 lines · Sasha Levin
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Quoted 6 lines
Quoted 6 lines
I like the concept - but is there any way to ensure that important functions like malloc aren't being patched? Or some way to make sure that what is being patched will not kill the entire kernel?
I know this probably boils down to "operator has to use it correctly", but just wondering if this was considered.
So I thought about it, and realized it would be very difficult to decide on this list of functions, and even more difficult to keep it maintained over time (functions get added, removed, refactored, ...).
Quoted 10 lines
I like the idea too, it should help prevent a few devops burnouts in the coming weeks.
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
Quoted 7 lines
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Why not just use our good old tracing infra? Set tracepoints where ever you want, collect any data you might need, and engage the killswitch when you're happy with the data you have?
It feels a bit weird adding something like this into killswitch.
Signature · 2 lines
Thanks, Sasha
On 2026-05-08 12:13, Sasha Levin wrote:
[...]
Quoted 12 lines
Quoted 12 lines
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.
Quoted 8 lines
Quoted 2 lines
This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Why not just use our good old tracing infra? Set tracepoints where ever you want, collect any data you might need, and engage the killswitch when you're happy with the data you have?
It feels a bit weird adding something like this into killswitch.
It really depends on whether you want to include some basic safety nets directly within killswitch, or leave that entirely to the end user.
I don't have a strong opinion either way. I was just pointing out the feasibility of a pre-soak sanity check before applying the killswitch.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Quoted 21 lines · Mathieu Desnoyers
On 2026-05-08 12:13, Sasha Levin wrote:
[...]Quoted 19 lines
Quoted 7 lines
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
Quoted 7 lines
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Why not just use our good old tracing infra? Set tracepoints where ever you want, collect any data you might need, and engage the killswitch when you're happy with the data you have?
Quoted 7 lines
Quoted 1 line
It feels a bit weird adding something like this into killswitch.
It really depends on whether you want to include some basic safety nets directly within killswitch, or leave that entirely to the end user.
I don't have a strong opinion either way. I was just pointing out the feasibility of a pre-soak sanity check before applying the killswitch.
What about doing this with some userspace tooling (maybe under scripts/) to facilitate this?
Signature · 2 lines
Thanks, Sasha
Quoted 24 lines · Sasha Levin
Quoted 23 lines · Mathieu Desnoyers
On 2026-05-08 12:13, Sasha Levin wrote:
[...]Quoted 20 lines
Quoted 7 lines
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
Quoted 7 lines
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Why not just use our good old tracing infra? Set tracepoints where ever you want, collect any data you might need, and engage the killswitch when you're happy with the data you have?
It feels a bit weird adding something like this into killswitch.
Quoted 9 lines
Quoted 5 lines
It really depends on whether you want to include some basic safety nets directly within killswitch, or leave that entirely to the end user.
I don't have a strong opinion either way. I was just pointing out the feasibility of a pre-soak sanity check before applying the killswitch.
What about doing this with some userspace tooling (maybe under
scripts/) to facilitate this?
That could work, although it requires additional infrastructure to be in place (tracing) on production environments, which may not be the case everywhere. In comparison, if the sanity check is done within killswitch, you only need killswitch and kprobe to be compiled into the production system, which is more lightweight.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Quoted 35 lines · Mathieu Desnoyers
Quoted 24 lines · Sasha Levin
Quoted 23 lines · Mathieu Desnoyers
On 2026-05-08 12:13, Sasha Levin wrote:
[...]Quoted 20 lines
Quoted 7 lines
One possible approach to prevent "footgun" type of killswitch use would be to first apply a statistics collection killswitch handler that does not change the behavior: it checks whether the target function is invoked at all on the system for a given period of time. Then it applies the killswitch if it was not invoked during that period. Overall sequence:
Quoted 7 lines
- pre-soak killswitch for e.g. 30s, checking whether the function is invoked at all. (period would be user-configurable)
- if no calls were detected, engage killswitch, else report failure to the user.This should prevent footguns such as trying to killswitch fork, malloc or other core functions which are inherently required.
Why not just use our good old tracing infra? Set tracepoints where ever you want, collect any data you might need, and engage the killswitch when you're happy with the data you have?
It feels a bit weird adding something like this into killswitch.
Quoted 9 lines
Quoted 5 lines
It really depends on whether you want to include some basic safety nets directly within killswitch, or leave that entirely to the end user.
I don't have a strong opinion either way. I was just pointing out the feasibility of a pre-soak sanity check before applying the killswitch.
What about doing this with some userspace tooling (maybe under
scripts/) to facilitate this?
Quoted 5 lines
That could work, although it requires additional infrastructure to be in place (tracing) on production environments, which may not be the case everywhere. In comparison, if the sanity check is done within killswitch, you only need killswitch and kprobe to be compiled into the production system, which is more lightweight.
So CONFIG_KPROBES but no CONFIG_KPROBES_EVENTS or BPF?
This sounds like a pretty small crowd :)
I think it makes sense to document/script a workflow around tracing or bpftrace, but I don't think it's worth adding all that logic in the kernel.
I'd also note that you can always reverse the killswitch if you observe issues.
Signature · 2 lines
Thanks, Sasha
Andrew Morton
maintainerQuoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/control
It certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Also,
Quoted 1 line
19 files changed, 1451 insertions(+), 1 deletion(-)
wowzers. I'm looking at samples/livepatch/livepatch-sample.c wondering "why"?
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
Quoted 6 lines
Quoted 2 lines
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
Quoted 4 lines
Quoted 1 line
19 files changed, 1451 insertions(+), 1 deletion(-)wowzers. I'm looking at
samples/livepatch/livepatch-sample.cwondering "why"?
Yup, a bit chunky, but over half of it is documentation and testing, and the actual functional code is largely the securityfs interface.
Signature · 2 lines
Thanks, Sasha
Andrew Morton
maintainerQuoted 7 lines · On Fri, 8 May 2026 17:47:04 -0400 Sasha Levin <[email protected]> wrote:
Quoted 4 lines
Quoted 1 line
19 files changed, 1451 insertions(+), 1 deletion(-)wowzers. I'm looking at
samples/livepatch/livepatch-sample.cwondering "why"?Yup, a bit chunky, but over half of it is documentation and testing, and the actual functional code is largely the securityfs interface.
So we can't use livepatch here?
Quoted 11 lines · Andrew Morton
Quoted 7 lines · On Fri, 8 May 2026 17:47:04 -0400 Sasha Levin <[email protected]> wrote:
Quoted 4 lines
Quoted 1 line
19 files changed, 1451 insertions(+), 1 deletion(-)wowzers. I'm looking at
samples/livepatch/livepatch-sample.cwondering "why"?Yup, a bit chunky, but over half of it is documentation and testing, and the actual functional code is largely the securityfs interface.
So we can't use livepatch here?
I might have misunderstood your original question.
Livepatch is great when you have one. The problem is getting one...
To get a livepatch, somebody has to write the fix, build it against the exact kernel you're running (for distros, thats hundreds of different kernel/arch/flavor combinations), sign it, and get it onto every machine.
Most regular users won't be able to do it on their own because of secure boot limitations, so they depend on their vendor to provide them with one.
Yes, you could write a livepatch that just stubs the function out, same end state as killswitch, but you still have to build, sign, and ship a module per kernel to do it
Killswitch would be just a single write to /sys which an ordinary user can do to mitigate a critical issue immediately.
Signature · 2 lines
Thanks, Sasha
Andrew Morton
maintainerQuoted 9 lines · On Fri, 8 May 2026 20:15:00 -0400 Sasha Levin <[email protected]> wrote:
Livepatch is great when you have one. The problem is getting one...
To get a livepatch, somebody has to write the fix, build it against the exact kernel you're running (for distros, thats hundreds of different
kernel/arch/flavorcombinations), sign it, and get it onto every machine.Most regular users won't be able to do it on their own because of secure boot limitations, so they depend on their vendor to provide them with one.
Quoted 6 lines
Yes, you could write a livepatch that just stubs the function out, same end state as killswitch, but you still have to build, sign, and ship a module per kernel to do it
Killswitch would be just a single write to /sys which an ordinary user can do to mitigate a critical issue immediately.
OK, thanks. Worth adding the changelog in case someone else was wondering?
Quoted 12 lines · Sasha Levin
Quoted 11 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/control
Quoted 6 lines
Quoted 3 lines
It certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 26 lines · Breno Leitao
Quoted 12 lines · Sasha Levin
Quoted 11 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlQuoted 6 lines
Quoted 3 lines
It certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
Quoted 7 lines
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Breno Leitao
Quoted 16 lines · Sasha Levin
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
Thanks for the feedback!
Quoted 11 lines
Quoted 10 lines
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 6 lines
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.
"On Debian XX.YY, use the following command to mitigate CVE-AAAA-BBBB:
echo "engage woops -1" > /sys/kernel/security/killswitch/control"
Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
This would definitely help (and in light of how the last couple of weeks played out, the case for livepatches definitely increased), but not all vendors/distros provide livepatches.
My personal usecase is simple: I use debian, with their kernel. I'm not going to get livepatches from debian, and it would take a few days/weeks for a kernel update to land. I want a simple solution that'll let me disable functionality I don't care about.
So I can't use livepatching/fault injection/etc easily.
Signature · 2 lines
Thanks, Sasha
Quoted 45 lines · Sasha Levin
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Breno Leitao
Quoted 16 lines · Sasha Levin
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
Thanks for the feedback!
Quoted 11 lines
Quoted 10 lines
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 6 lines
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
Quoted 2 lines
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.
You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Quoted 10 lines
"On Debian XX.YY, use the following command to mitigate CVE-AAAA-BBBB:
echo "engage woops -1" >
/sys/kernel/security/killswitch/control"Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
Quoted 3 lines
This would definitely help (and in light of how the last couple of weeks played out, the case for livepatches definitely increased), but not all vendors/distros provide livepatches.
The point I've tried to make is that you (as an admin) shouldn't depend on your vendor to provide you with an official LP just to disable a certain function(ality). That is/should be a trivial case where the LP should be ideally generated automagically if you have a tooling available. I might be wrong and overlook some complexity here.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 46 lines · Michal Hocko
Quoted 45 lines · Sasha Levin
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Breno Leitao
Quoted 16 lines · Sasha Levin
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
Thanks for the feedback!
Quoted 17 lines
Quoted 10 lines
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
Quoted 6 lines
Quoted 2 lines
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.
You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Safety checks like making sure the patched function is on the stack, or did you mean something else?
Quoted 14 lines
Quoted 10 lines
"On Debian XX.YY, use the following command to mitigate CVE-AAAA-BBBB:
echo "engage woops -1" >
/sys/kernel/security/killswitch/control"Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
Quoted 3 lines
This would definitely help (and in light of how the last couple of weeks played out, the case for livepatches definitely increased), but not all vendors/distros provide livepatches.
Quoted 5 lines
The point I've tried to make is that you (as an admin) shouldn't depend on your vendor to provide you with an official LP just to disable a certain function(ality). That is/should be a trivial case where the LP should be ideally generated automagically if you have a tooling available. I might be wrong and overlook some complexity here.
Module signing is what stops that approach for me.
Signature · 2 lines
Thanks, Sasha
Quoted 50 lines · Sasha Levin
Quoted 49 lines · Michal Hocko
Quoted 47 lines · Sasha Levin
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Breno Leitao
Quoted 16 lines · Sasha Levin
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
Thanks for the feedback!
Quoted 11 lines
Quoted 10 lines
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 6 lines
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.
Quoted 6 lines
Quoted 3 lines
You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Safety checks like making sure the patched function is on the stack, or did you mean something else?
Yes, exactly what LP infrastructure already provides.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
"On Debian XX.YY, use the following command to mitigate CVE-AAAA-BBBB:
echo "engage woops -1" >
/sys/kernel/security/killswitch/control"Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
This would definitely help (and in light of how the last couple of weeks played out, the case for livepatches definitely increased), but not all vendors/distros provide livepatches.
Quoted 7 lines
Quoted 5 lines
The point I've tried to make is that you (as an admin) shouldn't depend on your vendor to provide you with an official LP just to disable a certain function(ality). That is/should be a trivial case where the LP should be ideally generated automagically if you have a tooling available. I might be wrong and overlook some complexity here.
Module signing is what stops that approach for me.
OK, so the actual constrain here is that you cannot load your own modules. That was not really clear from your description. I assume you cannot enroll your own key and sign?
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 51 lines · Michal Hocko
Quoted 50 lines · Sasha Levin
Quoted 49 lines · Michal Hocko
Quoted 47 lines · Sasha Levin
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Breno Leitao
Quoted 16 lines · Sasha Levin
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Thu, 7 May 2026 03:05:45 -0400 Sasha Levin <[email protected]> wrote:
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlIt certainly sounds useful, but what would I know. How do we hunt down suitable operations people (aka "target audience") to find out how useful this is to them?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm not entierly sure here... If folks have suggestions on folks to loop in, that'll be great!
I work with these issues at Meta, and this approach would address a real need we have.
Thanks for the feedback!
Quoted 11 lines
Quoted 10 lines
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 6 lines
LP is certainly a more laborous solution. I guess this is quite clear. It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Safety checks like making sure the patched function is on the stack, or did you mean something else?
Yes, exactly what LP infrastructure already provides.
But do we actually need it here?
For threads already inside the body when killswitch is engaged: they just keep executing the body to completion.
For threads at entry after the kprobe arms: pre-handler fires, they exit with the override retval, never enter the body.
For threads arriving while the kprobe is being armed: kprobes-on-ftrace uses ftrace's text_poke for atomic arm, so there's no "half-armed" window.
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 10 lines
"On Debian XX.YY, use the following command to mitigate CVE-AAAA-BBBB:
echo "engage woops -1" >
/sys/kernel/security/killswitch/control"Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
Quoted 3 lines
This would definitely help (and in light of how the last couple of weeks played out, the case for livepatches definitely increased), but not all vendors/distros provide livepatches.
The point I've tried to make is that you (as an admin) shouldn't depend on your vendor to provide you with an official LP just to disable a certain function(ality). That is/should be a trivial case where the LP should be ideally generated automagically if you have a tooling available. I might be wrong and overlook some complexity here.
Quoted 5 lines
Quoted 1 line
Module signing is what stops that approach for me.
OK, so the actual constrain here is that you cannot load your own modules. That was not really clear from your description. I assume you cannot enroll your own key and sign?
It's one of them, yes. I don't want to build my own kernel (and assume that most distro users don't build their own kernel), so I can't enroll my own keys.
Outside of that, you would still need to have a patch-per-version (or at least, per group of versions where the patch applies without conflicts).
Signature · 2 lines
Thanks, Sasha
Quoted 12 lines · Sasha Levin
Quoted 11 lines · Michal Hocko
Quoted 10 lines · Sasha Levin
Quoted 8 lines · Michal Hocko
Quoted 3 lines · Sasha Levin
On Mon, May 11, 2026 at 03:07:51PM +0200, Michal Hocko wrote:
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Safety checks like making sure the patched function is on the stack, or did you mean something else?
Yes, exactly what LP infrastructure already provides.
But do we actually need it here?
If not then you can simply systemtap or use BPF to inject the code. In other words we have several ways how to runtime modify the kernel so before yet another interface is provided (with a non-trivial amount of code and very limited functionality) you should really start by describing why none of the existing one is fitting well.
I do understand your argument that solutions based on loading a module might have an additional step to deal with (AFAIK you do not need to build your own kernel to deploy your key) is that a brohibitive roadblock? We also do have fault injection which is much less convenient because of all the existing constraines but can those be elevated?
So nothing really against playing with ideas nad LLMs to generated a quick PoC. That is all good but for this to be considered more seriously I think we really need to think deeper whether the existing infrastructure is really not fitting and if not whether it could be changed to cover more usecase like the one you have mentioned here and I believe it is something worth thinking about.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 32 lines · Michal Hocko
Quoted 12 lines · Sasha Levin
Quoted 11 lines · Michal Hocko
Quoted 10 lines · Sasha Levin
Quoted 8 lines · Michal Hocko
Quoted 3 lines · Sasha Levin
On Mon, May 11, 2026 at 03:07:51PM +0200, Michal Hocko wrote:
In a similar way to how they would know if a given livepatch is safe to apply - ideally it would be communicated by the vendor/distro/kernel team.You have missed my point. KLP takes an extra steps to make sure patching a particular function is safe to modify or to put the change into the effect.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Safety checks like making sure the patched function is on the stack, or did you mean something else?
Yes, exactly what LP infrastructure already provides.
But do we actually need it here?
If not then you can simply systemtap or use BPF to inject the code. In other words we have several ways how to runtime modify the kernel so before yet another interface is provided (with a non-trivial amount of code and very limited functionality) you should really start by describing why none of the existing one is fitting well.
I do understand your argument that solutions based on loading a module might have an additional step to deal with (AFAIK you do not need to build your own kernel to deploy your key) is that a brohibitive roadblock? We also do have fault injection which is much less convenient because of all the existing constraines but can those be elevated?
Quoted 6 lines
So nothing really against playing with ideas nad LLMs to generated a quick PoC. That is all good but for this to be considered more seriously I think we really need to think deeper whether the existing infrastructure is really not fitting and if not whether it could be changed to cover more usecase like the one you have mentioned here and I believe it is something worth thinking about.
Could you describe an existing infrastructure I can use here? Let's look at this recent "Copy Fail" thing as an example.
I can obviously build my own kernel and enroll my own key, but 99.9% of our users won't be doing that.
Livepatching, or manually building a module that just injects a kprobe is out of the question as we previously agreed.
systemtap falls into the same bucket as building my own module.
BPF doesn't help because bpf_override_return() requires the target to be on the same within_error_injection_list() whitelist as fault injection, and the CVE targets never are. Some of our fleet doesn't even have BPF enabled either, but that's the smaller objection.
I can't use fault injection because:
a. It's almost never built in production/distro kernels, and I suspect this
won't change.
b. The functions I need are not whitelisted.
c. Even if (a) and (b) were addressed, fault injection would still need a
securityfs front-end, a cmdline parser, a module-unload notifier, a taint flag, and audit on engage and disengage. By the time those land in fail_function and tie into/refactor the fault injection code, the net diff is bigger than this proposal.
In my case I can remove the module, but not if I run a distro that shipped with CONFIG_CRYPTO_USER_API_AEAD=y (like RHEL/SUSE).
I can use "initcall_blacklist=" hack and reboot, but as things stand today, I'll need to be rebooting few times a day.
Even if I'm okay with rebooting that often (and I really really would prefer not to), this doesn't solve the issues of a larger fleet of servers that can't just reboot that often.
What am I missing?
Signature · 2 lines
Thanks, Sasha
Quoted 1 line · Sasha Levin
Could you describe an existing infrastructure I can use here?
I think it would help to CC maintainers of subsystems that provide kernel modification functionality. They will surely have a better insight than me.
Quoted 7 lines
Let's look at
this recent "Copy Fail" thing as an example.I can obviously build my own kernel and enroll my own key, but 99.9% of our users won't be doing that.
Livepatching, or manually building a module that just injects a kprobe is out of the question as we previously agreed.
Onless I am mistaken you can enroll your own key through MOK. But you are right that this is an additional step. But the real question is whether this is a major road block for users of this specific feature.
Quoted 9 lines
systemtap falls into the same bucket as building my own module.
BPF doesn't help because
bpf_override_return()requires the target to be on the samewithin_error_injection_list()whitelist as fault injection, and the CVE targets never are. Some of our fleet doesn't even have BPF enabled either, but that's the smaller objection.I can't use fault injection because:
Quoted 8 lines
a. It's almost never built in production/distro kernels, and I suspect this
won't change.
b. The functions I need are not whitelisted.
c. Even if (a) and (b) were addressed, fault injection would still need a
securityfs front-end, a cmdline parser, a module-unload notifier, a taint flag, and audit on engage and disengage. By the time those land infail_functionand tie into/refactor the fault injection code, the net diff is bigger than this proposal.
I cannot comment on fault injection imeplementation details of course but I have to say that the whitelist nature is something that makes its use very limited. Maybe this is a good opportunity to change the approach.
Quoted 3 lines
In my case I can remove the module, but not if I run a distro that shipped with
CONFIG_CRYPTO_USER_API_AEAD=y(like RHEL/SUSE).
If you look at copy fail[2], IIRC algif_aead, esp[46] and rxrcp are all modules that could be blacklisted.
Quoted 2 lines
I can use "initcall_blacklist=" hack and reboot, but as things stand today, I'll need to be rebooting few times a day.
with your just disable some functions in the kernel you might need to reboot even more. But more seriously...
Quoted 5 lines
Even if I'm okay with rebooting that often (and I really really would prefer not to), this doesn't solve the issues of a larger fleet of servers that can't just reboot that often.
What am I missing?
For one, you are missing more maintainers of code modification infrastructures.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 10 lines · Michal Hocko
Quoted 1 line · Sasha Levin
Could you describe an existing infrastructure I can use here?
I think it would help to CC maintainers of subsystems that provide kernel modification functionality. They will surely have a better insight than me.
Quoted 3 lines
Let's look at
this recent "Copy Fail" thing as an example.
Quoted 8 lines
Quoted 4 lines
I can obviously build my own kernel and enroll my own key, but 99.9% of our users won't be doing that.
Livepatching, or manually building a module that just injects a kprobe is out of the question as we previously agreed.Onless I am mistaken you can enroll your own key through MOK. But you are right that this is an additional step. But the real question is whether this is a major road block for users of this specific feature.
The roadblock here is that then I need to start owning the kernel package: I need to pull updates, rebuild, reinstall, etc. I lose the support I might be getting from the distro vendor.
I see "users of this particular feature" as the other 99.9% of folks who don't build their own kernel, who follow security updates from their distro vendor and could apply the simple workaround that those vendors could now provide.
Quoted 18 lines
Quoted 9 lines
systemtap falls into the same bucket as building my own module.
BPF doesn't help because
bpf_override_return()requires the target to be on the samewithin_error_injection_list()whitelist as fault injection, and the CVE targets never are. Some of our fleet doesn't even have BPF enabled either, but that's the smaller objection.I can't use fault injection because:
Quoted 8 lines
a. It's almost never built in production/distro kernels, and I suspect this
won't change.
b. The functions I need are not whitelisted.
c. Even if (a) and (b) were addressed, fault injection would still need a
securityfs front-end, a cmdline parser, a module-unload notifier, a taint flag, and audit on engage and disengage. By the time those land infail_functionand tie into/refactor the fault injection code, the net diff is bigger than this proposal.
Quoted 4 lines
I cannot comment on fault injection imeplementation details of course but I have to say that the whitelist nature is something that makes its use very limited. Maybe this is a good opportunity to change the approach.
Possibly, but IMO the bigger hurdle is the refactoring we'll need to do so seperate fail_function out of the fault injection umbrella.
One approach would be to abstract the kprobe logic out of fail_function into a common lib that killswitch could also use, but from a brief look the benefit will be minimal.
Quoted 5 lines
Quoted 2 lines
In my case I can remove the module, but not if I run a distro that shipped with
CONFIG_CRYPTO_USER_API_AEAD=y(like RHEL/SUSE).If you look at copy fail[2], IIRC
algif_aead, esp[46] and rxrcp are all modules that could be blacklisted.
On some distros sure, on some others, not:
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/raw/main/redhat/configs/common/generic/CONFIG_CRYPTO_USER_API_AEAD
Even if it is a module, what if I can't just unload it because I have something that actually uses it?
Look at the ESP issue for example. I can mitigate it by simply doing:
echo "engage xfrm4_udp_encap_rcv 0" > /sys/kernel/security/killswitch/control echo "engage xfrm6_udp_encap_rcv 0" > /sys/kernel/security/killswitch/control
which only kills ESP encapsulated in UDP. The remaining functionality will keep working just fine.
Quoted 6 lines
Quoted 2 lines
I can use "initcall_blacklist=" hack and reboot, but as things stand today, I'll need to be rebooting few times a day.
with your just disable some functions in the kernel you might need to reboot even more. But more seriously...
Quoted 7 lines
Quoted 5 lines
Even if I'm okay with rebooting that often (and I really really would prefer not to), this doesn't solve the issues of a larger fleet of servers that can't just reboot that often.
What am I missing?
For one, you are missing more maintainers of code modification infrastructures.
Happy to add more, but I don't want to be too spammy. I'll add in the livepatching ML and the fault injection maintainer (I couldn't find a list). Please add any other folks/lists who you think might want to contribute to this discussion.
Signature · 2 lines
Thanks, Sasha
On Mon, May 11, 2026 at 02:09:45PM -0400, Sasha Levin wrote:
SNIP
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Even if I'm okay with rebooting that often (and I really really would prefer not to), this doesn't solve the issues of a larger fleet of servers that can't just reboot that often.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What am I missing?
For one, you are missing more maintainers of code modification infrastructures.
Happy to add more, but I don't want to be too spammy. I'll add in the livepatching ML and the fault injection maintainer (I couldn't find a list). Please add any other folks/lists who you think might want to contribute to this discussion.
hi,
could you please add bpf ([email protected]) to the loop?
thanks,
jirka
Hello Michal,
Quoted 14 lines · Michal Hocko
Quoted 6 lines
I work with these issues at Meta, and this approach would address a real need we have.
While livepatch could theoretically solve this problem, it's less suited for rapid mitigation for a couple of reasons:
Quoted 7 lines
1) Livepatch rollout is inherently slower due to the blast radius if a bug exists in the livepatch mechanism itself.
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 7 lines
LP is certainly a more laborous solution. I guess this is quite clear.
It is also much safer option as it deals with all implementation details like consistency. All that is not done for fun. I am really wondering how admins are expected to a) know which kernel functions are ok/safe to disable and b) when it is safe to do so without introducing unsafe kernel state or introduce an outright bug that way.
You raise a valid concern. There's no simple answer. Making these decisions requires deep understanding of both the code and the potential consequences.
The value proposition here (IMO) is the ability to completely disable a code path by returning an error code (such as -EINVAL or -EBUSY) at key entry points, rather than attempting surgical modifications.
While this approach is far from perfect, it can serve as an effective stopgap measure until a proper fix is deployed or a livepatch becomes available.
Quoted 5 lines
Thiking about this I can see how waiting for an official LP can be time consuming and sometimes creating those is far from trivial. But would it make sense to have automated LP creation tooling available that would allow to return early from a function and relly on the existing infrastructure to do the right thing?
Absolutely. I view this as a progression of mitigation strategies, where the ultimate goal is deploying a properly fixed kernel, but reaching that endpoint may require intermediate steps.
1) Fix and deploy a new kernel:
* Pros: Lowest risk, permanent solution
* Cons:
- Requires reboot and extended downtime
2) Livepatch:
* Pros: Complete mitigation, clean approach, zero downtime
* Cons:
- Time-intensive rollout (requires bake time and health checks)
- Demands manual patch creation and review for each kernel version (i.e., kernel developer involvement is essential)
3) This approach (killswitch):
* Pros: Immediate deployment capability
- Security engineers familiar with kernel code can act independently
* Cons:
- Risk of instability if the operator misjudges the impact
In short, I see killswitch as a complementary tool in the security toolbox, not a universal solution.
--breno
Andrew Morton
maintainerQuoted 6 lines · On Mon, 11 May 2026 15:07:51 +0200 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
LP is certainly a more laborous solution.
<another please-educate-akpm email>
Does a livepatch *have* to be distributed as a ready-to-load kernel module?
Is it not possible to distribute a "livepatch" to the fleet as a single string? Send out "make function some_bad_function() return -EINVAL" and let scripting on each machine figure out how to locally write, build, sign and install such a livepatch?
That would require that each machine locally contains enough data for it to be able to build a kernel for the currently-running kernel, and that each machine contains a build environment.
I *think* this is feasible on distro-based machines? But perhaps not on stripped-down hyperscalar boxen?
Song Liu
maintainerQuoted 8 lines · Andrew Morton
Quoted 5 lines · On Mon, 11 May 2026 15:07:51 +0200 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
Quoted 6 lines
Quoted 1 line
LP is certainly a more laborous solution.
<another please-educate-akpm email>
Does a livepatch *have* to be distributed as a ready-to-load kernel module?
As of today, livepatch is loaded to the kernel as a module. It requires kernel config CONFIG_LIVEPATCH. If CONFIG_LIVEPATCH is not set in the running kernel, livepatch module won't work.
Quoted 4 lines
Is it not possible to distribute a "livepatch" to the fleet as a single string? Send out "make function
some_bad_function()return-EINVAL" and let scripting on each machine figure out how to locally write, build, sign and install such a livepatch?
With CONFIG_LIVEPATCH, and with proper toolchain and keys, this is surely possible. But I guess this comes with some security concerns (sharing the keys, etc.).
Quoted 6 lines
That would require that each machine locally contains enough data for it to be able to build a kernel for the currently-running kernel, and that each machine contains a build environment.
I *think* this is feasible on distro-based machines? But perhaps not on stripped-down hyperscalar boxen?
Do most distro machines have CONFIG_LIVEPATCH enabled? AFAICT, Ubuntu 26.04 does have it enabled.
Thanks,
Song
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Mon, 11 May 2026 15:07:51 +0200 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
2) It's common to run hundreds of different kernel versions across a fleet. Since livepatch is kernel-specific, a single CVE suddenly requires building and deploying hundreds of individual livepatches— far less practical than a simple sysfs write.
LP is certainly a more laborous solution.
<another please-educate-akpm email>
Does a livepatch *have* to be distributed as a ready-to-load kernel module?
Quoted 8 lines
Is it not possible to distribute a "livepatch" to the fleet as a single string? Send out "make function
some_bad_function()return-EINVAL" and let scripting on each machine figure out how to locally write, build, sign and install such a livepatch?That would require that each machine locally contains enough data for it to be able to build a kernel for the currently-running kernel, and that each machine contains a build environment.
So we'll need to have a kernel build env, the sources for the current kernel, debug info, and some sort of a semantic patch (.cocci?) to make the transformation. I think we could even script all of that per-distro, yes.
Quoted 2 lines
I *think* this is feasible on distro-based machines? But perhaps not on stripped-down hyperscalar boxen?
Few concerns:
1. Tiny/embedded machines that will have a really hard time building a kernel either because of storage, CPU power, etc... Consider something like your home router running OpenWRT.
Actually, this is a good example for a killswitch too I think. I went digging for issues that would affect OpenWRT routers, and
https://www.cve.org/CVERecord?id=CVE-2024-1086 is a good example: OpenWRT supports user namespaces to allow containers to run on the router, so any container could then compromise the router.
There's no way to build kernel modules on the router - no toolchain nor storage.
With killswitch, you could simply do something like:
echo "engage nft_verdict_init -1" > /sys/kernel/security/killswitch/control
Which, if I understand the code correctly, would disable us from adding any new netfilter rules, but existing rules would keep working (and on most routers the rules are fairly static).
2. Having to install a build env is not only wasteful but also not secure. For example, a certain hyperscaler we both know does not allow compilers on production machines. It's probably a good practice for regular distro based machines too.
3. With secure boot a user can't load their own unsigned modules, so the user will need to spin their own kernel and enroll their keys. Having to turn off secure boot is a really bad solution too.
4. Nightmare as far as reproducibility goes: think of all the odd compiler/toolchain/etc combos you'll encounter. No way to track what went wrong, where, and how.
Signature · 2 lines
Thanks, Sasha
Paul Moore
maintainerQuoted 46 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Assisted-by Claude:claude-opus-4-7Signed-off-by Sasha Levin <[email protected]>--- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/killswitch.rst | 159 ++++ Documentation/admin-guide/tainted-kernels.rst | 8 + MAINTAINERS | 11 + include/linux/killswitch.h | 19 + include/linux/panic.h | 3 +- init/Kconfig | 2 + kernel/Kconfig.killswitch | 31 + kernel/Makefile | 1 + kernel/killswitch.c | 798 ++++++++++++++++++ kernel/panic.c | 1 + lib/Kconfig.debug | 13 + lib/Makefile | 1 + lib/test_killswitch.c | 85 ++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/killswitch/.gitignore | 1 + tools/testing/selftests/killswitch/Makefile | 8 + .../selftests/killswitch/cve_31431_test.c | 162 ++++ .../selftests/killswitch/killswitch_test.sh | 147 ++++ 19 files changed, 1451 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/killswitch.rst
Quoted 8 lines
create mode 100644 include/linux/killswitch.h create mode 100644 kernel/Kconfig.killswitch create mode 100644 kernel/killswitch.c create mode 100644 lib/test_killswitch.c create mode 100644 tools/testing/selftests/killswitch/.gitignore create mode 100644 tools/testing/selftests/killswitch/Makefile create mode 100644 tools/testing/selftests/killswitch/cve_31431_test.c create mode 100755 tools/testing/selftests/killswitch/killswitch_test.sh
If we made Lockdown an LSM, we should probably also make killswitch an LSM.
For the LSM crowd who might be seeing this for the first time, the original thread can be found on lore via the link below:
https://lore.kernel.org/all/[email protected]
Signature · 1 line
paul-moore.com
Song Liu
maintainerQuoted 57 lines · Paul Moore
Quoted 46 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Assisted-by Claude:claude-opus-4-7Signed-off-by Sasha Levin <[email protected]>--- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/killswitch.rst | 159 ++++ Documentation/admin-guide/tainted-kernels.rst | 8 + MAINTAINERS | 11 + include/linux/killswitch.h | 19 + include/linux/panic.h | 3 +- init/Kconfig | 2 + kernel/Kconfig.killswitch | 31 + kernel/Makefile | 1 + kernel/killswitch.c | 798 ++++++++++++++++++ kernel/panic.c | 1 + lib/Kconfig.debug | 13 + lib/Makefile | 1 + lib/test_killswitch.c | 85 ++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/killswitch/.gitignore | 1 + tools/testing/selftests/killswitch/Makefile | 8 + .../selftests/killswitch/cve_31431_test.c | 162 ++++ .../selftests/killswitch/killswitch_test.sh | 147 ++++ 19 files changed, 1451 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/killswitch.rstQuoted 8 lines
create mode 100644 include/linux/killswitch.h create mode 100644 kernel/Kconfig.killswitch create mode 100644 kernel/killswitch.c create mode 100644 lib/test_killswitch.c create mode 100644 tools/testing/selftests/killswitch/.gitignore create mode 100644 tools/testing/selftests/killswitch/Makefile create mode 100644 tools/testing/selftests/killswitch/cve_31431_test.c create mode 100755 tools/testing/selftests/killswitch/killswitch_test.sh
Quoted 1 line
If we made Lockdown an LSM, we should probably also make killswitch an LSM.
I don't think killswitch can stack with other LSMs. In fact, killswitch can be used to bypass other LSMs, for example:
echo engage security_file_open 0 > /sys/kernel/security/killswitch/control
will bypass all hooks on security_file_open.
Thanks,
Song
Quoted 7 lines
For the LSM crowd who might be seeing this for the first time, the original thread can be found on lore via the link below:
https://lore.kernel.org/all/[email protected]--
paul-moore.com
Paul Moore
maintainerQuoted 57 lines · Song Liu
Quoted 56 lines · Paul Moore
Quoted 54 lines · Sasha Levin
When a (security) issue goes public, fleets stay exposed until a patched kernel is built, distributed, and rebooted into.
For many such issues the simplest mitigation is to stop calling the buggy function. Killswitch provides that. An admin writes:
echo "engage af_alg_sendmsg -1" \ > /sys/kernel/security/killswitch/controlAfter this,
af_alg_sendmsg()returns-EPERMon every call without running its body. The mitigation takes effect immediately, and is dropped on the next reboot.A lot of recent kernel issues sit in code paths most installs only have enabled to support a relative minority of users:
AF_ALG, ksmbd,nf_tables, vsock, ax25, and friends.For most users, the cost of "this socket family stops working for the day" is much smaller than the cost of running a known vulnerable kernel until the fix land.
Assisted-by Claude:claude-opus-4-7Signed-off-by Sasha Levin <[email protected]>--- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/killswitch.rst | 159 ++++ Documentation/admin-guide/tainted-kernels.rst | 8 + MAINTAINERS | 11 + include/linux/killswitch.h | 19 + include/linux/panic.h | 3 +- init/Kconfig | 2 + kernel/Kconfig.killswitch | 31 + kernel/Makefile | 1 + kernel/killswitch.c | 798 ++++++++++++++++++ kernel/panic.c | 1 + lib/Kconfig.debug | 13 + lib/Makefile | 1 + lib/test_killswitch.c | 85 ++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/killswitch/.gitignore | 1 + tools/testing/selftests/killswitch/Makefile | 8 + .../selftests/killswitch/cve_31431_test.c | 162 ++++ .../selftests/killswitch/killswitch_test.sh | 147 ++++ 19 files changed, 1451 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/killswitch.rst create mode 100644 include/linux/killswitch.h create mode 100644 kernel/Kconfig.killswitch create mode 100644 kernel/killswitch.c create mode 100644 lib/test_killswitch.c create mode 100644 tools/testing/selftests/killswitch/.gitignore create mode 100644 tools/testing/selftests/killswitch/Makefile create mode 100644 tools/testing/selftests/killswitch/cve_31431_test.c create mode 100755 tools/testing/selftests/killswitch/killswitch_test.sh
Quoted 8 lines
Quoted 1 line
If we made Lockdown an LSM, we should probably also make killswitch an LSM.
I don't think killswitch can stack with other LSMs. In fact, killswitch can be used to bypass other LSMs, for example:
echo engage
security_file_open0 >/sys/kernel/security/killswitch/controlwill bypass all hooks on
security_file_open.
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing capable() and friends?
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of NOKPROBE_SYMBOL() which I think would be an unfortunate casualty.
Signature · 1 line
paul-moore.com
Song Liu
maintainerOn Mon, May 18, 2026 at 2:29 PM Paul Moore <[email protected]> wrote:
[...]
Quoted 12 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
I don't think we can use NOKPROBE_SYMBOL(). There are functions that we don't want to killswitch, but still want to trace.
Thanks,
Song
Paul Moore
maintainerQuoted 21 lines · Song Liu
On Mon, May 18, 2026 at 2:29 PM Paul Moore <[email protected]> wrote:
[...]Quoted 12 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Quoted 2 lines
I don't think we can use
NOKPROBE_SYMBOL(). There are functions that we don't want to killswitch, but still want to trace.
That was exactly my point, but we need to figure something out so killswitch doesn't make it easier to cause a regression.
Signature · 1 line
paul-moore.com
Song Liu
maintainerQuoted 23 lines · Paul Moore
Quoted 21 lines · Song Liu
On Mon, May 18, 2026 at 2:29 PM Paul Moore <[email protected]> wrote:
[...]Quoted 18 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Quoted 5 lines
Quoted 2 lines
I don't think we can use
NOKPROBE_SYMBOL(). There are functions that we don't want to killswitch, but still want to trace.That was exactly my point, but we need to figure something out so killswitch doesn't make it easier to cause a regression.
killswitch is making it easier to fix a CVE. It can surely make it easier to cause a regression. AFAICT, the only protection here is "it is only for root".
Thanks,
Song
Paul Moore
maintainerQuoted 26 lines · Song Liu
Quoted 25 lines · Paul Moore
Quoted 23 lines · Song Liu
On Mon, May 18, 2026 at 2:29 PM Paul Moore <[email protected]> wrote:
[...]Quoted 12 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.I don't think we can use
NOKPROBE_SYMBOL(). There are functions that we don't want to killswitch, but still want to trace.
Quoted 6 lines
Quoted 2 lines
That was exactly my point, but we need to figure something out so killswitch doesn't make it easier to cause a regression.
killswitch is making it easier to fix a CVE. It can surely make it easier to cause a regression. AFAICT, the only protection here is "it is only for root".
As I mentioned earlier, several LSMs have the ability to restrict root beyond what is possible with traditional Linux accesscontrols. For example, with SELinux one could deny root a specific privilege while also blocking changes to the SELinux policy; the root user would not be able to restore that privilege without rebooting the system.
On a killswitch enabled system the ability to restrict root is lost as root would be able to kill the enforcement of those access controls. Presumably one could have the LSM block access to killswitch in this particular case, but that defeats the purpose doesn't it?
The audit subsystem also has a somewhat similar one-way configuration lock, which when set does not allow even root to unlock it, a reboot is required. By a bit of luck with regards to how the code is written*, it may not be vulnerable to a killswitch regression but I do wonder if there are other similar things in the kernel which would have the same type of problem.
* This is probably the first time I think I've ever considered myself lucky with respect to the audit code implementation.
Signature · 1 line
paul-moore.com
Quoted 22 lines · Paul Moore
Quoted 21 lines · Song Liu
On Mon, May 18, 2026 at 2:29 PM Paul Moore <[email protected]> wrote:
[...]Quoted 18 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Quoted 5 lines
Quoted 2 lines
I don't think we can use
NOKPROBE_SYMBOL(). There are functions that we don't want to killswitch, but still want to trace.That was exactly my point, but we need to figure something out so killswitch doesn't make it easier to cause a regression.
At this point it sounds like you're trying to stop root from shooting itself in the foot, which we always avoided doing.
killswitch doesn't add any new functionality in that regard: rood can always load a module, write to /dev/mem, etc which would allow it to do the same thing. It's just a more convenient way to do it.
Signature · 2 lines
Thanks, Sasha
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?
killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
Quoted 6 lines
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
killswitch "complies" with lockdown. Is there a different scenario which we should be blocking?
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Why? If I don't really mind the security impact, I want to be able to have a killswitch-like interface on my systems. If an attacker is in my systems, killswitch is the least of my concerns I think.
If you are security concious, just don't enable CONFIG_KILLSWITCH?
Signature · 2 lines
Thanks, Sasha
Paul Moore
maintainerQuoted 8 lines · Sasha Levin
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
As I mentioned previously, there are cases where we can restrict root's privileges today, but a functional killswitch would allow that restriction to be bypassed. My last email to Song has an example with SELinux.
Quoted 8 lines
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
I don't see any LSM hooks in this revision of killswitch, and as long as it is based on a kprobes I can't imagine it would ever use any. As I mentioned above, my killswitch-as-a-LSM comment is primarily about killswitch filling a role very similar to Lockdown.
Quoted 9 lines
Quoted 6 lines
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
killswitch "complies" with lockdown. Is there a different scenario which we should be blocking?
See the SELinux example I mentioned in my email to Song.
Quoted 7 lines
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Quoted 5 lines
Why? If I don't really mind the security impact, I want to be able to have a killswitch-like interface on my systems. If an attacker is in my systems, killswitch is the least of my concerns I think.
If you are security concious, just don't enable
CONFIG_KILLSWITCH?
Isn't the whole point of killswitch to have it enabled everywhere because you never know when you might want/need it?
Signature · 1 line
paul-moore.com
Quoted 7 lines · Paul Moore
Quoted 6 lines · Sasha Levin
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?
Quoted 7 lines
Quoted 2 lines
killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
As I mentioned previously, there are cases where we can restrict root's privileges today, but a functional killswitch would allow that restriction to be bypassed. My last email to Song has an example with SELinux.
This would be handled by just disabling killswitch in those scenarios like how we do with lockdown, no?
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Quoted 8 lines
Quoted 3 lines
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
I don't see any LSM hooks in this revision of killswitch, and as long as it is based on a kprobes I can't imagine it would ever use any. As I mentioned above, my killswitch-as-a-LSM comment is primarily about killswitch filling a role very similar to Lockdown.
My question was more about how to structure killswitch as an LSM. I want to be able to poke at pretty much any function in the kernel, rather than restrict access to a known list of functions.
Quoted 19 lines
Quoted 9 lines
Quoted 6 lines
The use of kprobes, while an interesting idea, presents problems as allowing any kernel symbol to be killed introduces the potential for security regressions. As a reminder, some LSMs, as well as other kernel subsystems, have mechanisms in place to restrict root and/or enforce one-way configuration locks; while many people equate "root" with full control, in many cases today that is not strictly correct.
killswitch "complies" with lockdown. Is there a different scenario which we should be blocking?
See the SELinux example I mentioned in my email to Song.
Quoted 7 lines
Quoted 6 lines
Yes, kprobes have been around for some time, this is not a new problem, but killswitch makes it far more convenient and accessible to do dangerous things with kprobes. If killswitch makes it past the RFC stage without any significant changes to its kill mechanism, we may need to start considering more liberal usage of
NOKPROBE_SYMBOL()which I think would be an unfortunate casualty.
Quoted 8 lines
Quoted 5 lines
Why? If I don't really mind the security impact, I want to be able to have a killswitch-like interface on my systems. If an attacker is in my systems, killswitch is the least of my concerns I think.
If you are security concious, just don't enable
CONFIG_KILLSWITCH?Isn't the whole point of killswitch to have it enabled everywhere because you never know when you might want/need it?
Right. We have different usecases. If you want selinux/lockdown/etc and a really crippled root, that should be an option. If you choose to allow something like killswitch, it should be an option too.
Signature · 2 lines
Thanks, Sasha
Paul Moore
maintainerQuoted 11 lines · Sasha Levin
Quoted 10 lines · Paul Moore
Quoted 8 lines · Sasha Levin
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
Quoted 7 lines
Quoted 4 lines
As I mentioned previously, there are cases where we can restrict root's privileges today, but a functional killswitch would allow that restriction to be bypassed. My last email to Song has an example with SELinux.
This would be handled by just disabling killswitch in those scenarios like how we do with lockdown, no?
One could presumably deny access to killswitch, but that pushes the burden of choice onto the users/admins. Yes, that is the easy way to solve thorny use case conflicts like this, but it would be nice if we could do better for those who have to deal with this in the wild.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
Quoted 8 lines
Quoted 4 lines
I don't see any LSM hooks in this revision of killswitch, and as long as it is based on a kprobes I can't imagine it would ever use any. As I mentioned above, my killswitch-as-a-LSM comment is primarily about killswitch filling a role very similar to Lockdown.
My question was more about how to structure killswitch as an LSM. I want to be able to poke at pretty much any function in the kernel, rather than restrict access to a known list of functions.
Well, like I said in my last reply to you, I can't imagine a kprobes based killswitch would need to worry about the LSM hooks. Structuring killswitch as an LSM would be mostly a few lines of code to register it as an LSM and that's about it. Benefits would be minor, and likely a matter of opinion, it's mostly about how we view something like killswitch in the kernel. If we view it as a security mechanism similar to lockdown, then it makes sense as a LSM, if we view this as a completely different thing then it can be whatever it wants to be.
Signature · 1 line
paul-moore.com
Song Liu
maintainerQuoted 10 lines · Sasha Levin
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
Quoted 8 lines
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
There are much fewer LSM hooks than ftrace-able (killswitch-able) functions. In this sense, killswitch is more granular. However, LSM hooks allow LSM policies to make different decisions for different arguments. In this sense, LSM hooks are more granular than killswitch, as killswitch can only set a fixed return value for each engaged function.
With current LSM solutions, we can mitigate issues like Copy Fail without breaking other features of the system. In [1], Cloudflare shared how they mitigate Copy Fail with BPF LSM.
Thanks,
Song
[1] https://blog.cloudflare.com/copy-fail-linux-vulnerability-mitigation/
Paul Moore
maintainerQuoted 16 lines · Song Liu
Quoted 15 lines · Sasha Levin
Quoted 4 lines · Paul Moore
From my perspective there are two different issues here: should killswitch be a LSM, and should killswitch leverage kprobes to be able to "kill" security related symbols. After all, are we okay with killswitch killing
capable()and friends?killswitch doesn't do it on it's own. It may be instructed by root to do that, at which point that is root's problem.
Quoted 4 lines
In my opinion, making killswitch an LSM is more of a procedural item that deals with how we view a capability like killswitch. I personally view killswitch as somewhat similar to Lockdown, which is why I made the suggestion.
Quoted 6 lines
Quoted 3 lines
Maybe I'm not all that familiar with LSMs, but we would need to be able to stop "random" code paths from executing, and I don't think we can create LSM hooks at that granularity, no?
There are much fewer LSM hooks than ftrace-able (killswitch-able) functions. In this sense, killswitch is more granular.
I don't know if I would say it is necessarily more granular as its ability to filter access is limited to a breakpoint set on a symbol, but killswitch definitely has a larger quantity of control points.
Quoted 5 lines
However, LSM
hooks allow LSM policies to make different decisions for different arguments. In this sense, LSM hooks are more granular than killswitch, as killswitch can only set a fixed return value for each engaged function.
Yes, I think we agree here.
Quoted 3 lines
With current LSM solutions, we can mitigate issues like Copy Fail without breaking other features of the system. In [1], Cloudflare shared how they mitigate Copy Fail with BPF LSM.
... and Android has been shown to not be vulnerable in the first place due to their use of SELinux and a well crafted SELinux policy.
Signature · 1 line
paul-moore.com