diff options
Diffstat (limited to 'security')
-rw-r--r-- | security/Kconfig | 9 | ||||
-rw-r--r-- | security/capability.c | 57 | ||||
-rw-r--r-- | security/commoncap.c | 6 | ||||
-rw-r--r-- | security/inode.c | 3 | ||||
-rw-r--r-- | security/security.c | 66 | ||||
-rw-r--r-- | security/selinux/selinuxfs.c | 4 | ||||
-rw-r--r-- | security/selinux/ss/services.c | 26 | ||||
-rw-r--r-- | security/smack/smack_lsm.c | 6 |
8 files changed, 152 insertions, 25 deletions
diff --git a/security/Kconfig b/security/Kconfig index d9f47ce7e207..9438535d7fd0 100644 --- a/security/Kconfig +++ b/security/Kconfig | |||
@@ -81,6 +81,15 @@ config SECURITY_NETWORK_XFRM | |||
81 | IPSec. | 81 | IPSec. |
82 | If you are unsure how to answer this question, answer N. | 82 | If you are unsure how to answer this question, answer N. |
83 | 83 | ||
84 | config SECURITY_PATH | ||
85 | bool "Security hooks for pathname based access control" | ||
86 | depends on SECURITY | ||
87 | help | ||
88 | This enables the security hooks for pathname based access control. | ||
89 | If enabled, a security module can use these hooks to | ||
90 | implement pathname based access controls. | ||
91 | If you are unsure how to answer this question, answer N. | ||
92 | |||
84 | config SECURITY_FILE_CAPABILITIES | 93 | config SECURITY_FILE_CAPABILITIES |
85 | bool "File POSIX Capabilities" | 94 | bool "File POSIX Capabilities" |
86 | default n | 95 | default n |
diff --git a/security/capability.c b/security/capability.c index 2dce66fcb992..c545bd1300b5 100644 --- a/security/capability.c +++ b/security/capability.c | |||
@@ -263,6 +263,53 @@ static void cap_inode_getsecid(const struct inode *inode, u32 *secid) | |||
263 | *secid = 0; | 263 | *secid = 0; |
264 | } | 264 | } |
265 | 265 | ||
266 | #ifdef CONFIG_SECURITY_PATH | ||
267 | static int cap_path_mknod(struct path *dir, struct dentry *dentry, int mode, | ||
268 | unsigned int dev) | ||
269 | { | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static int cap_path_mkdir(struct path *dir, struct dentry *dentry, int mode) | ||
274 | { | ||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static int cap_path_rmdir(struct path *dir, struct dentry *dentry) | ||
279 | { | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | static int cap_path_unlink(struct path *dir, struct dentry *dentry) | ||
284 | { | ||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static int cap_path_symlink(struct path *dir, struct dentry *dentry, | ||
289 | const char *old_name) | ||
290 | { | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static int cap_path_link(struct dentry *old_dentry, struct path *new_dir, | ||
295 | struct dentry *new_dentry) | ||
296 | { | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static int cap_path_rename(struct path *old_path, struct dentry *old_dentry, | ||
301 | struct path *new_path, struct dentry *new_dentry) | ||
302 | { | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | static int cap_path_truncate(struct path *path, loff_t length, | ||
307 | unsigned int time_attrs) | ||
308 | { | ||
309 | return 0; | ||
310 | } | ||
311 | #endif | ||
312 | |||
266 | static int cap_file_permission(struct file *file, int mask) | 313 | static int cap_file_permission(struct file *file, int mask) |
267 | { | 314 | { |
268 | return 0; | 315 | return 0; |
@@ -883,6 +930,16 @@ void security_fixup_ops(struct security_operations *ops) | |||
883 | set_to_cap_if_null(ops, inode_setsecurity); | 930 | set_to_cap_if_null(ops, inode_setsecurity); |
884 | set_to_cap_if_null(ops, inode_listsecurity); | 931 | set_to_cap_if_null(ops, inode_listsecurity); |
885 | set_to_cap_if_null(ops, inode_getsecid); | 932 | set_to_cap_if_null(ops, inode_getsecid); |
933 | #ifdef CONFIG_SECURITY_PATH | ||
934 | set_to_cap_if_null(ops, path_mknod); | ||
935 | set_to_cap_if_null(ops, path_mkdir); | ||
936 | set_to_cap_if_null(ops, path_rmdir); | ||
937 | set_to_cap_if_null(ops, path_unlink); | ||
938 | set_to_cap_if_null(ops, path_symlink); | ||
939 | set_to_cap_if_null(ops, path_link); | ||
940 | set_to_cap_if_null(ops, path_rename); | ||
941 | set_to_cap_if_null(ops, path_truncate); | ||
942 | #endif | ||
886 | set_to_cap_if_null(ops, file_permission); | 943 | set_to_cap_if_null(ops, file_permission); |
887 | set_to_cap_if_null(ops, file_alloc_security); | 944 | set_to_cap_if_null(ops, file_alloc_security); |
888 | set_to_cap_if_null(ops, file_free_security); | 945 | set_to_cap_if_null(ops, file_free_security); |
diff --git a/security/commoncap.c b/security/commoncap.c index f0e671dcfff0..7cd61a5f5205 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -235,7 +235,7 @@ int cap_inode_need_killpriv(struct dentry *dentry) | |||
235 | struct inode *inode = dentry->d_inode; | 235 | struct inode *inode = dentry->d_inode; |
236 | int error; | 236 | int error; |
237 | 237 | ||
238 | if (!inode->i_op || !inode->i_op->getxattr) | 238 | if (!inode->i_op->getxattr) |
239 | return 0; | 239 | return 0; |
240 | 240 | ||
241 | error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); | 241 | error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); |
@@ -256,7 +256,7 @@ int cap_inode_killpriv(struct dentry *dentry) | |||
256 | { | 256 | { |
257 | struct inode *inode = dentry->d_inode; | 257 | struct inode *inode = dentry->d_inode; |
258 | 258 | ||
259 | if (!inode->i_op || !inode->i_op->removexattr) | 259 | if (!inode->i_op->removexattr) |
260 | return 0; | 260 | return 0; |
261 | 261 | ||
262 | return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); | 262 | return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); |
@@ -314,7 +314,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data | |||
314 | 314 | ||
315 | memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); | 315 | memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); |
316 | 316 | ||
317 | if (!inode || !inode->i_op || !inode->i_op->getxattr) | 317 | if (!inode || !inode->i_op->getxattr) |
318 | return -ENODATA; | 318 | return -ENODATA; |
319 | 319 | ||
320 | size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, | 320 | size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, |
diff --git a/security/inode.c b/security/inode.c index efea5a605466..007ef252dde7 100644 --- a/security/inode.c +++ b/security/inode.c | |||
@@ -61,9 +61,6 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) | |||
61 | 61 | ||
62 | if (inode) { | 62 | if (inode) { |
63 | inode->i_mode = mode; | 63 | inode->i_mode = mode; |
64 | inode->i_uid = 0; | ||
65 | inode->i_gid = 0; | ||
66 | inode->i_blocks = 0; | ||
67 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 64 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
68 | switch (mode & S_IFMT) { | 65 | switch (mode & S_IFMT) { |
69 | default: | 66 | default: |
diff --git a/security/security.c b/security/security.c index a02f243f09c0..c3586c0d97e2 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -373,6 +373,72 @@ int security_inode_init_security(struct inode *inode, struct inode *dir, | |||
373 | } | 373 | } |
374 | EXPORT_SYMBOL(security_inode_init_security); | 374 | EXPORT_SYMBOL(security_inode_init_security); |
375 | 375 | ||
376 | #ifdef CONFIG_SECURITY_PATH | ||
377 | int security_path_mknod(struct path *path, struct dentry *dentry, int mode, | ||
378 | unsigned int dev) | ||
379 | { | ||
380 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
381 | return 0; | ||
382 | return security_ops->path_mknod(path, dentry, mode, dev); | ||
383 | } | ||
384 | EXPORT_SYMBOL(security_path_mknod); | ||
385 | |||
386 | int security_path_mkdir(struct path *path, struct dentry *dentry, int mode) | ||
387 | { | ||
388 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
389 | return 0; | ||
390 | return security_ops->path_mkdir(path, dentry, mode); | ||
391 | } | ||
392 | |||
393 | int security_path_rmdir(struct path *path, struct dentry *dentry) | ||
394 | { | ||
395 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
396 | return 0; | ||
397 | return security_ops->path_rmdir(path, dentry); | ||
398 | } | ||
399 | |||
400 | int security_path_unlink(struct path *path, struct dentry *dentry) | ||
401 | { | ||
402 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
403 | return 0; | ||
404 | return security_ops->path_unlink(path, dentry); | ||
405 | } | ||
406 | |||
407 | int security_path_symlink(struct path *path, struct dentry *dentry, | ||
408 | const char *old_name) | ||
409 | { | ||
410 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
411 | return 0; | ||
412 | return security_ops->path_symlink(path, dentry, old_name); | ||
413 | } | ||
414 | |||
415 | int security_path_link(struct dentry *old_dentry, struct path *new_dir, | ||
416 | struct dentry *new_dentry) | ||
417 | { | ||
418 | if (unlikely(IS_PRIVATE(old_dentry->d_inode))) | ||
419 | return 0; | ||
420 | return security_ops->path_link(old_dentry, new_dir, new_dentry); | ||
421 | } | ||
422 | |||
423 | int security_path_rename(struct path *old_dir, struct dentry *old_dentry, | ||
424 | struct path *new_dir, struct dentry *new_dentry) | ||
425 | { | ||
426 | if (unlikely(IS_PRIVATE(old_dentry->d_inode) || | ||
427 | (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) | ||
428 | return 0; | ||
429 | return security_ops->path_rename(old_dir, old_dentry, new_dir, | ||
430 | new_dentry); | ||
431 | } | ||
432 | |||
433 | int security_path_truncate(struct path *path, loff_t length, | ||
434 | unsigned int time_attrs) | ||
435 | { | ||
436 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
437 | return 0; | ||
438 | return security_ops->path_truncate(path, length, time_attrs); | ||
439 | } | ||
440 | #endif | ||
441 | |||
376 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) | 442 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) |
377 | { | 443 | { |
378 | if (unlikely(IS_PRIVATE(dir))) | 444 | if (unlikely(IS_PRIVATE(dir))) |
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 77fb3c8d9267..01ec6d2c6b97 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c | |||
@@ -847,8 +847,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode) | |||
847 | 847 | ||
848 | if (ret) { | 848 | if (ret) { |
849 | ret->i_mode = mode; | 849 | ret->i_mode = mode; |
850 | ret->i_uid = ret->i_gid = 0; | ||
851 | ret->i_blocks = 0; | ||
852 | ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; | 850 | ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; |
853 | } | 851 | } |
854 | return ret; | 852 | return ret; |
@@ -1211,7 +1209,7 @@ static struct avc_cache_stats *sel_avc_get_stat_idx(loff_t *idx) | |||
1211 | { | 1209 | { |
1212 | int cpu; | 1210 | int cpu; |
1213 | 1211 | ||
1214 | for (cpu = *idx; cpu < NR_CPUS; ++cpu) { | 1212 | for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) { |
1215 | if (!cpu_possible(cpu)) | 1213 | if (!cpu_possible(cpu)) |
1216 | continue; | 1214 | continue; |
1217 | *idx = cpu + 1; | 1215 | *idx = cpu + 1; |
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 343c8ab14af0..c65e4fe4a0f1 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -2602,7 +2602,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) | |||
2602 | case AUDIT_OBJ_ROLE: | 2602 | case AUDIT_OBJ_ROLE: |
2603 | case AUDIT_OBJ_TYPE: | 2603 | case AUDIT_OBJ_TYPE: |
2604 | /* only 'equals' and 'not equals' fit user, role, and type */ | 2604 | /* only 'equals' and 'not equals' fit user, role, and type */ |
2605 | if (op != AUDIT_EQUAL && op != AUDIT_NOT_EQUAL) | 2605 | if (op != Audit_equal && op != Audit_not_equal) |
2606 | return -EINVAL; | 2606 | return -EINVAL; |
2607 | break; | 2607 | break; |
2608 | case AUDIT_SUBJ_SEN: | 2608 | case AUDIT_SUBJ_SEN: |
@@ -2736,10 +2736,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule, | |||
2736 | case AUDIT_SUBJ_USER: | 2736 | case AUDIT_SUBJ_USER: |
2737 | case AUDIT_OBJ_USER: | 2737 | case AUDIT_OBJ_USER: |
2738 | switch (op) { | 2738 | switch (op) { |
2739 | case AUDIT_EQUAL: | 2739 | case Audit_equal: |
2740 | match = (ctxt->user == rule->au_ctxt.user); | 2740 | match = (ctxt->user == rule->au_ctxt.user); |
2741 | break; | 2741 | break; |
2742 | case AUDIT_NOT_EQUAL: | 2742 | case Audit_not_equal: |
2743 | match = (ctxt->user != rule->au_ctxt.user); | 2743 | match = (ctxt->user != rule->au_ctxt.user); |
2744 | break; | 2744 | break; |
2745 | } | 2745 | } |
@@ -2747,10 +2747,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule, | |||
2747 | case AUDIT_SUBJ_ROLE: | 2747 | case AUDIT_SUBJ_ROLE: |
2748 | case AUDIT_OBJ_ROLE: | 2748 | case AUDIT_OBJ_ROLE: |
2749 | switch (op) { | 2749 | switch (op) { |
2750 | case AUDIT_EQUAL: | 2750 | case Audit_equal: |
2751 | match = (ctxt->role == rule->au_ctxt.role); | 2751 | match = (ctxt->role == rule->au_ctxt.role); |
2752 | break; | 2752 | break; |
2753 | case AUDIT_NOT_EQUAL: | 2753 | case Audit_not_equal: |
2754 | match = (ctxt->role != rule->au_ctxt.role); | 2754 | match = (ctxt->role != rule->au_ctxt.role); |
2755 | break; | 2755 | break; |
2756 | } | 2756 | } |
@@ -2758,10 +2758,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule, | |||
2758 | case AUDIT_SUBJ_TYPE: | 2758 | case AUDIT_SUBJ_TYPE: |
2759 | case AUDIT_OBJ_TYPE: | 2759 | case AUDIT_OBJ_TYPE: |
2760 | switch (op) { | 2760 | switch (op) { |
2761 | case AUDIT_EQUAL: | 2761 | case Audit_equal: |
2762 | match = (ctxt->type == rule->au_ctxt.type); | 2762 | match = (ctxt->type == rule->au_ctxt.type); |
2763 | break; | 2763 | break; |
2764 | case AUDIT_NOT_EQUAL: | 2764 | case Audit_not_equal: |
2765 | match = (ctxt->type != rule->au_ctxt.type); | 2765 | match = (ctxt->type != rule->au_ctxt.type); |
2766 | break; | 2766 | break; |
2767 | } | 2767 | } |
@@ -2774,31 +2774,31 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule, | |||
2774 | field == AUDIT_OBJ_LEV_LOW) ? | 2774 | field == AUDIT_OBJ_LEV_LOW) ? |
2775 | &ctxt->range.level[0] : &ctxt->range.level[1]); | 2775 | &ctxt->range.level[0] : &ctxt->range.level[1]); |
2776 | switch (op) { | 2776 | switch (op) { |
2777 | case AUDIT_EQUAL: | 2777 | case Audit_equal: |
2778 | match = mls_level_eq(&rule->au_ctxt.range.level[0], | 2778 | match = mls_level_eq(&rule->au_ctxt.range.level[0], |
2779 | level); | 2779 | level); |
2780 | break; | 2780 | break; |
2781 | case AUDIT_NOT_EQUAL: | 2781 | case Audit_not_equal: |
2782 | match = !mls_level_eq(&rule->au_ctxt.range.level[0], | 2782 | match = !mls_level_eq(&rule->au_ctxt.range.level[0], |
2783 | level); | 2783 | level); |
2784 | break; | 2784 | break; |
2785 | case AUDIT_LESS_THAN: | 2785 | case Audit_lt: |
2786 | match = (mls_level_dom(&rule->au_ctxt.range.level[0], | 2786 | match = (mls_level_dom(&rule->au_ctxt.range.level[0], |
2787 | level) && | 2787 | level) && |
2788 | !mls_level_eq(&rule->au_ctxt.range.level[0], | 2788 | !mls_level_eq(&rule->au_ctxt.range.level[0], |
2789 | level)); | 2789 | level)); |
2790 | break; | 2790 | break; |
2791 | case AUDIT_LESS_THAN_OR_EQUAL: | 2791 | case Audit_le: |
2792 | match = mls_level_dom(&rule->au_ctxt.range.level[0], | 2792 | match = mls_level_dom(&rule->au_ctxt.range.level[0], |
2793 | level); | 2793 | level); |
2794 | break; | 2794 | break; |
2795 | case AUDIT_GREATER_THAN: | 2795 | case Audit_gt: |
2796 | match = (mls_level_dom(level, | 2796 | match = (mls_level_dom(level, |
2797 | &rule->au_ctxt.range.level[0]) && | 2797 | &rule->au_ctxt.range.level[0]) && |
2798 | !mls_level_eq(level, | 2798 | !mls_level_eq(level, |
2799 | &rule->au_ctxt.range.level[0])); | 2799 | &rule->au_ctxt.range.level[0])); |
2800 | break; | 2800 | break; |
2801 | case AUDIT_GREATER_THAN_OR_EQUAL: | 2801 | case Audit_ge: |
2802 | match = mls_level_dom(level, | 2802 | match = mls_level_dom(level, |
2803 | &rule->au_ctxt.range.level[0]); | 2803 | &rule->au_ctxt.range.level[0]); |
2804 | break; | 2804 | break; |
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 6bfaba6177c2..0278bc083044 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -2691,7 +2691,7 @@ static int smack_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) | |||
2691 | if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) | 2691 | if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) |
2692 | return -EINVAL; | 2692 | return -EINVAL; |
2693 | 2693 | ||
2694 | if (op != AUDIT_EQUAL && op != AUDIT_NOT_EQUAL) | 2694 | if (op != Audit_equal && op != Audit_not_equal) |
2695 | return -EINVAL; | 2695 | return -EINVAL; |
2696 | 2696 | ||
2697 | *rule = smk_import(rulestr, 0); | 2697 | *rule = smk_import(rulestr, 0); |
@@ -2755,9 +2755,9 @@ static int smack_audit_rule_match(u32 secid, u32 field, u32 op, void *vrule, | |||
2755 | * both pointers will point to the same smack_known | 2755 | * both pointers will point to the same smack_known |
2756 | * label. | 2756 | * label. |
2757 | */ | 2757 | */ |
2758 | if (op == AUDIT_EQUAL) | 2758 | if (op == Audit_equal) |
2759 | return (rule == smack); | 2759 | return (rule == smack); |
2760 | if (op == AUDIT_NOT_EQUAL) | 2760 | if (op == Audit_not_equal) |
2761 | return (rule != smack); | 2761 | return (rule != smack); |
2762 | 2762 | ||
2763 | return 0; | 2763 | return 0; |