diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-08-10 13:46:28 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-08-10 13:46:28 -0400 |
| commit | 2f058256cb64e346f4fb4499ff4e0f1c2791a4b4 (patch) | |
| tree | 91e06602f4d3abb6812ea8c9bc9ba4501e14c84e /security/selinux/hooks.c | |
| parent | 0274aa2506fd2fe89a58dd6cd64d3b3f7b976af8 (diff) | |
| parent | 86b3786078d63242d3194ffc58ae8dae1d1bbef3 (diff) | |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'security/selinux/hooks.c')
| -rw-r--r-- | security/selinux/hooks.c | 34 |
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 | ||
| 1659 | static void selinux_bprm_free_security(struct linux_binprm *bprm) | 1661 | static 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 | ||
| 1666 | extern struct vfsmount *selinuxfs_mount; | 1667 | extern 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); |
| 1949 | out: | 1950 | out: |
| 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 | } |
