aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-08-29 16:40:27 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-08-29 16:40:27 -0400
commitc1b054d03f5b31c33eaa0b267c629b118eaf3790 (patch)
tree9333907ca767be24fcb3667877242976c3e3c8dd /security/selinux/hooks.c
parent559fb51ba7e66fe298b8355fabde1275b7def35f (diff)
parentbf4e70e54cf31dcca48d279c7f7e71328eebe749 (diff)
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 87302a49067b..2253f388234f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -68,6 +68,7 @@
68#include <linux/personality.h> 68#include <linux/personality.h>
69#include <linux/sysctl.h> 69#include <linux/sysctl.h>
70#include <linux/audit.h> 70#include <linux/audit.h>
71#include <linux/string.h>
71 72
72#include "avc.h" 73#include "avc.h"
73#include "objsec.h" 74#include "objsec.h"
@@ -825,7 +826,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
825 sid = sbsec->def_sid; 826 sid = sbsec->def_sid;
826 rc = 0; 827 rc = 0;
827 } else { 828 } else {
828 rc = security_context_to_sid(context, rc, &sid); 829 rc = security_context_to_sid_default(context, rc, &sid,
830 sbsec->def_sid);
829 if (rc) { 831 if (rc) {
830 printk(KERN_WARNING "%s: context_to_sid(%s) " 832 printk(KERN_WARNING "%s: context_to_sid(%s) "
831 "returned %d for dev=%s ino=%ld\n", 833 "returned %d for dev=%s ino=%ld\n",
@@ -1658,9 +1660,8 @@ static int selinux_bprm_secureexec (struct linux_binprm *bprm)
1658 1660
1659static void selinux_bprm_free_security(struct linux_binprm *bprm) 1661static void selinux_bprm_free_security(struct linux_binprm *bprm)
1660{ 1662{
1661 struct bprm_security_struct *bsec = bprm->security; 1663 kfree(bprm->security);
1662 bprm->security = NULL; 1664 bprm->security = NULL;
1663 kfree(bsec);
1664} 1665}
1665 1666
1666extern struct vfsmount *selinuxfs_mount; 1667extern struct vfsmount *selinuxfs_mount;
@@ -1944,7 +1945,7 @@ static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void
1944 } 1945 }
1945 } while (*in_end++); 1946 } while (*in_end++);
1946 1947
1947 copy_page(in_save, nosec_save); 1948 strcpy(in_save, nosec_save);
1948 free_page((unsigned long)nosec_save); 1949 free_page((unsigned long)nosec_save);
1949out: 1950out:
1950 return rc; 1951 return rc;
@@ -2477,6 +2478,17 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
2477 prot = reqprot; 2478 prot = reqprot;
2478 2479
2479#ifndef CONFIG_PPC32 2480#ifndef CONFIG_PPC32
2481 if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXECUTABLE) &&
2482 (vma->vm_start >= vma->vm_mm->start_brk &&
2483 vma->vm_end <= vma->vm_mm->brk)) {
2484 /*
2485 * We are making an executable mapping in the brk region.
2486 * This has an additional execheap check.
2487 */
2488 rc = task_has_perm(current, current, PROCESS__EXECHEAP);
2489 if (rc)
2490 return rc;
2491 }
2480 if (vma->vm_file != NULL && vma->anon_vma != NULL && (prot & PROT_EXEC)) { 2492 if (vma->vm_file != NULL && vma->anon_vma != NULL && (prot & PROT_EXEC)) {
2481 /* 2493 /*
2482 * We are making executable a file mapping that has 2494 * We are making executable a file mapping that has
@@ -2488,6 +2500,16 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
2488 if (rc) 2500 if (rc)
2489 return rc; 2501 return rc;
2490 } 2502 }
2503 if (!vma->vm_file && (prot & PROT_EXEC) &&
2504 vma->vm_start <= vma->vm_mm->start_stack &&
2505 vma->vm_end >= vma->vm_mm->start_stack) {
2506 /* Attempt to make the process stack executable.
2507 * This has an additional execstack check.
2508 */
2509 rc = task_has_perm(current, current, PROCESS__EXECSTACK);
2510 if (rc)
2511 return rc;
2512 }
2491#endif 2513#endif
2492 2514
2493 return file_map_prot_check(vma->vm_file, prot, vma->vm_flags&VM_SHARED); 2515 return file_map_prot_check(vma->vm_file, prot, vma->vm_flags&VM_SHARED);
@@ -3104,12 +3126,12 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
3104 3126
3105 if (sk->sk_family == PF_INET) { 3127 if (sk->sk_family == PF_INET) {
3106 addr4 = (struct sockaddr_in *)address; 3128 addr4 = (struct sockaddr_in *)address;
3107 if (addrlen != sizeof(struct sockaddr_in)) 3129 if (addrlen < sizeof(struct sockaddr_in))
3108 return -EINVAL; 3130 return -EINVAL;
3109 snum = ntohs(addr4->sin_port); 3131 snum = ntohs(addr4->sin_port);
3110 } else { 3132 } else {
3111 addr6 = (struct sockaddr_in6 *)address; 3133 addr6 = (struct sockaddr_in6 *)address;
3112 if (addrlen != sizeof(struct sockaddr_in6)) 3134 if (addrlen < SIN6_LEN_RFC2133)
3113 return -EINVAL; 3135 return -EINVAL;
3114 snum = ntohs(addr6->sin6_port); 3136 snum = ntohs(addr6->sin6_port);
3115 } 3137 }