diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-08-11 05:19:20 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-08-11 05:19:20 -0400 |
| commit | 8067794bec1cc5de1431102cf0a6a1c7ce75cd85 (patch) | |
| tree | 2bfa0fba060d253bbd972282b29a3d60c3e7cb7f /security/selinux/hooks.c | |
| parent | 7ab6af7ab69df8c9c5fbc380004fb81187742096 (diff) | |
| parent | 796aadeb1b2db9b5d463946766c5bbfd7717158c (diff) | |
Merge branch 'linus' into x86/x2apic
Conflicts:
arch/x86/kernel/genapic_64.c
Manual merge:
arch/x86/kernel/genx2apic_uv_x.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'security/selinux/hooks.c')
| -rw-r--r-- | security/selinux/hooks.c | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 63f131fc42e4..3ae9bec5a508 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/ptrace.h> | 28 | #include <linux/tracehook.h> |
| 29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
| 30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
| 31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
| @@ -998,8 +998,12 @@ static int selinux_sb_show_options(struct seq_file *m, struct super_block *sb) | |||
| 998 | int rc; | 998 | int rc; |
| 999 | 999 | ||
| 1000 | rc = selinux_get_mnt_opts(sb, &opts); | 1000 | rc = selinux_get_mnt_opts(sb, &opts); |
| 1001 | if (rc) | 1001 | if (rc) { |
| 1002 | /* before policy load we may get EINVAL, don't show anything */ | ||
| 1003 | if (rc == -EINVAL) | ||
| 1004 | rc = 0; | ||
| 1002 | return rc; | 1005 | return rc; |
| 1006 | } | ||
| 1003 | 1007 | ||
| 1004 | selinux_write_opts(m, &opts); | 1008 | selinux_write_opts(m, &opts); |
| 1005 | 1009 | ||
| @@ -1971,22 +1975,6 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages) | |||
| 1971 | return __vm_enough_memory(mm, pages, cap_sys_admin); | 1975 | return __vm_enough_memory(mm, pages, cap_sys_admin); |
| 1972 | } | 1976 | } |
| 1973 | 1977 | ||
| 1974 | /** | ||
| 1975 | * task_tracer_task - return the task that is tracing the given task | ||
| 1976 | * @task: task to consider | ||
| 1977 | * | ||
| 1978 | * Returns NULL if noone is tracing @task, or the &struct task_struct | ||
| 1979 | * pointer to its tracer. | ||
| 1980 | * | ||
| 1981 | * Must be called under rcu_read_lock(). | ||
| 1982 | */ | ||
| 1983 | static struct task_struct *task_tracer_task(struct task_struct *task) | ||
| 1984 | { | ||
| 1985 | if (task->ptrace & PT_PTRACED) | ||
| 1986 | return rcu_dereference(task->parent); | ||
| 1987 | return NULL; | ||
| 1988 | } | ||
| 1989 | |||
| 1990 | /* binprm security operations */ | 1978 | /* binprm security operations */ |
| 1991 | 1979 | ||
| 1992 | static int selinux_bprm_alloc_security(struct linux_binprm *bprm) | 1980 | static int selinux_bprm_alloc_security(struct linux_binprm *bprm) |
| @@ -2238,7 +2226,7 @@ static void selinux_bprm_apply_creds(struct linux_binprm *bprm, int unsafe) | |||
| 2238 | u32 ptsid = 0; | 2226 | u32 ptsid = 0; |
| 2239 | 2227 | ||
| 2240 | rcu_read_lock(); | 2228 | rcu_read_lock(); |
| 2241 | tracer = task_tracer_task(current); | 2229 | tracer = tracehook_tracer_task(current); |
| 2242 | if (likely(tracer != NULL)) { | 2230 | if (likely(tracer != NULL)) { |
| 2243 | sec = tracer->security; | 2231 | sec = tracer->security; |
| 2244 | ptsid = sec->sid; | 2232 | ptsid = sec->sid; |
| @@ -2640,12 +2628,11 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na | |||
| 2640 | return dentry_has_perm(current, NULL, dentry, FILE__READ); | 2628 | return dentry_has_perm(current, NULL, dentry, FILE__READ); |
| 2641 | } | 2629 | } |
| 2642 | 2630 | ||
| 2643 | static int selinux_inode_permission(struct inode *inode, int mask, | 2631 | static int selinux_inode_permission(struct inode *inode, int mask) |
| 2644 | struct nameidata *nd) | ||
| 2645 | { | 2632 | { |
| 2646 | int rc; | 2633 | int rc; |
| 2647 | 2634 | ||
| 2648 | rc = secondary_ops->inode_permission(inode, mask, nd); | 2635 | rc = secondary_ops->inode_permission(inode, mask); |
| 2649 | if (rc) | 2636 | if (rc) |
| 2650 | return rc; | 2637 | return rc; |
| 2651 | 2638 | ||
| @@ -5247,7 +5234,7 @@ static int selinux_setprocattr(struct task_struct *p, | |||
| 5247 | Otherwise, leave SID unchanged and fail. */ | 5234 | Otherwise, leave SID unchanged and fail. */ |
| 5248 | task_lock(p); | 5235 | task_lock(p); |
| 5249 | rcu_read_lock(); | 5236 | rcu_read_lock(); |
| 5250 | tracer = task_tracer_task(p); | 5237 | tracer = tracehook_tracer_task(p); |
| 5251 | if (tracer != NULL) { | 5238 | if (tracer != NULL) { |
| 5252 | struct task_security_struct *ptsec = tracer->security; | 5239 | struct task_security_struct *ptsec = tracer->security; |
| 5253 | u32 ptsid = ptsec->sid; | 5240 | u32 ptsid = ptsec->sid; |
| @@ -5670,27 +5657,20 @@ static struct nf_hook_ops selinux_ipv6_ops[] = { | |||
| 5670 | static int __init selinux_nf_ip_init(void) | 5657 | static int __init selinux_nf_ip_init(void) |
| 5671 | { | 5658 | { |
| 5672 | int err = 0; | 5659 | int err = 0; |
| 5673 | u32 iter; | ||
| 5674 | 5660 | ||
| 5675 | if (!selinux_enabled) | 5661 | if (!selinux_enabled) |
| 5676 | goto out; | 5662 | goto out; |
| 5677 | 5663 | ||
| 5678 | printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n"); | 5664 | printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n"); |
| 5679 | 5665 | ||
| 5680 | for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++) { | 5666 | err = nf_register_hooks(selinux_ipv4_ops, ARRAY_SIZE(selinux_ipv4_ops)); |
| 5681 | err = nf_register_hook(&selinux_ipv4_ops[iter]); | 5667 | if (err) |
| 5682 | if (err) | 5668 | panic("SELinux: nf_register_hooks for IPv4: error %d\n", err); |
| 5683 | panic("SELinux: nf_register_hook for IPv4: error %d\n", | ||
| 5684 | err); | ||
| 5685 | } | ||
| 5686 | 5669 | ||
| 5687 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 5670 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 5688 | for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++) { | 5671 | err = nf_register_hooks(selinux_ipv6_ops, ARRAY_SIZE(selinux_ipv6_ops)); |
| 5689 | err = nf_register_hook(&selinux_ipv6_ops[iter]); | 5672 | if (err) |
| 5690 | if (err) | 5673 | panic("SELinux: nf_register_hooks for IPv6: error %d\n", err); |
| 5691 | panic("SELinux: nf_register_hook for IPv6: error %d\n", | ||
| 5692 | err); | ||
| 5693 | } | ||
| 5694 | #endif /* IPV6 */ | 5674 | #endif /* IPV6 */ |
| 5695 | 5675 | ||
| 5696 | out: | 5676 | out: |
| @@ -5702,15 +5682,11 @@ __initcall(selinux_nf_ip_init); | |||
| 5702 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE | 5682 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE |
| 5703 | static void selinux_nf_ip_exit(void) | 5683 | static void selinux_nf_ip_exit(void) |
| 5704 | { | 5684 | { |
| 5705 | u32 iter; | ||
| 5706 | |||
| 5707 | printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n"); | 5685 | printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n"); |
| 5708 | 5686 | ||
| 5709 | for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++) | 5687 | nf_unregister_hooks(selinux_ipv4_ops, ARRAY_SIZE(selinux_ipv4_ops)); |
| 5710 | nf_unregister_hook(&selinux_ipv4_ops[iter]); | ||
| 5711 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 5688 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 5712 | for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++) | 5689 | nf_unregister_hooks(selinux_ipv6_ops, ARRAY_SIZE(selinux_ipv6_ops)); |
| 5713 | nf_unregister_hook(&selinux_ipv6_ops[iter]); | ||
| 5714 | #endif /* IPV6 */ | 5690 | #endif /* IPV6 */ |
| 5715 | } | 5691 | } |
| 5716 | #endif | 5692 | #endif |
