diff options
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 0c2ac318aa7f..e67a526d1f30 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3920,6 +3920,21 @@ static int selinux_task_getioprio(struct task_struct *p) | |||
3920 | PROCESS__GETSCHED, NULL); | 3920 | PROCESS__GETSCHED, NULL); |
3921 | } | 3921 | } |
3922 | 3922 | ||
3923 | int selinux_task_prlimit(const struct cred *cred, const struct cred *tcred, | ||
3924 | unsigned int flags) | ||
3925 | { | ||
3926 | u32 av = 0; | ||
3927 | |||
3928 | if (!flags) | ||
3929 | return 0; | ||
3930 | if (flags & LSM_PRLIMIT_WRITE) | ||
3931 | av |= PROCESS__SETRLIMIT; | ||
3932 | if (flags & LSM_PRLIMIT_READ) | ||
3933 | av |= PROCESS__GETRLIMIT; | ||
3934 | return avc_has_perm(cred_sid(cred), cred_sid(tcred), | ||
3935 | SECCLASS_PROCESS, av, NULL); | ||
3936 | } | ||
3937 | |||
3923 | static int selinux_task_setrlimit(struct task_struct *p, unsigned int resource, | 3938 | static int selinux_task_setrlimit(struct task_struct *p, unsigned int resource, |
3924 | struct rlimit *new_rlim) | 3939 | struct rlimit *new_rlim) |
3925 | { | 3940 | { |
@@ -4352,10 +4367,18 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in | |||
4352 | u32 sid, node_perm; | 4367 | u32 sid, node_perm; |
4353 | 4368 | ||
4354 | if (family == PF_INET) { | 4369 | if (family == PF_INET) { |
4370 | if (addrlen < sizeof(struct sockaddr_in)) { | ||
4371 | err = -EINVAL; | ||
4372 | goto out; | ||
4373 | } | ||
4355 | addr4 = (struct sockaddr_in *)address; | 4374 | addr4 = (struct sockaddr_in *)address; |
4356 | snum = ntohs(addr4->sin_port); | 4375 | snum = ntohs(addr4->sin_port); |
4357 | addrp = (char *)&addr4->sin_addr.s_addr; | 4376 | addrp = (char *)&addr4->sin_addr.s_addr; |
4358 | } else { | 4377 | } else { |
4378 | if (addrlen < SIN6_LEN_RFC2133) { | ||
4379 | err = -EINVAL; | ||
4380 | goto out; | ||
4381 | } | ||
4359 | addr6 = (struct sockaddr_in6 *)address; | 4382 | addr6 = (struct sockaddr_in6 *)address; |
4360 | snum = ntohs(addr6->sin6_port); | 4383 | snum = ntohs(addr6->sin6_port); |
4361 | addrp = (char *)&addr6->sin6_addr.s6_addr; | 4384 | addrp = (char *)&addr6->sin6_addr.s6_addr; |
@@ -6108,7 +6131,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer) | |||
6108 | 6131 | ||
6109 | #endif | 6132 | #endif |
6110 | 6133 | ||
6111 | static struct security_hook_list selinux_hooks[] = { | 6134 | static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { |
6112 | LSM_HOOK_INIT(binder_set_context_mgr, selinux_binder_set_context_mgr), | 6135 | LSM_HOOK_INIT(binder_set_context_mgr, selinux_binder_set_context_mgr), |
6113 | LSM_HOOK_INIT(binder_transaction, selinux_binder_transaction), | 6136 | LSM_HOOK_INIT(binder_transaction, selinux_binder_transaction), |
6114 | LSM_HOOK_INIT(binder_transfer_binder, selinux_binder_transfer_binder), | 6137 | LSM_HOOK_INIT(binder_transfer_binder, selinux_binder_transfer_binder), |
@@ -6206,6 +6229,7 @@ static struct security_hook_list selinux_hooks[] = { | |||
6206 | LSM_HOOK_INIT(task_setnice, selinux_task_setnice), | 6229 | LSM_HOOK_INIT(task_setnice, selinux_task_setnice), |
6207 | LSM_HOOK_INIT(task_setioprio, selinux_task_setioprio), | 6230 | LSM_HOOK_INIT(task_setioprio, selinux_task_setioprio), |
6208 | LSM_HOOK_INIT(task_getioprio, selinux_task_getioprio), | 6231 | LSM_HOOK_INIT(task_getioprio, selinux_task_getioprio), |
6232 | LSM_HOOK_INIT(task_prlimit, selinux_task_prlimit), | ||
6209 | LSM_HOOK_INIT(task_setrlimit, selinux_task_setrlimit), | 6233 | LSM_HOOK_INIT(task_setrlimit, selinux_task_setrlimit), |
6210 | LSM_HOOK_INIT(task_setscheduler, selinux_task_setscheduler), | 6234 | LSM_HOOK_INIT(task_setscheduler, selinux_task_setscheduler), |
6211 | LSM_HOOK_INIT(task_getscheduler, selinux_task_getscheduler), | 6235 | LSM_HOOK_INIT(task_getscheduler, selinux_task_getscheduler), |