Skip to content

Commit afb0c57

Browse files
laoarKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
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 5f061d4 commit afb0c57

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
@@ -4238,6 +4238,13 @@ static int selinux_userns_create(const struct cred *cred)
42384238
USER_NAMESPACE__CREATE, NULL);
42394239
}
42404240

4241+
static int selinux_set_mempolicy(unsigned long mode, unsigned short mode_flags,
4242+
nodemask_t *nmask, unsigned int flags)
4243+
{
4244+
return avc_has_perm(current_sid(), task_sid_obj(current), SECCLASS_PROCESS,
4245+
PROCESS__SETMEMPOLICY, NULL);
4246+
}
4247+
42414248
/* Returns error only if unable to parse addresses */
42424249
static int selinux_parse_skb_ipv4(struct sk_buff *skb,
42434250
struct common_audit_data *ad, u8 *proto)
@@ -7072,6 +7079,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
70727079
LSM_HOOK_INIT(task_kill, selinux_task_kill),
70737080
LSM_HOOK_INIT(task_to_inode, selinux_task_to_inode),
70747081
LSM_HOOK_INIT(userns_create, selinux_userns_create),
7082+
LSM_HOOK_INIT(set_mempolicy, selinux_set_mempolicy),
70757083

70767084
LSM_HOOK_INIT(ipc_permission, selinux_ipc_permission),
70777085
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)