hooks.c (99dbbb593fe6b39153c15ea9b9c63ea911864cf2) | hooks.c (757cbe597fe8490c7c0a9650ebe5d60195f151d4) |
---|---|
1/* 2 * NSA Security-Enhanced Linux (SELinux) security module 3 * 4 * This file contains the SELinux hook function implementations. 5 * 6 * Authors: Stephen Smalley, <sds@tycho.nsa.gov> 7 * Chris Vance, <cvance@nai.com> 8 * Wayne Salamon, <wsalamon@nai.com> --- 1035 unchanged lines hidden (view full) --- 1044 break; 1045 } 1046 return 0; 1047Einval: 1048 pr_warn(SEL_MOUNT_FAIL_MSG); 1049 return -EINVAL; 1050} 1051 | 1/* 2 * NSA Security-Enhanced Linux (SELinux) security module 3 * 4 * This file contains the SELinux hook function implementations. 5 * 6 * Authors: Stephen Smalley, <sds@tycho.nsa.gov> 7 * Chris Vance, <cvance@nai.com> 8 * Wayne Salamon, <wsalamon@nai.com> --- 1035 unchanged lines hidden (view full) --- 1044 break; 1045 } 1046 return 0; 1047Einval: 1048 pr_warn(SEL_MOUNT_FAIL_MSG); 1049 return -EINVAL; 1050} 1051 |
1052static int selinux_parse_opts_str(char *options, 1053 void **mnt_opts) | 1052static int selinux_add_mnt_opt(const char *option, const char *val, int len, 1053 void **mnt_opts) |
1054{ | 1054{ |
1055 char *p = options, *next; 1056 int rc; | 1055 int token = Opt_error; 1056 int rc, i; |
1057 | 1057 |
1058 /* Standard string-based options. */ 1059 for (p = options; *p; p = next) { 1060 int token, len; 1061 char *arg = NULL; 1062 1063 next = strchr(p, '|'); 1064 if (next) { 1065 len = next++ - p; 1066 } else { 1067 len = strlen(p); 1068 next = p + len; | 1058 for (i = 0; i < ARRAY_SIZE(tokens); i++) { 1059 if (strcmp(option, tokens[i].name) == 0) { 1060 token = tokens[i].opt; 1061 break; |
1069 } | 1062 } |
1063 } |
|
1070 | 1064 |
1071 if (!len) 1072 continue; | 1065 if (token == Opt_error) 1066 return -EINVAL; |
1073 | 1067 |
1074 token = match_opt_prefix(p, len, &arg); 1075 if (arg) 1076 arg = kmemdup_nul(arg, p + len - arg, GFP_KERNEL); 1077 rc = selinux_add_opt(token, arg, mnt_opts); 1078 if (rc) { 1079 kfree(arg); | 1068 if (token != Opt_seclabel) 1069 val = kmemdup_nul(val, len, GFP_KERNEL); 1070 rc = selinux_add_opt(token, val, mnt_opts); 1071 if (unlikely(rc)) { 1072 kfree(val); 1073 if (*mnt_opts) { |
1080 selinux_free_mnt_opts(*mnt_opts); 1081 *mnt_opts = NULL; | 1074 selinux_free_mnt_opts(*mnt_opts); 1075 *mnt_opts = NULL; |
1082 return rc; | |
1083 } 1084 } | 1076 } 1077 } |
1085 return 0; | 1078 return rc; |
1086} 1087 1088static int show_sid(struct seq_file *m, u32 sid) 1089{ 1090 char *context = NULL; 1091 u32 len; 1092 int rc; 1093 --- 5627 unchanged lines hidden (view full) --- 6721 LSM_HOOK_INIT(sb_remount, selinux_sb_remount), 6722 LSM_HOOK_INIT(sb_kern_mount, selinux_sb_kern_mount), 6723 LSM_HOOK_INIT(sb_show_options, selinux_sb_show_options), 6724 LSM_HOOK_INIT(sb_statfs, selinux_sb_statfs), 6725 LSM_HOOK_INIT(sb_mount, selinux_mount), 6726 LSM_HOOK_INIT(sb_umount, selinux_umount), 6727 LSM_HOOK_INIT(sb_set_mnt_opts, selinux_set_mnt_opts), 6728 LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts), | 1079} 1080 1081static int show_sid(struct seq_file *m, u32 sid) 1082{ 1083 char *context = NULL; 1084 u32 len; 1085 int rc; 1086 --- 5627 unchanged lines hidden (view full) --- 6714 LSM_HOOK_INIT(sb_remount, selinux_sb_remount), 6715 LSM_HOOK_INIT(sb_kern_mount, selinux_sb_kern_mount), 6716 LSM_HOOK_INIT(sb_show_options, selinux_sb_show_options), 6717 LSM_HOOK_INIT(sb_statfs, selinux_sb_statfs), 6718 LSM_HOOK_INIT(sb_mount, selinux_mount), 6719 LSM_HOOK_INIT(sb_umount, selinux_umount), 6720 LSM_HOOK_INIT(sb_set_mnt_opts, selinux_set_mnt_opts), 6721 LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts), |
6729 LSM_HOOK_INIT(sb_parse_opts_str, selinux_parse_opts_str), | 6722 LSM_HOOK_INIT(sb_add_mnt_opt, selinux_add_mnt_opt), |
6730 6731 LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security), 6732 LSM_HOOK_INIT(dentry_create_files_as, selinux_dentry_create_files_as), 6733 6734 LSM_HOOK_INIT(inode_alloc_security, selinux_inode_alloc_security), 6735 LSM_HOOK_INIT(inode_free_security, selinux_inode_free_security), 6736 LSM_HOOK_INIT(inode_init_security, selinux_inode_init_security), 6737 LSM_HOOK_INIT(inode_create, selinux_inode_create), --- 398 unchanged lines hidden --- | 6723 6724 LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security), 6725 LSM_HOOK_INIT(dentry_create_files_as, selinux_dentry_create_files_as), 6726 6727 LSM_HOOK_INIT(inode_alloc_security, selinux_inode_alloc_security), 6728 LSM_HOOK_INIT(inode_free_security, selinux_inode_free_security), 6729 LSM_HOOK_INIT(inode_init_security, selinux_inode_init_security), 6730 LSM_HOOK_INIT(inode_create, selinux_inode_create), --- 398 unchanged lines hidden --- |