panic: lib: Add TAINT for FAULT_INJECTION
Subsystems (2)
RFC PATCH 1/1 panic: lib: Add TAINT for FAULT_INJECTION
From: Steven Rostedt <[email protected]>
There's been several times where syzbot reports a bug that was caused by a fault injection, but it doesn't report this fact in its email reports. The bug report could happen in code that wasn't involved with the fault injection due to the code that faulted not cleaning up things properly, leading to an unstable kernel, which in turn can trigger issues elsewhere that doesn't have a bug (much like a proprietary module could do).
It would be very useful if the syzbot report notified the developer that the test had injected faults into the kernel.
Introduce a new taint flag 'V' that gets set when a fault injection takes place. (Note, there's not many taint flags left, so 'V' looked as good as any other value).
This will let the syzbot see that the kernel had a fault injection during the test and can report that it happened when sending out its emails.
It may also be useful for other bug reports.
---
[
Currently this keeps lockdep enabled. Should lockdep be turned off too?
Also, I'm surprised that fault injection didn't already taint the kernel.
]
include/linux/panic.h | 3 ++- kernel/panic.c | 1 + lib/fault-inject.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-)
include/linux/panic.h +2 -1
@@ -75,7 +75,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_FAULT_INJECTION 20 +#define TAINT_FLAGS_COUNT 21#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)struct taint_flag {
kernel/panic.c +1 -0
@@ -512,6 +512,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {TAINT_FLAG (RANDSTRUCT ,'T' ,' ' , true),TAINT_FLAG (TEST ,'N' ,' ' , true),TAINT_FLAG (FWCTL ,'J' ,' ' , true), + TAINT_FLAG(FAULT_INJECTION, 'V', ' ', false), };#undef TAINT_FLAG
lib/fault-inject.c +3 -0
@@ -176,6 +176,9 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)if (atomic_read (&attr->times) !=-1 )atomic_dec_not_zero (&attr->times); +pr_notice_once ("Tainting kernel with TAINT_FAULT_INJECTION\n" ); +add_taint (TAINT_FAULT_INJECTION ,LOCKDEP_STILL_OK ); +return true; }
Signature · 1 line
2.47.2
Andrew Morton
maintainerQuoted 12 lines · On Thu, 10 Apr 2025 14:43:59 -0400 Steven Rostedt <[email protected]> wrote:
From: Steven Rostedt <[email protected]>
There's been several times where syzbot reports a bug that was caused by a fault injection, but it doesn't report this fact in its email reports. The bug report could happen in code that wasn't involved with the fault injection due to the code that faulted not cleaning up things properly, leading to an unstable kernel, which in turn can trigger issues elsewhere that doesn't have a bug (much like a proprietary module could do).
It would be very useful if the syzbot report notified the developer that the test had injected faults into the kernel.
Quoted 8 lines
Introduce a new taint flag 'V' that gets set when a fault injection takes place. (Note, there's not many taint flags left, so 'V' looked as good as any other value).
This will let the syzbot see that the kernel had a fault injection during the test and can report that it happened when sending out its emails.
It may also be useful for other bug reports.
Seems sane. Does any userspace tooling need an update for this?
lib/fault-inject.c bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) · line 180
Quoted 8 lines
lib/fault-inject.c +2
-0@@ -176,6 +176,9 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)if (atomic_read (&attr->times) !=-1 )atomic_dec_not_zero (&attr->times); +pr_notice_once ("Tainting kernel with TAINT_FAULT_INJECTION\n" ); +add_taint (TAINT_FAULT_INJECTION ,LOCKDEP_STILL_OK );
if (pr_notice_once("Tainting kernel with TAINT_FAULT_INJECTION\n"))
add_taint(TAINT_FAULT_INJECTION, LOCKDEP_STILL_OK);perhaps?
Quoted 5 lines
lib/fault-inject.c +0
-0return true; }Signature · 1 line
2.47.2
Quoted 3 lines · On Thu, 10 Apr 2025 13:51:14 -0700 Andrew Morton <[email protected]>…
Quoted 1 line
It may also be useful for other bug reports.
Seems sane. Does any userspace tooling need an update for this?
Well, the syzbot does show the taints in their reports. It can use that to explicitly state that the kernel has fault injections, or at least the developer can see the taint.
Quoted 7 lines
Quoted 7 lines
lib/fault-inject.c +0
-0@@ -176,6 +176,9 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)if (atomic_read (&attr->times) !=-1 )atomic_dec_not_zero (&attr->times);
Quoted 7 lines
lib/fault-inject.c bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) · line 180
Quoted 2 lines
lib/fault-inject.c +2
-0+pr_notice_once ("Tainting kernel with TAINT_FAULT_INJECTION\n" ); +add_taint (TAINT_FAULT_INJECTION ,LOCKDEP_STILL_OK );if (pr_notice_once("Tainting kernel with TAINT_FAULT_INJECTION\n")) add_taint(TAINT_FAULT_INJECTION, LOCKDEP_STILL_OK);perhaps?
I'm fine with that too. I can send a v2.
-- Steve
Quoted 4 lines
Quoted 4 lines
lib/fault-inject.c +0
-0return true; }