FAILED: patch "[PATCH] lsm,io_uring: add LSM hooks for the new uring_cmd file op" failed to apply to 5.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Possible dependencies:
2a5840124009 ("lsm,io_uring: add LSM hooks for the new uring_cmd file op") 99f15d8d6136 ("io_uring: move uring_cmd handling to its own file") cd40cae29ef8 ("io_uring: split out open/close operations") 453b329be5ea ("io_uring: separate out file table handling code") f4c163dd7d4b ("io_uring: split out fadvise/madvise operations") 0d5847274037 ("io_uring: split out fs related sync/fallocate functions") 531113bbd5bf ("io_uring: split out splice related operations") 11aeb71406dd ("io_uring: split out filesystem related operations") e28683bdfc2f ("io_uring: move nop into its own file") 5e2a18d93fec ("io_uring: move xattr related opcodes to its own file") 97b388d70b53 ("io_uring: handle completions in the core") de23077eda61 ("io_uring: set completion results upfront") e27f928ee1cb ("io_uring: add io_uring_types.h")4d4c9cff4f70 ("io_uring: define a request type cleanup handler") 890968dc0336 ("io_uring: unify struct io_symlink and io_hardlink") 9a3a11f977f9 ("io_uring: convert iouring_cmd to io_cmd_type") ceb452e1b4ba ("io_uring: convert xattr to use io_cmd_type") ea5af87d29cf ("io_uring: convert rsrc_update to io_cmd_type") c1ee55950155 ("io_uring: convert msg and nop to io_cmd_type") 2511d3030c5e ("io_uring: convert splice to use io_cmd_type")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2a5840124009f133bd09fd855963551fb2cefe22 Mon Sep 17 00:00:00 2001
From: Luis Chamberlain <[email protected]>
Date: Fri, 15 Jul 2022 12:16:22 -0700
Subject: [PATCH] lsm,io_uring: add LSM hooks for the new uring_cmd file op
io-uring cmd support was added through ee692a21e9bf ("fs,io_uring:
add infrastructure for uring-cmd"), this extended the struct file_operations to allow a new command which each subsystem can use to enable command passthrough. Add an LSM specific for the command passthrough which enables LSMs to inspect the command details.
This was discussed long ago without no clear pointer for something conclusive, so this enables LSMs to at least reject this new file operation.
[0] https://lkml.kernel.org/r/[email protected]
include/linux/lsm_hook_defs.h +1 -0
@@ -407,4 +407,5 @@ LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)#ifdef CONFIG_IO_URING LSM_HOOK(int, 0, uring_override_creds, const struct cred *new) LSM_HOOK(int, 0, uring_sqpoll, void) +LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)#endif /* CONFIG_IO_URING */
include/linux/lsm_hooks.h +3 -0
@@ -1582,6 +1582,9 @@* Check whether the current task is allowed to spawn a io_uring polling * thread (IORING_SETUP_SQPOLL). * +* @uring_cmd: +* Check whether the file_operations uring_cmd is allowed to run. +* */ union security_list_options {#define LSM_HOOK (RET ,DEFAULT ,NAME , ...) RET (*NAME)(__VA_ARGS__);
include/linux/security.h +5 -0
@@ -2060,6 +2060,7 @@ static inline int security_perf_event_write(struct perf_event *event)#ifdef CONFIG_SECURITY extern int security_uring_override_creds (const struct cred *new);extern int security_uring_sqpoll (void ); +extern int security_uring_cmd (struct io_uring_cmd *ioucmd);#else static inline int security_uring_override_creds (const struct cred *new) {
@@ -2069,6 +2070,10 @@ static inline int security_uring_sqpoll(void) {return 0 ; } +static inline int security_uring_cmd (struct io_uring_cmd *ioucmd) +{ +return 0 ; +}#endif /* CONFIG_SECURITY */ #endif /* CONFIG_IO_URING */
io_uring/uring_cmd.c +5 -0
@@ -3,6 +3,7 @@#include <linux/errno.h> #include <linux/file.h> #include <linux/io_uring.h> +#include <linux/security.h> #include <uapi/linux/io_uring.h>
@@ -88,6 +89,10 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)if (!req->file->f_op->uring_cmd)return -EOPNOTSUPP ; + ret =security_uring_cmd (ioucmd); +if (ret) +return ret; +if (ctx->flags &IORING_SETUP_SQE128 ) issue_flags |=IO_URING_F_SQE128 ;if (ctx->flags &IORING_SETUP_CQE32 )
security/security.c +4 -0
@@ -2660,4 +2660,8 @@ int security_uring_sqpoll(void) {return call_int_hook (uring_sqpoll,0 ); } +int security_uring_cmd (struct io_uring_cmd *ioucmd) +{ +return call_int_hook (uring_cmd,0 , ioucmd); +}#endif /* CONFIG_IO_URING */