|
91 | 91 | #include <uapi/linux/mount.h>
|
92 | 92 | #include <linux/fsnotify.h>
|
93 | 93 | #include <linux/fanotify.h>
|
| 94 | +#include <linux/io_uring.h> |
94 | 95 |
|
95 | 96 | #include "avc.h"
|
96 | 97 | #include "objsec.h"
|
@@ -6987,6 +6988,28 @@ static int selinux_uring_sqpoll(void)
|
6987 | 6988 | return avc_has_perm(&selinux_state, sid, sid,
|
6988 | 6989 | SECCLASS_IO_URING, IO_URING__SQPOLL, NULL);
|
6989 | 6990 | }
|
| 6991 | + |
| 6992 | +/** |
| 6993 | + * selinux_uring_cmd - check if IORING_OP_URING_CMD is allowed |
| 6994 | + * @ioucmd: the io_uring command structure |
| 6995 | + * |
| 6996 | + * Check to see if the current domain is allowed to execute an |
| 6997 | + * IORING_OP_URING_CMD against the device/file specified in @ioucmd. |
| 6998 | + * |
| 6999 | + */ |
| 7000 | +static int selinux_uring_cmd(struct io_uring_cmd *ioucmd) |
| 7001 | +{ |
| 7002 | + struct file *file = ioucmd->file; |
| 7003 | + struct inode *inode = file_inode(file); |
| 7004 | + struct inode_security_struct *isec = selinux_inode(inode); |
| 7005 | + struct common_audit_data ad; |
| 7006 | + |
| 7007 | + ad.type = LSM_AUDIT_DATA_FILE; |
| 7008 | + ad.u.file = file; |
| 7009 | + |
| 7010 | + return avc_has_perm(&selinux_state, current_sid(), isec->sid, |
| 7011 | + SECCLASS_IO_URING, IO_URING__CMD, &ad); |
| 7012 | +} |
6990 | 7013 | #endif /* CONFIG_IO_URING */
|
6991 | 7014 |
|
6992 | 7015 | /*
|
@@ -7231,6 +7254,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
|
7231 | 7254 | #ifdef CONFIG_IO_URING
|
7232 | 7255 | LSM_HOOK_INIT(uring_override_creds, selinux_uring_override_creds),
|
7233 | 7256 | LSM_HOOK_INIT(uring_sqpoll, selinux_uring_sqpoll),
|
| 7257 | + LSM_HOOK_INIT(uring_cmd, selinux_uring_cmd), |
7234 | 7258 | #endif
|
7235 | 7259 |
|
7236 | 7260 | /*
|
|
0 commit comments