[PATCH V4 2/2] blktrace: allow access trace file in lockdown mode

From: Junxiao Bi
Date: Thu Apr 20 2023 - 17:54:01 EST


blktrace trace files are per-cpu relay files that are used by kernel to
export IO metadata(IO events, type, target disk, offset and len etc.) to
userspace, no data from IO itself will be exported. Bypass lockdown for
these files will make blktrace work in lockdown mode.

Signed-off-by: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
---
kernel/trace/blktrace.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d5d94510afd3..e1a9f8b7d710 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -490,10 +490,16 @@ static struct dentry *blk_create_buf_file_callback(const char *filename,
&relay_file_operations);
}

+static bool blk_bypass_lockdown(struct inode *inode)
+{
+ return true;
+}
+
static const struct rchan_callbacks blk_relay_callbacks = {
.subbuf_start = blk_subbuf_start_callback,
.create_buf_file = blk_create_buf_file_callback,
.remove_buf_file = blk_remove_buf_file_callback,
+ .bypass_lockdown = blk_bypass_lockdown,
};

static void blk_trace_setup_lba(struct blk_trace *bt,
--
2.24.3 (Apple Git-128)