lsm/stable-6.15 PR 20250323
-----BEGIN PGP SIGNATURE----- iQJIBAABCAAyFiEES0KozwfymdVUl37v6iDy2pc3iXMFAmfgWgMUHHBhdWxAcGF1 bC1tb29yZS5jb20ACgkQ6iDy2pc3iXNW5RAAvCDq5gBtY0aTNlULe637EVLSh+t8 PkSzHzu/NlzU6BfjtwSm2fuML8welTGxSwUPxUzMCI91gPdkGeFktefavT3xa+QI BHWROn7fEJ/KmRZvngPeIkgLr5xhF5nBJmc/Jw71qem20zRzNgJnpzMX16d10Phx dxd2xOO1qM3bv6Z9RcIssZRGaN+PHngpWWg+0B69XuaBUso87S6NDyKNn1XPmvoz as96k+Wk/xAZGVEeCbs/+H5rBx6DLg+FfTRa06Oh4BFsqedpkDPxLrTgCJGJkA0H dsK6O/993zvjx0Jn4ZPoJ9n35S82BmkCsz4bGq1xVl6FYUiMcm3/8yO41wllS+w4 j+RlTU/RIdB7n8EKyMMl1hj1stTvt3Bi9F5Cbf7ZEv0snfR00K4KVpi17jnFjUHv kpOiEtXZb/NGQip7UAuUq0PisfqbiO4jJurYHRetDgv1WCy6+C8ufM5t6I+cnvmG VG+dlxcW+rDIn6bLRVuGi9TJRsQ6eox9ipa+qEKNNiOXgftELcgT7m74nAS5m0uv n5rDa221nPXecEB0X7d6YUFk711lly90dbelNeLrmv1w6jl8L1PpS1oBaW+UzGu9 46eGBd6pzu9otvK9WVyDEdotDOCrgH0sd7pTetqDhLJZ7KrGwyyqO2gD/JroUKcC lnxBQwPnat86iI8= =oxfV -----END PGP SIGNATURE----- Merge tag 'lsm-pr-20250323' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm Pull lsm updates from Paul Moore: - Various minor updates to the LSM Rust bindings Changes include marking trivial Rust bindings as inlines and comment tweaks to better reflect the LSM hooks. - Add LSM/SELinux access controls to io_uring_allowed() Similar to the io_uring_disabled sysctl, add a LSM hook to io_uring_allowed() to enable LSMs a simple way to enforce security policy on the use of io_uring. This pull request includes SELinux support for this new control using the io_uring/allowed permission. - Remove an unused parameter from the security_perf_event_open() hook The perf_event_attr struct parameter was not used by any currently supported LSMs, remove it from the hook. - Add an explicit MAINTAINERS entry for the credentials code We've seen problems in the past where patches to the credentials code sent by non-maintainers would often languish on the lists for multiple months as there was no one explicitly tasked with the responsibility of reviewing and/or merging credentials related code. Considering that most of the code under security/ has a vested interest in ensuring that the credentials code is well maintained, I'm volunteering to look after the credentials code and Serge Hallyn has also volunteered to step up as an official reviewer. I posted the MAINTAINERS update as a RFC to LKML in hopes that someone else would jump up with an "I'll do it!", but beyond Serge it was all crickets. - Update Stephen Smalley's old email address to prevent confusion This includes a corresponding update to the mailmap file. * tag 'lsm-pr-20250323' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: mailmap: map Stephen Smalley's old email addresses lsm: remove old email address for Stephen Smalley MAINTAINERS: add Serge Hallyn as a credentials reviewer MAINTAINERS: add an explicit credentials entry cred,rust: mark Credential methods inline lsm,rust: reword "destroy" -> "release" in SecurityCtx lsm,rust: mark SecurityCtx methods inline perf: Remove unnecessary parameter of security check lsm: fix a missing security_uring_allowed() prototype io_uring,lsm,selinux: add LSM hooks for io_uring_setup() io_uring: refactor io_uring_allowed()pull/1184/head
commit
054570267d
2
.mailmap
2
.mailmap
|
|
@ -685,6 +685,8 @@ Stephen Hemminger <stephen@networkplumber.org> <shemminger@linux-foundation.org>
|
|||
Stephen Hemminger <stephen@networkplumber.org> <shemminger@osdl.org>
|
||||
Stephen Hemminger <stephen@networkplumber.org> <sthemmin@microsoft.com>
|
||||
Stephen Hemminger <stephen@networkplumber.org> <sthemmin@vyatta.com>
|
||||
Stephen Smalley <stephen.smalley.work@gmail.com> <sds@epoch.ncsc.mil>
|
||||
Stephen Smalley <stephen.smalley.work@gmail.com> <sds@tycho.nsa.gov>
|
||||
Steve Wise <larrystevenwise@gmail.com> <swise@chelsio.com>
|
||||
Steve Wise <larrystevenwise@gmail.com> <swise@opengridcomputing.com>
|
||||
Subash Abhinov Kasiviswanathan <quic_subashab@quicinc.com> <subashab@codeaurora.org>
|
||||
|
|
|
|||
10
MAINTAINERS
10
MAINTAINERS
|
|
@ -6154,6 +6154,16 @@ L: linux-input@vger.kernel.org
|
|||
S: Maintained
|
||||
F: drivers/hid/hid-creative-sb0540.c
|
||||
|
||||
CREDENTIALS
|
||||
M: Paul Moore <paul@paul-moore.com>
|
||||
R: Serge Hallyn <sergeh@kernel.org>
|
||||
L: linux-security-module@vger.kernel.org
|
||||
S: Supported
|
||||
T: git https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm.git
|
||||
F: include/linux/cred.h
|
||||
F: kernel/cred.c
|
||||
F: Documentation/security/credentials.rst
|
||||
|
||||
INTEL CRPS COMMON REDUNDANT PSU DRIVER
|
||||
M: Ninad Palsule <ninad@linux.ibm.com>
|
||||
L: linux-hwmon@vger.kernel.org
|
||||
|
|
|
|||
|
|
@ -1343,7 +1343,7 @@ fail:
|
|||
* unprivileged users.
|
||||
*/
|
||||
if ((event->attr.sample_type & PERF_SAMPLE_RAW) &&
|
||||
perf_allow_kernel(&event->attr)) {
|
||||
perf_allow_kernel()) {
|
||||
perf_ibs_phyaddr_clear(perf_ibs, &ibs_data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ static int bts_event_init(struct perf_event *event)
|
|||
* to the user in a zero-copy fashion.
|
||||
*/
|
||||
if (event->attr.exclude_kernel) {
|
||||
ret = perf_allow_kernel(&event->attr);
|
||||
ret = perf_allow_kernel();
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4297,7 +4297,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
|
|||
if (x86_pmu.version < 3)
|
||||
return -EINVAL;
|
||||
|
||||
ret = perf_allow_cpu(&event->attr);
|
||||
ret = perf_allow_cpu();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -777,7 +777,7 @@ static int p4_validate_raw_event(struct perf_event *event)
|
|||
* the user needs special permissions to be able to use it
|
||||
*/
|
||||
if (p4_ht_active() && p4_event_bind_map[v].shared) {
|
||||
v = perf_allow_cpu(&event->attr);
|
||||
v = perf_allow_cpu();
|
||||
if (v)
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_C
|
|||
|
||||
static void set_spe_event_has_cx(struct perf_event *event)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && !perf_allow_kernel(&event->attr))
|
||||
if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && !perf_allow_kernel())
|
||||
event->hw.flags |= SPE_PMU_HW_FLAGS_CX;
|
||||
}
|
||||
|
||||
|
|
@ -765,7 +765,7 @@ static int arm_spe_pmu_event_init(struct perf_event *event)
|
|||
set_spe_event_has_cx(event);
|
||||
reg = arm_spe_event_to_pmscr(event);
|
||||
if (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT))
|
||||
return perf_allow_kernel(&event->attr);
|
||||
return perf_allow_kernel();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Author : Etienne BASSET <etienne.basset@ensta.org>
|
||||
*
|
||||
* All credits to : Stephen Smalley, <sds@tycho.nsa.gov>
|
||||
* All credits to : Stephen Smalley
|
||||
* All BUGS to : Etienne BASSET <etienne.basset@ensta.org>
|
||||
*/
|
||||
#ifndef _LSM_COMMON_LOGGING_
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ LSM_HOOK(int, 0, bpf_token_capable, const struct bpf_token *token, int cap)
|
|||
LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
|
||||
LSM_HOOK(int, 0, perf_event_open, int type)
|
||||
LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
|
||||
LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
|
||||
LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
|
||||
|
|
@ -455,6 +455,7 @@ LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
|
|||
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)
|
||||
LSM_HOOK(int, 0, uring_allowed, void)
|
||||
#endif /* CONFIG_IO_URING */
|
||||
|
||||
LSM_HOOK(void, LSM_RET_VOID, initramfs_populated, void)
|
||||
|
|
|
|||
|
|
@ -1698,22 +1698,22 @@ static inline int perf_is_paranoid(void)
|
|||
return sysctl_perf_event_paranoid > -1;
|
||||
}
|
||||
|
||||
int perf_allow_kernel(struct perf_event_attr *attr);
|
||||
int perf_allow_kernel(void);
|
||||
|
||||
static inline int perf_allow_cpu(struct perf_event_attr *attr)
|
||||
static inline int perf_allow_cpu(void)
|
||||
{
|
||||
if (sysctl_perf_event_paranoid > 0 && !perfmon_capable())
|
||||
return -EACCES;
|
||||
|
||||
return security_perf_event_open(attr, PERF_SECURITY_CPU);
|
||||
return security_perf_event_open(PERF_SECURITY_CPU);
|
||||
}
|
||||
|
||||
static inline int perf_allow_tracepoint(struct perf_event_attr *attr)
|
||||
static inline int perf_allow_tracepoint(void)
|
||||
{
|
||||
if (sysctl_perf_event_paranoid > -1 && !perfmon_capable())
|
||||
return -EPERM;
|
||||
|
||||
return security_perf_event_open(attr, PERF_SECURITY_TRACEPOINT);
|
||||
return security_perf_event_open(PERF_SECURITY_TRACEPOINT);
|
||||
}
|
||||
|
||||
extern int perf_exclude_event(struct perf_event *event, struct pt_regs *regs);
|
||||
|
|
|
|||
|
|
@ -2324,14 +2324,13 @@ struct perf_event_attr;
|
|||
struct perf_event;
|
||||
|
||||
#ifdef CONFIG_SECURITY
|
||||
extern int security_perf_event_open(struct perf_event_attr *attr, int type);
|
||||
extern int security_perf_event_open(int type);
|
||||
extern int security_perf_event_alloc(struct perf_event *event);
|
||||
extern void security_perf_event_free(struct perf_event *event);
|
||||
extern int security_perf_event_read(struct perf_event *event);
|
||||
extern int security_perf_event_write(struct perf_event *event);
|
||||
#else
|
||||
static inline int security_perf_event_open(struct perf_event_attr *attr,
|
||||
int type)
|
||||
static inline int security_perf_event_open(int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2362,6 +2361,7 @@ static inline int security_perf_event_write(struct perf_event *event)
|
|||
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);
|
||||
extern int security_uring_allowed(void);
|
||||
#else
|
||||
static inline int security_uring_override_creds(const struct cred *new)
|
||||
{
|
||||
|
|
@ -2375,6 +2375,10 @@ static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int security_uring_allowed(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_SECURITY */
|
||||
#endif /* CONFIG_IO_URING */
|
||||
|
||||
|
|
|
|||
|
|
@ -3793,29 +3793,36 @@ static long io_uring_setup(u32 entries, struct io_uring_params __user *params)
|
|||
return io_uring_create(entries, &p, params);
|
||||
}
|
||||
|
||||
static inline bool io_uring_allowed(void)
|
||||
static inline int io_uring_allowed(void)
|
||||
{
|
||||
int disabled = READ_ONCE(sysctl_io_uring_disabled);
|
||||
kgid_t io_uring_group;
|
||||
|
||||
if (disabled == 2)
|
||||
return false;
|
||||
return -EPERM;
|
||||
|
||||
if (disabled == 0 || capable(CAP_SYS_ADMIN))
|
||||
return true;
|
||||
goto allowed_lsm;
|
||||
|
||||
io_uring_group = make_kgid(&init_user_ns, sysctl_io_uring_group);
|
||||
if (!gid_valid(io_uring_group))
|
||||
return false;
|
||||
return -EPERM;
|
||||
|
||||
return in_group_p(io_uring_group);
|
||||
if (!in_group_p(io_uring_group))
|
||||
return -EPERM;
|
||||
|
||||
allowed_lsm:
|
||||
return security_uring_allowed();
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(io_uring_setup, u32, entries,
|
||||
struct io_uring_params __user *, params)
|
||||
{
|
||||
if (!io_uring_allowed())
|
||||
return -EPERM;
|
||||
int ret;
|
||||
|
||||
ret = io_uring_allowed();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return io_uring_setup(entries, params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4886,7 +4886,7 @@ find_get_context(struct task_struct *task, struct perf_event *event)
|
|||
|
||||
if (!task) {
|
||||
/* Must be root to operate on a CPU event: */
|
||||
err = perf_allow_cpu(&event->attr);
|
||||
err = perf_allow_cpu();
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
|
|
@ -12848,7 +12848,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
|
|||
}
|
||||
/* privileged levels capture (kernel, hv): check permissions */
|
||||
if (mask & PERF_SAMPLE_BRANCH_PERM_PLM) {
|
||||
ret = perf_allow_kernel(attr);
|
||||
ret = perf_allow_kernel();
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -13105,12 +13105,12 @@ SYSCALL_DEFINE5(perf_event_open,
|
|||
return err;
|
||||
|
||||
/* Do we allow access to perf_event_open(2) ? */
|
||||
err = security_perf_event_open(&attr, PERF_SECURITY_OPEN);
|
||||
err = security_perf_event_open(PERF_SECURITY_OPEN);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!attr.exclude_kernel) {
|
||||
err = perf_allow_kernel(&attr);
|
||||
err = perf_allow_kernel();
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
@ -13130,7 +13130,7 @@ SYSCALL_DEFINE5(perf_event_open,
|
|||
|
||||
/* Only privileged users can get physical addresses */
|
||||
if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR)) {
|
||||
err = perf_allow_kernel(&attr);
|
||||
err = perf_allow_kernel();
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
@ -13969,12 +13969,12 @@ const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
|
|||
return &event->attr;
|
||||
}
|
||||
|
||||
int perf_allow_kernel(struct perf_event_attr *attr)
|
||||
int perf_allow_kernel(void)
|
||||
{
|
||||
if (sysctl_perf_event_paranoid > 1 && !perfmon_capable())
|
||||
return -EACCES;
|
||||
|
||||
return security_perf_event_open(attr, PERF_SECURITY_KERNEL);
|
||||
return security_perf_event_open(PERF_SECURITY_KERNEL);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(perf_allow_kernel);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static int perf_trace_event_perm(struct trace_event_call *tp_event,
|
|||
|
||||
/* The ftrace function trace is allowed only for root. */
|
||||
if (ftrace_event_is_function(tp_event)) {
|
||||
ret = perf_allow_tracepoint(&p_event->attr);
|
||||
ret = perf_allow_tracepoint();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ static int perf_trace_event_perm(struct trace_event_call *tp_event,
|
|||
* ...otherwise raw tracepoint data can be a severe data leak,
|
||||
* only allow root to have these.
|
||||
*/
|
||||
ret = perf_allow_tracepoint(&p_event->attr);
|
||||
ret = perf_allow_tracepoint();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ impl Credential {
|
|||
///
|
||||
/// The caller must ensure that `ptr` is valid and remains valid for the lifetime of the
|
||||
/// returned [`Credential`] reference.
|
||||
#[inline]
|
||||
pub unsafe fn from_ptr<'a>(ptr: *const bindings::cred) -> &'a Credential {
|
||||
// SAFETY: The safety requirements guarantee the validity of the dereference, while the
|
||||
// `Credential` type being transparent makes the cast ok.
|
||||
|
|
@ -54,6 +55,7 @@ impl Credential {
|
|||
}
|
||||
|
||||
/// Get the id for this security context.
|
||||
#[inline]
|
||||
pub fn get_secid(&self) -> u32 {
|
||||
let mut secid = 0;
|
||||
// SAFETY: The invariants of this type ensures that the pointer is valid.
|
||||
|
|
@ -62,6 +64,7 @@ impl Credential {
|
|||
}
|
||||
|
||||
/// Returns the effective UID of the given credential.
|
||||
#[inline]
|
||||
pub fn euid(&self) -> Kuid {
|
||||
// SAFETY: By the type invariant, we know that `self.0` is valid. Furthermore, the `euid`
|
||||
// field of a credential is never changed after initialization, so there is no potential
|
||||
|
|
@ -72,11 +75,13 @@ impl Credential {
|
|||
|
||||
// SAFETY: The type invariants guarantee that `Credential` is always ref-counted.
|
||||
unsafe impl AlwaysRefCounted for Credential {
|
||||
#[inline]
|
||||
fn inc_ref(&self) {
|
||||
// SAFETY: The existence of a shared reference means that the refcount is nonzero.
|
||||
unsafe { bindings::get_cred(self.0.get()) };
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn dec_ref(obj: core::ptr::NonNull<Credential>) {
|
||||
// SAFETY: The safety requirements guarantee that the refcount is nonzero. The cast is okay
|
||||
// because `Credential` has the same representation as `struct cred`.
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@ use crate::{
|
|||
/// # Invariants
|
||||
///
|
||||
/// The `ctx` field corresponds to a valid security context as returned by a successful call to
|
||||
/// `security_secid_to_secctx`, that has not yet been destroyed by `security_release_secctx`.
|
||||
/// `security_secid_to_secctx`, that has not yet been released by `security_release_secctx`.
|
||||
pub struct SecurityCtx {
|
||||
ctx: bindings::lsm_context,
|
||||
}
|
||||
|
||||
impl SecurityCtx {
|
||||
/// Get the security context given its id.
|
||||
#[inline]
|
||||
pub fn from_secid(secid: u32) -> Result<Self> {
|
||||
// SAFETY: `struct lsm_context` can be initialized to all zeros.
|
||||
let mut ctx: bindings::lsm_context = unsafe { core::mem::zeroed() };
|
||||
|
|
@ -35,16 +36,19 @@ impl SecurityCtx {
|
|||
}
|
||||
|
||||
/// Returns whether the security context is empty.
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.ctx.len == 0
|
||||
}
|
||||
|
||||
/// Returns the length of this security context.
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
self.ctx.len as usize
|
||||
}
|
||||
|
||||
/// Returns the bytes for this security context.
|
||||
#[inline]
|
||||
pub fn as_bytes(&self) -> &[u8] {
|
||||
let ptr = self.ctx.context;
|
||||
if ptr.is_null() {
|
||||
|
|
@ -61,10 +65,10 @@ impl SecurityCtx {
|
|||
}
|
||||
|
||||
impl Drop for SecurityCtx {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: By the invariant of `Self`, this frees a context that came from a successful
|
||||
// call to `security_secid_to_secctx` and has not yet been destroyed by
|
||||
// `security_release_secctx`.
|
||||
// SAFETY: By the invariant of `Self`, this releases an lsm context that came from a
|
||||
// successful call to `security_secid_to_secctx` and has not yet been released.
|
||||
unsafe { bindings::security_release_secctx(&mut self.ctx) };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* common LSM auditing functions
|
||||
*
|
||||
* Based on code written for SELinux by :
|
||||
* Stephen Smalley, <sds@tycho.nsa.gov>
|
||||
* Stephen Smalley
|
||||
* James Morris <jmorris@redhat.com>
|
||||
* Author : Etienne Basset, <etienne.basset@ensta.org>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5883,16 +5883,15 @@ EXPORT_SYMBOL(security_bdev_setintegrity);
|
|||
#ifdef CONFIG_PERF_EVENTS
|
||||
/**
|
||||
* security_perf_event_open() - Check if a perf event open is allowed
|
||||
* @attr: perf event attribute
|
||||
* @type: type of event
|
||||
*
|
||||
* Check whether the @type of perf_event_open syscall is allowed.
|
||||
*
|
||||
* Return: Returns 0 if permission is granted.
|
||||
*/
|
||||
int security_perf_event_open(struct perf_event_attr *attr, int type)
|
||||
int security_perf_event_open(int type)
|
||||
{
|
||||
return call_int_hook(perf_event_open, attr, type);
|
||||
return call_int_hook(perf_event_open, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -5999,6 +5998,18 @@ int security_uring_cmd(struct io_uring_cmd *ioucmd)
|
|||
{
|
||||
return call_int_hook(uring_cmd, ioucmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* security_uring_allowed() - Check if io_uring_setup() is allowed
|
||||
*
|
||||
* Check whether the current task is allowed to call io_uring_setup().
|
||||
*
|
||||
* Return: Returns 0 if permission is granted.
|
||||
*/
|
||||
int security_uring_allowed(void)
|
||||
{
|
||||
return call_int_hook(uring_allowed);
|
||||
}
|
||||
#endif /* CONFIG_IO_URING */
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7043,7 +7043,7 @@ struct lsm_blob_sizes selinux_blob_sizes __ro_after_init = {
|
|||
};
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
static int selinux_perf_event_open(struct perf_event_attr *attr, int type)
|
||||
static int selinux_perf_event_open(int type)
|
||||
{
|
||||
u32 requested, sid = current_sid();
|
||||
|
||||
|
|
@ -7140,6 +7140,19 @@ static int selinux_uring_cmd(struct io_uring_cmd *ioucmd)
|
|||
return avc_has_perm(current_sid(), isec->sid,
|
||||
SECCLASS_IO_URING, IO_URING__CMD, &ad);
|
||||
}
|
||||
|
||||
/**
|
||||
* selinux_uring_allowed - check if io_uring_setup() can be called
|
||||
*
|
||||
* Check to see if the current task is allowed to call io_uring_setup().
|
||||
*/
|
||||
static int selinux_uring_allowed(void)
|
||||
{
|
||||
u32 sid = current_sid();
|
||||
|
||||
return avc_has_perm(sid, sid, SECCLASS_IO_URING, IO_URING__ALLOWED,
|
||||
NULL);
|
||||
}
|
||||
#endif /* CONFIG_IO_URING */
|
||||
|
||||
static const struct lsm_id selinux_lsmid = {
|
||||
|
|
@ -7393,6 +7406,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
|
|||
LSM_HOOK_INIT(uring_override_creds, selinux_uring_override_creds),
|
||||
LSM_HOOK_INIT(uring_sqpoll, selinux_uring_sqpoll),
|
||||
LSM_HOOK_INIT(uring_cmd, selinux_uring_cmd),
|
||||
LSM_HOOK_INIT(uring_allowed, selinux_uring_allowed),
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ const struct security_class_mapping secclass_map[] = {
|
|||
{ "perf_event",
|
||||
{ "open", "cpu", "kernel", "tracepoint", "read", "write", NULL } },
|
||||
{ "anon_inode", { COMMON_FILE_PERMS, NULL } },
|
||||
{ "io_uring", { "override_creds", "sqpoll", "cmd", NULL } },
|
||||
{ "io_uring", { "override_creds", "sqpoll", "cmd", "allowed", NULL } },
|
||||
{ "user_namespace", { "create", NULL } },
|
||||
/* last one */ { NULL, {} }
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue