diff options
Diffstat (limited to 'security')
-rw-r--r-- | security/keys/keyctl.c | 15 | ||||
-rw-r--r-- | security/seclvl.c | 4 | ||||
-rw-r--r-- | security/selinux/Kconfig | 2 | ||||
-rw-r--r-- | security/selinux/Makefile | 4 | ||||
-rw-r--r-- | security/selinux/avc.c | 2 | ||||
-rw-r--r-- | security/selinux/hooks.c | 122 | ||||
-rw-r--r-- | security/selinux/include/objsec.h | 8 |
7 files changed, 44 insertions, 113 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 90db5c76cf6e..0c62798ac7d8 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -67,9 +67,10 @@ asmlinkage long sys_add_key(const char __user *_type, | |||
67 | description = kmalloc(dlen + 1, GFP_KERNEL); | 67 | description = kmalloc(dlen + 1, GFP_KERNEL); |
68 | if (!description) | 68 | if (!description) |
69 | goto error; | 69 | goto error; |
70 | description[dlen] = '\0'; | ||
70 | 71 | ||
71 | ret = -EFAULT; | 72 | ret = -EFAULT; |
72 | if (copy_from_user(description, _description, dlen + 1) != 0) | 73 | if (copy_from_user(description, _description, dlen) != 0) |
73 | goto error2; | 74 | goto error2; |
74 | 75 | ||
75 | /* pull the payload in if one was supplied */ | 76 | /* pull the payload in if one was supplied */ |
@@ -161,9 +162,10 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
161 | description = kmalloc(dlen + 1, GFP_KERNEL); | 162 | description = kmalloc(dlen + 1, GFP_KERNEL); |
162 | if (!description) | 163 | if (!description) |
163 | goto error; | 164 | goto error; |
165 | description[dlen] = '\0'; | ||
164 | 166 | ||
165 | ret = -EFAULT; | 167 | ret = -EFAULT; |
166 | if (copy_from_user(description, _description, dlen + 1) != 0) | 168 | if (copy_from_user(description, _description, dlen) != 0) |
167 | goto error2; | 169 | goto error2; |
168 | 170 | ||
169 | /* pull the callout info into kernel space */ | 171 | /* pull the callout info into kernel space */ |
@@ -182,9 +184,10 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
182 | callout_info = kmalloc(dlen + 1, GFP_KERNEL); | 184 | callout_info = kmalloc(dlen + 1, GFP_KERNEL); |
183 | if (!callout_info) | 185 | if (!callout_info) |
184 | goto error2; | 186 | goto error2; |
187 | callout_info[dlen] = '\0'; | ||
185 | 188 | ||
186 | ret = -EFAULT; | 189 | ret = -EFAULT; |
187 | if (copy_from_user(callout_info, _callout_info, dlen + 1) != 0) | 190 | if (copy_from_user(callout_info, _callout_info, dlen) != 0) |
188 | goto error3; | 191 | goto error3; |
189 | } | 192 | } |
190 | 193 | ||
@@ -279,9 +282,10 @@ long keyctl_join_session_keyring(const char __user *_name) | |||
279 | name = kmalloc(nlen + 1, GFP_KERNEL); | 282 | name = kmalloc(nlen + 1, GFP_KERNEL); |
280 | if (!name) | 283 | if (!name) |
281 | goto error; | 284 | goto error; |
285 | name[nlen] = '\0'; | ||
282 | 286 | ||
283 | ret = -EFAULT; | 287 | ret = -EFAULT; |
284 | if (copy_from_user(name, _name, nlen + 1) != 0) | 288 | if (copy_from_user(name, _name, nlen) != 0) |
285 | goto error2; | 289 | goto error2; |
286 | } | 290 | } |
287 | 291 | ||
@@ -583,9 +587,10 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
583 | description = kmalloc(dlen + 1, GFP_KERNEL); | 587 | description = kmalloc(dlen + 1, GFP_KERNEL); |
584 | if (!description) | 588 | if (!description) |
585 | goto error; | 589 | goto error; |
590 | description[dlen] = '\0'; | ||
586 | 591 | ||
587 | ret = -EFAULT; | 592 | ret = -EFAULT; |
588 | if (copy_from_user(description, _description, dlen + 1) != 0) | 593 | if (copy_from_user(description, _description, dlen) != 0) |
589 | goto error2; | 594 | goto error2; |
590 | 595 | ||
591 | /* get the keyring at which to begin the search */ | 596 | /* get the keyring at which to begin the search */ |
diff --git a/security/seclvl.c b/security/seclvl.c index 1caac0164643..8529ea6f7aa8 100644 --- a/security/seclvl.c +++ b/security/seclvl.c | |||
@@ -368,8 +368,8 @@ static int seclvl_capable(struct task_struct *tsk, int cap) | |||
368 | */ | 368 | */ |
369 | static int seclvl_settime(struct timespec *tv, struct timezone *tz) | 369 | static int seclvl_settime(struct timespec *tv, struct timezone *tz) |
370 | { | 370 | { |
371 | struct timespec now; | 371 | if (tv && seclvl > 1) { |
372 | if (seclvl > 1) { | 372 | struct timespec now; |
373 | now = current_kernel_time(); | 373 | now = current_kernel_time(); |
374 | if (tv->tv_sec < now.tv_sec || | 374 | if (tv->tv_sec < now.tv_sec || |
375 | (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) { | 375 | (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) { |
diff --git a/security/selinux/Kconfig b/security/selinux/Kconfig index b59582b92283..f636f53ca544 100644 --- a/security/selinux/Kconfig +++ b/security/selinux/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config SECURITY_SELINUX | 1 | config SECURITY_SELINUX |
2 | bool "NSA SELinux Support" | 2 | bool "NSA SELinux Support" |
3 | depends on SECURITY && NET && INET | 3 | depends on SECURITY_NETWORK && AUDIT && NET && INET |
4 | default n | 4 | default n |
5 | help | 5 | help |
6 | This selects NSA Security-Enhanced Linux (SELinux). | 6 | This selects NSA Security-Enhanced Linux (SELinux). |
diff --git a/security/selinux/Makefile b/security/selinux/Makefile index 06d54d9d20a5..688c0a267b62 100644 --- a/security/selinux/Makefile +++ b/security/selinux/Makefile | |||
@@ -4,9 +4,7 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/ | 5 | obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/ |
6 | 6 | ||
7 | selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o | 7 | selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o |
8 | |||
9 | selinux-$(CONFIG_SECURITY_NETWORK) += netif.o | ||
10 | 8 | ||
11 | selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o | 9 | selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o |
12 | 10 | ||
diff --git a/security/selinux/avc.c b/security/selinux/avc.c index 53d6c7bbf564..ac5d69bb3377 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c | |||
@@ -43,13 +43,11 @@ static const struct av_perm_to_string | |||
43 | #undef S_ | 43 | #undef S_ |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #ifdef CONFIG_AUDIT | ||
47 | static const char *class_to_string[] = { | 46 | static const char *class_to_string[] = { |
48 | #define S_(s) s, | 47 | #define S_(s) s, |
49 | #include "class_to_string.h" | 48 | #include "class_to_string.h" |
50 | #undef S_ | 49 | #undef S_ |
51 | }; | 50 | }; |
52 | #endif | ||
53 | 51 | ||
54 | #define TB_(s) static const char * s [] = { | 52 | #define TB_(s) static const char * s [] = { |
55 | #define TE_(s) }; | 53 | #define TE_(s) }; |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index b9f8d9731c3d..b7773bf68efa 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -127,7 +127,6 @@ static int task_alloc_security(struct task_struct *task) | |||
127 | if (!tsec) | 127 | if (!tsec) |
128 | return -ENOMEM; | 128 | return -ENOMEM; |
129 | 129 | ||
130 | tsec->magic = SELINUX_MAGIC; | ||
131 | tsec->task = task; | 130 | tsec->task = task; |
132 | tsec->osid = tsec->sid = tsec->ptrace_sid = SECINITSID_UNLABELED; | 131 | tsec->osid = tsec->sid = tsec->ptrace_sid = SECINITSID_UNLABELED; |
133 | task->security = tsec; | 132 | task->security = tsec; |
@@ -138,10 +137,6 @@ static int task_alloc_security(struct task_struct *task) | |||
138 | static void task_free_security(struct task_struct *task) | 137 | static void task_free_security(struct task_struct *task) |
139 | { | 138 | { |
140 | struct task_security_struct *tsec = task->security; | 139 | struct task_security_struct *tsec = task->security; |
141 | |||
142 | if (!tsec || tsec->magic != SELINUX_MAGIC) | ||
143 | return; | ||
144 | |||
145 | task->security = NULL; | 140 | task->security = NULL; |
146 | kfree(tsec); | 141 | kfree(tsec); |
147 | } | 142 | } |
@@ -157,14 +152,10 @@ static int inode_alloc_security(struct inode *inode) | |||
157 | 152 | ||
158 | init_MUTEX(&isec->sem); | 153 | init_MUTEX(&isec->sem); |
159 | INIT_LIST_HEAD(&isec->list); | 154 | INIT_LIST_HEAD(&isec->list); |
160 | isec->magic = SELINUX_MAGIC; | ||
161 | isec->inode = inode; | 155 | isec->inode = inode; |
162 | isec->sid = SECINITSID_UNLABELED; | 156 | isec->sid = SECINITSID_UNLABELED; |
163 | isec->sclass = SECCLASS_FILE; | 157 | isec->sclass = SECCLASS_FILE; |
164 | if (tsec && tsec->magic == SELINUX_MAGIC) | 158 | isec->task_sid = tsec->sid; |
165 | isec->task_sid = tsec->sid; | ||
166 | else | ||
167 | isec->task_sid = SECINITSID_UNLABELED; | ||
168 | inode->i_security = isec; | 159 | inode->i_security = isec; |
169 | 160 | ||
170 | return 0; | 161 | return 0; |
@@ -175,9 +166,6 @@ static void inode_free_security(struct inode *inode) | |||
175 | struct inode_security_struct *isec = inode->i_security; | 166 | struct inode_security_struct *isec = inode->i_security; |
176 | struct superblock_security_struct *sbsec = inode->i_sb->s_security; | 167 | struct superblock_security_struct *sbsec = inode->i_sb->s_security; |
177 | 168 | ||
178 | if (!isec || isec->magic != SELINUX_MAGIC) | ||
179 | return; | ||
180 | |||
181 | spin_lock(&sbsec->isec_lock); | 169 | spin_lock(&sbsec->isec_lock); |
182 | if (!list_empty(&isec->list)) | 170 | if (!list_empty(&isec->list)) |
183 | list_del_init(&isec->list); | 171 | list_del_init(&isec->list); |
@@ -192,19 +180,13 @@ static int file_alloc_security(struct file *file) | |||
192 | struct task_security_struct *tsec = current->security; | 180 | struct task_security_struct *tsec = current->security; |
193 | struct file_security_struct *fsec; | 181 | struct file_security_struct *fsec; |
194 | 182 | ||
195 | fsec = kzalloc(sizeof(struct file_security_struct), GFP_ATOMIC); | 183 | fsec = kzalloc(sizeof(struct file_security_struct), GFP_KERNEL); |
196 | if (!fsec) | 184 | if (!fsec) |
197 | return -ENOMEM; | 185 | return -ENOMEM; |
198 | 186 | ||
199 | fsec->magic = SELINUX_MAGIC; | ||
200 | fsec->file = file; | 187 | fsec->file = file; |
201 | if (tsec && tsec->magic == SELINUX_MAGIC) { | 188 | fsec->sid = tsec->sid; |
202 | fsec->sid = tsec->sid; | 189 | fsec->fown_sid = tsec->sid; |
203 | fsec->fown_sid = tsec->sid; | ||
204 | } else { | ||
205 | fsec->sid = SECINITSID_UNLABELED; | ||
206 | fsec->fown_sid = SECINITSID_UNLABELED; | ||
207 | } | ||
208 | file->f_security = fsec; | 190 | file->f_security = fsec; |
209 | 191 | ||
210 | return 0; | 192 | return 0; |
@@ -213,10 +195,6 @@ static int file_alloc_security(struct file *file) | |||
213 | static void file_free_security(struct file *file) | 195 | static void file_free_security(struct file *file) |
214 | { | 196 | { |
215 | struct file_security_struct *fsec = file->f_security; | 197 | struct file_security_struct *fsec = file->f_security; |
216 | |||
217 | if (!fsec || fsec->magic != SELINUX_MAGIC) | ||
218 | return; | ||
219 | |||
220 | file->f_security = NULL; | 198 | file->f_security = NULL; |
221 | kfree(fsec); | 199 | kfree(fsec); |
222 | } | 200 | } |
@@ -233,7 +211,6 @@ static int superblock_alloc_security(struct super_block *sb) | |||
233 | INIT_LIST_HEAD(&sbsec->list); | 211 | INIT_LIST_HEAD(&sbsec->list); |
234 | INIT_LIST_HEAD(&sbsec->isec_head); | 212 | INIT_LIST_HEAD(&sbsec->isec_head); |
235 | spin_lock_init(&sbsec->isec_lock); | 213 | spin_lock_init(&sbsec->isec_lock); |
236 | sbsec->magic = SELINUX_MAGIC; | ||
237 | sbsec->sb = sb; | 214 | sbsec->sb = sb; |
238 | sbsec->sid = SECINITSID_UNLABELED; | 215 | sbsec->sid = SECINITSID_UNLABELED; |
239 | sbsec->def_sid = SECINITSID_FILE; | 216 | sbsec->def_sid = SECINITSID_FILE; |
@@ -246,9 +223,6 @@ static void superblock_free_security(struct super_block *sb) | |||
246 | { | 223 | { |
247 | struct superblock_security_struct *sbsec = sb->s_security; | 224 | struct superblock_security_struct *sbsec = sb->s_security; |
248 | 225 | ||
249 | if (!sbsec || sbsec->magic != SELINUX_MAGIC) | ||
250 | return; | ||
251 | |||
252 | spin_lock(&sb_security_lock); | 226 | spin_lock(&sb_security_lock); |
253 | if (!list_empty(&sbsec->list)) | 227 | if (!list_empty(&sbsec->list)) |
254 | list_del_init(&sbsec->list); | 228 | list_del_init(&sbsec->list); |
@@ -258,7 +232,6 @@ static void superblock_free_security(struct super_block *sb) | |||
258 | kfree(sbsec); | 232 | kfree(sbsec); |
259 | } | 233 | } |
260 | 234 | ||
261 | #ifdef CONFIG_SECURITY_NETWORK | ||
262 | static int sk_alloc_security(struct sock *sk, int family, gfp_t priority) | 235 | static int sk_alloc_security(struct sock *sk, int family, gfp_t priority) |
263 | { | 236 | { |
264 | struct sk_security_struct *ssec; | 237 | struct sk_security_struct *ssec; |
@@ -270,7 +243,6 @@ static int sk_alloc_security(struct sock *sk, int family, gfp_t priority) | |||
270 | if (!ssec) | 243 | if (!ssec) |
271 | return -ENOMEM; | 244 | return -ENOMEM; |
272 | 245 | ||
273 | ssec->magic = SELINUX_MAGIC; | ||
274 | ssec->sk = sk; | 246 | ssec->sk = sk; |
275 | ssec->peer_sid = SECINITSID_UNLABELED; | 247 | ssec->peer_sid = SECINITSID_UNLABELED; |
276 | sk->sk_security = ssec; | 248 | sk->sk_security = ssec; |
@@ -282,13 +254,12 @@ static void sk_free_security(struct sock *sk) | |||
282 | { | 254 | { |
283 | struct sk_security_struct *ssec = sk->sk_security; | 255 | struct sk_security_struct *ssec = sk->sk_security; |
284 | 256 | ||
285 | if (sk->sk_family != PF_UNIX || ssec->magic != SELINUX_MAGIC) | 257 | if (sk->sk_family != PF_UNIX) |
286 | return; | 258 | return; |
287 | 259 | ||
288 | sk->sk_security = NULL; | 260 | sk->sk_security = NULL; |
289 | kfree(ssec); | 261 | kfree(ssec); |
290 | } | 262 | } |
291 | #endif /* CONFIG_SECURITY_NETWORK */ | ||
292 | 263 | ||
293 | /* The security server must be initialized before | 264 | /* The security server must be initialized before |
294 | any labeling or access decisions can be provided. */ | 265 | any labeling or access decisions can be provided. */ |
@@ -1483,7 +1454,6 @@ static int selinux_bprm_alloc_security(struct linux_binprm *bprm) | |||
1483 | if (!bsec) | 1454 | if (!bsec) |
1484 | return -ENOMEM; | 1455 | return -ENOMEM; |
1485 | 1456 | ||
1486 | bsec->magic = SELINUX_MAGIC; | ||
1487 | bsec->bprm = bprm; | 1457 | bsec->bprm = bprm; |
1488 | bsec->sid = SECINITSID_UNLABELED; | 1458 | bsec->sid = SECINITSID_UNLABELED; |
1489 | bsec->set = 0; | 1459 | bsec->set = 0; |
@@ -2454,35 +2424,27 @@ static int selinux_file_mprotect(struct vm_area_struct *vma, | |||
2454 | prot = reqprot; | 2424 | prot = reqprot; |
2455 | 2425 | ||
2456 | #ifndef CONFIG_PPC32 | 2426 | #ifndef CONFIG_PPC32 |
2457 | if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXECUTABLE) && | 2427 | if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) { |
2458 | (vma->vm_start >= vma->vm_mm->start_brk && | 2428 | rc = 0; |
2459 | vma->vm_end <= vma->vm_mm->brk)) { | 2429 | if (vma->vm_start >= vma->vm_mm->start_brk && |
2460 | /* | 2430 | vma->vm_end <= vma->vm_mm->brk) { |
2461 | * We are making an executable mapping in the brk region. | 2431 | rc = task_has_perm(current, current, |
2462 | * This has an additional execheap check. | 2432 | PROCESS__EXECHEAP); |
2463 | */ | 2433 | } else if (!vma->vm_file && |
2464 | rc = task_has_perm(current, current, PROCESS__EXECHEAP); | 2434 | vma->vm_start <= vma->vm_mm->start_stack && |
2465 | if (rc) | 2435 | vma->vm_end >= vma->vm_mm->start_stack) { |
2466 | return rc; | 2436 | rc = task_has_perm(current, current, PROCESS__EXECSTACK); |
2467 | } | 2437 | } else if (vma->vm_file && vma->anon_vma) { |
2468 | if (vma->vm_file != NULL && vma->anon_vma != NULL && (prot & PROT_EXEC)) { | 2438 | /* |
2469 | /* | 2439 | * We are making executable a file mapping that has |
2470 | * We are making executable a file mapping that has | 2440 | * had some COW done. Since pages might have been |
2471 | * had some COW done. Since pages might have been written, | 2441 | * written, check ability to execute the possibly |
2472 | * check ability to execute the possibly modified content. | 2442 | * modified content. This typically should only |
2473 | * This typically should only occur for text relocations. | 2443 | * occur for text relocations. |
2474 | */ | 2444 | */ |
2475 | int rc = file_has_perm(current, vma->vm_file, FILE__EXECMOD); | 2445 | rc = file_has_perm(current, vma->vm_file, |
2476 | if (rc) | 2446 | FILE__EXECMOD); |
2477 | return rc; | 2447 | } |
2478 | } | ||
2479 | if (!vma->vm_file && (prot & PROT_EXEC) && | ||
2480 | vma->vm_start <= vma->vm_mm->start_stack && | ||
2481 | vma->vm_end >= vma->vm_mm->start_stack) { | ||
2482 | /* Attempt to make the process stack executable. | ||
2483 | * This has an additional execstack check. | ||
2484 | */ | ||
2485 | rc = task_has_perm(current, current, PROCESS__EXECSTACK); | ||
2486 | if (rc) | 2448 | if (rc) |
2487 | return rc; | 2449 | return rc; |
2488 | } | 2450 | } |
@@ -2772,8 +2734,6 @@ static void selinux_task_to_inode(struct task_struct *p, | |||
2772 | return; | 2734 | return; |
2773 | } | 2735 | } |
2774 | 2736 | ||
2775 | #ifdef CONFIG_SECURITY_NETWORK | ||
2776 | |||
2777 | /* Returns error only if unable to parse addresses */ | 2737 | /* Returns error only if unable to parse addresses */ |
2778 | static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad) | 2738 | static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad) |
2779 | { | 2739 | { |
@@ -3592,15 +3552,6 @@ static unsigned int selinux_ipv6_postroute_last(unsigned int hooknum, | |||
3592 | 3552 | ||
3593 | #endif /* CONFIG_NETFILTER */ | 3553 | #endif /* CONFIG_NETFILTER */ |
3594 | 3554 | ||
3595 | #else | ||
3596 | |||
3597 | static inline int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb) | ||
3598 | { | ||
3599 | return 0; | ||
3600 | } | ||
3601 | |||
3602 | #endif /* CONFIG_SECURITY_NETWORK */ | ||
3603 | |||
3604 | static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb) | 3555 | static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb) |
3605 | { | 3556 | { |
3606 | struct task_security_struct *tsec; | 3557 | struct task_security_struct *tsec; |
@@ -3642,14 +3593,9 @@ static int ipc_alloc_security(struct task_struct *task, | |||
3642 | if (!isec) | 3593 | if (!isec) |
3643 | return -ENOMEM; | 3594 | return -ENOMEM; |
3644 | 3595 | ||
3645 | isec->magic = SELINUX_MAGIC; | ||
3646 | isec->sclass = sclass; | 3596 | isec->sclass = sclass; |
3647 | isec->ipc_perm = perm; | 3597 | isec->ipc_perm = perm; |
3648 | if (tsec) { | 3598 | isec->sid = tsec->sid; |
3649 | isec->sid = tsec->sid; | ||
3650 | } else { | ||
3651 | isec->sid = SECINITSID_UNLABELED; | ||
3652 | } | ||
3653 | perm->security = isec; | 3599 | perm->security = isec; |
3654 | 3600 | ||
3655 | return 0; | 3601 | return 0; |
@@ -3658,9 +3604,6 @@ static int ipc_alloc_security(struct task_struct *task, | |||
3658 | static void ipc_free_security(struct kern_ipc_perm *perm) | 3604 | static void ipc_free_security(struct kern_ipc_perm *perm) |
3659 | { | 3605 | { |
3660 | struct ipc_security_struct *isec = perm->security; | 3606 | struct ipc_security_struct *isec = perm->security; |
3661 | if (!isec || isec->magic != SELINUX_MAGIC) | ||
3662 | return; | ||
3663 | |||
3664 | perm->security = NULL; | 3607 | perm->security = NULL; |
3665 | kfree(isec); | 3608 | kfree(isec); |
3666 | } | 3609 | } |
@@ -3673,7 +3616,6 @@ static int msg_msg_alloc_security(struct msg_msg *msg) | |||
3673 | if (!msec) | 3616 | if (!msec) |
3674 | return -ENOMEM; | 3617 | return -ENOMEM; |
3675 | 3618 | ||
3676 | msec->magic = SELINUX_MAGIC; | ||
3677 | msec->msg = msg; | 3619 | msec->msg = msg; |
3678 | msec->sid = SECINITSID_UNLABELED; | 3620 | msec->sid = SECINITSID_UNLABELED; |
3679 | msg->security = msec; | 3621 | msg->security = msec; |
@@ -3684,8 +3626,6 @@ static int msg_msg_alloc_security(struct msg_msg *msg) | |||
3684 | static void msg_msg_free_security(struct msg_msg *msg) | 3626 | static void msg_msg_free_security(struct msg_msg *msg) |
3685 | { | 3627 | { |
3686 | struct msg_security_struct *msec = msg->security; | 3628 | struct msg_security_struct *msec = msg->security; |
3687 | if (!msec || msec->magic != SELINUX_MAGIC) | ||
3688 | return; | ||
3689 | 3629 | ||
3690 | msg->security = NULL; | 3630 | msg->security = NULL; |
3691 | kfree(msec); | 3631 | kfree(msec); |
@@ -4387,7 +4327,6 @@ static struct security_operations selinux_ops = { | |||
4387 | .getprocattr = selinux_getprocattr, | 4327 | .getprocattr = selinux_getprocattr, |
4388 | .setprocattr = selinux_setprocattr, | 4328 | .setprocattr = selinux_setprocattr, |
4389 | 4329 | ||
4390 | #ifdef CONFIG_SECURITY_NETWORK | ||
4391 | .unix_stream_connect = selinux_socket_unix_stream_connect, | 4330 | .unix_stream_connect = selinux_socket_unix_stream_connect, |
4392 | .unix_may_send = selinux_socket_unix_may_send, | 4331 | .unix_may_send = selinux_socket_unix_may_send, |
4393 | 4332 | ||
@@ -4409,7 +4348,6 @@ static struct security_operations selinux_ops = { | |||
4409 | .sk_alloc_security = selinux_sk_alloc_security, | 4348 | .sk_alloc_security = selinux_sk_alloc_security, |
4410 | .sk_free_security = selinux_sk_free_security, | 4349 | .sk_free_security = selinux_sk_free_security, |
4411 | .sk_getsid = selinux_sk_getsid_security, | 4350 | .sk_getsid = selinux_sk_getsid_security, |
4412 | #endif | ||
4413 | 4351 | ||
4414 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | 4352 | #ifdef CONFIG_SECURITY_NETWORK_XFRM |
4415 | .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, | 4353 | .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, |
@@ -4487,7 +4425,7 @@ next_sb: | |||
4487 | all processes and objects when they are created. */ | 4425 | all processes and objects when they are created. */ |
4488 | security_initcall(selinux_init); | 4426 | security_initcall(selinux_init); |
4489 | 4427 | ||
4490 | #if defined(CONFIG_SECURITY_NETWORK) && defined(CONFIG_NETFILTER) | 4428 | #if defined(CONFIG_NETFILTER) |
4491 | 4429 | ||
4492 | static struct nf_hook_ops selinux_ipv4_op = { | 4430 | static struct nf_hook_ops selinux_ipv4_op = { |
4493 | .hook = selinux_ipv4_postroute_last, | 4431 | .hook = selinux_ipv4_postroute_last, |
@@ -4548,13 +4486,13 @@ static void selinux_nf_ip_exit(void) | |||
4548 | } | 4486 | } |
4549 | #endif | 4487 | #endif |
4550 | 4488 | ||
4551 | #else /* CONFIG_SECURITY_NETWORK && CONFIG_NETFILTER */ | 4489 | #else /* CONFIG_NETFILTER */ |
4552 | 4490 | ||
4553 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE | 4491 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE |
4554 | #define selinux_nf_ip_exit() | 4492 | #define selinux_nf_ip_exit() |
4555 | #endif | 4493 | #endif |
4556 | 4494 | ||
4557 | #endif /* CONFIG_SECURITY_NETWORK && CONFIG_NETFILTER */ | 4495 | #endif /* CONFIG_NETFILTER */ |
4558 | 4496 | ||
4559 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE | 4497 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE |
4560 | int selinux_disable(void) | 4498 | int selinux_disable(void) |
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index 887937c8134a..54c030778882 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "avc.h" | 27 | #include "avc.h" |
28 | 28 | ||
29 | struct task_security_struct { | 29 | struct task_security_struct { |
30 | unsigned long magic; /* magic number for this module */ | ||
31 | struct task_struct *task; /* back pointer to task object */ | 30 | struct task_struct *task; /* back pointer to task object */ |
32 | u32 osid; /* SID prior to last execve */ | 31 | u32 osid; /* SID prior to last execve */ |
33 | u32 sid; /* current SID */ | 32 | u32 sid; /* current SID */ |
@@ -37,7 +36,6 @@ struct task_security_struct { | |||
37 | }; | 36 | }; |
38 | 37 | ||
39 | struct inode_security_struct { | 38 | struct inode_security_struct { |
40 | unsigned long magic; /* magic number for this module */ | ||
41 | struct inode *inode; /* back pointer to inode object */ | 39 | struct inode *inode; /* back pointer to inode object */ |
42 | struct list_head list; /* list of inode_security_struct */ | 40 | struct list_head list; /* list of inode_security_struct */ |
43 | u32 task_sid; /* SID of creating task */ | 41 | u32 task_sid; /* SID of creating task */ |
@@ -49,14 +47,12 @@ struct inode_security_struct { | |||
49 | }; | 47 | }; |
50 | 48 | ||
51 | struct file_security_struct { | 49 | struct file_security_struct { |
52 | unsigned long magic; /* magic number for this module */ | ||
53 | struct file *file; /* back pointer to file object */ | 50 | struct file *file; /* back pointer to file object */ |
54 | u32 sid; /* SID of open file description */ | 51 | u32 sid; /* SID of open file description */ |
55 | u32 fown_sid; /* SID of file owner (for SIGIO) */ | 52 | u32 fown_sid; /* SID of file owner (for SIGIO) */ |
56 | }; | 53 | }; |
57 | 54 | ||
58 | struct superblock_security_struct { | 55 | struct superblock_security_struct { |
59 | unsigned long magic; /* magic number for this module */ | ||
60 | struct super_block *sb; /* back pointer to sb object */ | 56 | struct super_block *sb; /* back pointer to sb object */ |
61 | struct list_head list; /* list of superblock_security_struct */ | 57 | struct list_head list; /* list of superblock_security_struct */ |
62 | u32 sid; /* SID of file system */ | 58 | u32 sid; /* SID of file system */ |
@@ -70,20 +66,17 @@ struct superblock_security_struct { | |||
70 | }; | 66 | }; |
71 | 67 | ||
72 | struct msg_security_struct { | 68 | struct msg_security_struct { |
73 | unsigned long magic; /* magic number for this module */ | ||
74 | struct msg_msg *msg; /* back pointer */ | 69 | struct msg_msg *msg; /* back pointer */ |
75 | u32 sid; /* SID of message */ | 70 | u32 sid; /* SID of message */ |
76 | }; | 71 | }; |
77 | 72 | ||
78 | struct ipc_security_struct { | 73 | struct ipc_security_struct { |
79 | unsigned long magic; /* magic number for this module */ | ||
80 | struct kern_ipc_perm *ipc_perm; /* back pointer */ | 74 | struct kern_ipc_perm *ipc_perm; /* back pointer */ |
81 | u16 sclass; /* security class of this object */ | 75 | u16 sclass; /* security class of this object */ |
82 | u32 sid; /* SID of IPC resource */ | 76 | u32 sid; /* SID of IPC resource */ |
83 | }; | 77 | }; |
84 | 78 | ||
85 | struct bprm_security_struct { | 79 | struct bprm_security_struct { |
86 | unsigned long magic; /* magic number for this module */ | ||
87 | struct linux_binprm *bprm; /* back pointer to bprm object */ | 80 | struct linux_binprm *bprm; /* back pointer to bprm object */ |
88 | u32 sid; /* SID for transformed process */ | 81 | u32 sid; /* SID for transformed process */ |
89 | unsigned char set; | 82 | unsigned char set; |
@@ -102,7 +95,6 @@ struct netif_security_struct { | |||
102 | }; | 95 | }; |
103 | 96 | ||
104 | struct sk_security_struct { | 97 | struct sk_security_struct { |
105 | unsigned long magic; /* magic number for this module */ | ||
106 | struct sock *sk; /* back pointer to sk object */ | 98 | struct sock *sk; /* back pointer to sk object */ |
107 | u32 peer_sid; /* SID of peer */ | 99 | u32 peer_sid; /* SID of peer */ |
108 | }; | 100 | }; |