From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Borislav Petkov <bp@alien8.de>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <keescook@chromium.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
KP Singh <kpsingh@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Florent Revest <revest@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Christoph Hellwig <hch@infradead.org>, Chris Mason <clm@meta.com>
Subject: [RFC PATCH] panic: Add new taint flag for fault injection
Date: Fri, 2 Dec 2022 01:37:13 +0900 [thread overview]
Message-ID: <166991263326.311919.16890937584677289681.stgit@devnote3> (raw)
In-Reply-To: <20221201234121.8925fdf83115747ac4ac116a@kernel.org>
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Since the function error injection framework in the fault injection
subsystem can change the function code flow forcibly, it may cause
unexpected behavior (but that is the purpose of this feature).
To identify this in the kernel oops message, add a new taint flag
for this, and set it if it is (and similar things in BPF) used.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
include/linux/panic.h | 3 ++-
kernel/fail_function.c | 2 ++
kernel/panic.c | 1 +
kernel/trace/bpf_trace.c | 2 ++
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index c7759b3f2045..2b03a02d86be 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -69,7 +69,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
#define TAINT_AUX 16
#define TAINT_RANDSTRUCT 17
#define TAINT_TEST 18
-#define TAINT_FLAGS_COUNT 19
+#define TAINT_FAULT_INJECTED 19
+#define TAINT_FLAGS_COUNT 20
#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)
struct taint_flag {
diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index a7ccd2930c5f..80a743f14a2c 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -9,6 +9,7 @@
#include <linux/kprobes.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/panic.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
@@ -298,6 +299,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
fei_attr_free(attr);
goto out;
}
+ add_taint(TAINT_FAULT_INJECTED, LOCKDEP_NOW_UNRELIABLE);
fei_debugfs_add_attr(attr);
list_add_tail(&attr->list, &fei_attr_list);
ret = count;
diff --git a/kernel/panic.c b/kernel/panic.c
index da323209f583..e396a5fd9bb6 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -426,6 +426,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
[ TAINT_AUX ] = { 'X', ' ', true },
[ TAINT_RANDSTRUCT ] = { 'T', ' ', true },
[ TAINT_TEST ] = { 'N', ' ', true },
+ [ TAINT_FAULT_INJECTED ] = { 'J', ' ', false },
};
/**
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 1ed08967fb97..de0614d9796c 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -2137,6 +2137,8 @@ int perf_event_attach_bpf_prog(struct perf_event *event,
goto unlock;
/* set the new array to event->tp_event and set event->prog */
+ if (prog->kprobe_override)
+ add_taint(TAINT_FAULT_INJECTED, LOCKDEP_NOW_UNRELIABLE);
event->prog = prog;
event->bpf_cookie = bpf_cookie;
rcu_assign_pointer(event->tp_event->prog_array, new_array);
next prev parent reply other threads:[~2022-12-01 16:37 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 15:44 [PATCH] error-injection: Add prompt for function error injection Steven Rostedt
2022-11-21 19:32 ` Borislav Petkov
2022-11-21 23:36 ` Alexei Starovoitov
2022-11-22 0:09 ` Masami Hiramatsu
2022-11-22 0:24 ` Steven Rostedt
2022-11-22 0:40 ` Steven Rostedt
2022-11-22 10:39 ` Borislav Petkov
2022-11-22 17:42 ` Chris Mason
2022-11-22 18:16 ` Borislav Petkov
2022-11-22 18:29 ` Steven Rostedt
2022-11-22 19:51 ` Chris Mason
2022-11-30 22:37 ` Andrew Morton
2022-12-01 16:58 ` Alexei Starovoitov
2022-12-01 17:39 ` Benjamin Tissoires
2022-12-01 21:12 ` Andrew Morton
2022-12-01 21:13 ` Linus Torvalds
2022-12-02 0:46 ` Jiri Kosina
2022-12-02 0:57 ` Linus Torvalds
2022-12-02 1:03 ` Jiri Kosina
2022-12-02 1:32 ` Steven Rostedt
2022-12-02 1:41 ` Alexei Starovoitov
2022-12-02 15:56 ` Theodore Ts'o
2022-12-02 21:27 ` Alexei Starovoitov
2022-12-02 23:17 ` Steven Rostedt
2022-12-03 0:55 ` Alexei Starovoitov
2022-12-04 22:50 ` Masami Hiramatsu
2022-12-06 2:05 ` Alexei Starovoitov
2022-12-02 14:55 ` Benjamin Tissoires
2022-12-02 19:30 ` Alexei Starovoitov
2022-12-05 17:01 ` Benjamin Tissoires
2022-12-01 14:41 ` Masami Hiramatsu
2022-12-01 16:37 ` Masami Hiramatsu (Google) [this message]
2022-12-01 16:39 ` [RFC PATCH] panic: Add new taint flag for fault injection Kees Cook
2022-12-01 16:48 ` Steven Rostedt
2022-12-01 16:53 ` Kees Cook
2022-12-01 19:14 ` Steven Rostedt
2022-12-01 21:00 ` Chris Mason
2022-12-01 21:18 ` Linus Torvalds
2022-12-02 6:17 ` Christoph Hellwig
2022-12-01 21:25 ` Steven Rostedt
2022-12-01 21:29 ` Steven Rostedt
2022-12-02 0:46 ` Masami Hiramatsu
2022-12-01 16:40 ` Steven Rostedt
2022-11-21 22:24 ` [PATCH] error-injection: Add prompt for function error injection Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=166991263326.311919.16890937584677289681.stgit@devnote3 \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=bp@alien8.de \
--cc=clm@meta.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=revest@chromium.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox