Skip to content

Commit 03be9fb

Browse files
laoarKernel Patches Daemon
authored andcommitted
security: selinux: Implement set_mempolicy hook
Add a SELinux access control for the newly introduced set_mempolicy lsm hook. A new permission "setmempolicy" is defined under the "process" class for it. Signed-off-by: Yafang Shao <[email protected]>
1 parent 2a2c580 commit 03be9fb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

security/selinux/hooks.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,6 +4232,13 @@ static int selinux_userns_create(const struct cred *cred)
42324232
USER_NAMESPACE__CREATE, NULL);
42334233
}
42344234

4235+
static int selinux_set_mempolicy(unsigned long mode, unsigned short mode_flags,
4236+
nodemask_t *nmask, unsigned int flags)
4237+
{
4238+
return avc_has_perm(current_sid(), task_sid_obj(current), SECCLASS_PROCESS,
4239+
PROCESS__SETMEMPOLICY, NULL);
4240+
}
4241+
42354242
/* Returns error only if unable to parse addresses */
42364243
static int selinux_parse_skb_ipv4(struct sk_buff *skb,
42374244
struct common_audit_data *ad, u8 *proto)
@@ -7066,6 +7073,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
70667073
LSM_HOOK_INIT(task_kill, selinux_task_kill),
70677074
LSM_HOOK_INIT(task_to_inode, selinux_task_to_inode),
70687075
LSM_HOOK_INIT(userns_create, selinux_userns_create),
7076+
LSM_HOOK_INIT(set_mempolicy, selinux_set_mempolicy),
70697077

70707078
LSM_HOOK_INIT(ipc_permission, selinux_ipc_permission),
70717079
LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),

security/selinux/include/classmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const struct security_class_mapping secclass_map[] = {
5151
"getattr", "setexec", "setfscreate", "noatsecure", "siginh",
5252
"setrlimit", "rlimitinh", "dyntransition", "setcurrent",
5353
"execmem", "execstack", "execheap", "setkeycreate",
54-
"setsockcreate", "getrlimit", NULL } },
54+
"setsockcreate", "getrlimit", "setmempolicy", NULL } },
5555
{ "process2",
5656
{ "nnp_transition", "nosuid_transition", NULL } },
5757
{ "system",

0 commit comments

Comments
 (0)