diff options
Diffstat (limited to 'security/tomoyo/tomoyo.c')
-rw-r--r-- | security/tomoyo/tomoyo.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index 3fb5f6ea4fc9..ad9555fc3765 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c | |||
@@ -85,83 +85,6 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm) | |||
85 | return tomoyo_check_open_permission(domain, &bprm->file->f_path, 1); | 85 | return tomoyo_check_open_permission(domain, &bprm->file->f_path, 1); |
86 | } | 86 | } |
87 | 87 | ||
88 | #ifdef CONFIG_SYSCTL | ||
89 | |||
90 | static int tomoyo_prepend(char **buffer, int *buflen, const char *str) | ||
91 | { | ||
92 | int namelen = strlen(str); | ||
93 | |||
94 | if (*buflen < namelen) | ||
95 | return -ENOMEM; | ||
96 | *buflen -= namelen; | ||
97 | *buffer -= namelen; | ||
98 | memcpy(*buffer, str, namelen); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * tomoyo_sysctl_path - return the realpath of a ctl_table. | ||
104 | * @table: pointer to "struct ctl_table". | ||
105 | * | ||
106 | * Returns realpath(3) of the @table on success. | ||
107 | * Returns NULL on failure. | ||
108 | * | ||
109 | * This function uses tomoyo_alloc(), so the caller must call tomoyo_free() | ||
110 | * if this function didn't return NULL. | ||
111 | */ | ||
112 | static char *tomoyo_sysctl_path(struct ctl_table *table) | ||
113 | { | ||
114 | int buflen = TOMOYO_MAX_PATHNAME_LEN; | ||
115 | char *buf = tomoyo_alloc(buflen); | ||
116 | char *end = buf + buflen; | ||
117 | int error = -ENOMEM; | ||
118 | |||
119 | if (!buf) | ||
120 | return NULL; | ||
121 | |||
122 | *--end = '\0'; | ||
123 | buflen--; | ||
124 | while (table) { | ||
125 | char num[32]; | ||
126 | const char *sp = table->procname; | ||
127 | |||
128 | if (!sp) { | ||
129 | memset(num, 0, sizeof(num)); | ||
130 | snprintf(num, sizeof(num) - 1, "=%d=", table->ctl_name); | ||
131 | sp = num; | ||
132 | } | ||
133 | if (tomoyo_prepend(&end, &buflen, sp) || | ||
134 | tomoyo_prepend(&end, &buflen, "/")) | ||
135 | goto out; | ||
136 | table = table->parent; | ||
137 | } | ||
138 | if (tomoyo_prepend(&end, &buflen, "/proc/sys")) | ||
139 | goto out; | ||
140 | error = tomoyo_encode(buf, end - buf, end); | ||
141 | out: | ||
142 | if (!error) | ||
143 | return buf; | ||
144 | tomoyo_free(buf); | ||
145 | return NULL; | ||
146 | } | ||
147 | |||
148 | static int tomoyo_sysctl(struct ctl_table *table, int op) | ||
149 | { | ||
150 | int error; | ||
151 | char *name; | ||
152 | |||
153 | op &= MAY_READ | MAY_WRITE; | ||
154 | if (!op) | ||
155 | return 0; | ||
156 | name = tomoyo_sysctl_path(table); | ||
157 | if (!name) | ||
158 | return -ENOMEM; | ||
159 | error = tomoyo_check_file_perm(tomoyo_domain(), name, op); | ||
160 | tomoyo_free(name); | ||
161 | return error; | ||
162 | } | ||
163 | #endif | ||
164 | |||
165 | static int tomoyo_path_truncate(struct path *path, loff_t length, | 88 | static int tomoyo_path_truncate(struct path *path, loff_t length, |
166 | unsigned int time_attrs) | 89 | unsigned int time_attrs) |
167 | { | 90 | { |
@@ -336,9 +259,6 @@ static struct security_operations tomoyo_security_ops = { | |||
336 | .cred_transfer = tomoyo_cred_transfer, | 259 | .cred_transfer = tomoyo_cred_transfer, |
337 | .bprm_set_creds = tomoyo_bprm_set_creds, | 260 | .bprm_set_creds = tomoyo_bprm_set_creds, |
338 | .bprm_check_security = tomoyo_bprm_check_security, | 261 | .bprm_check_security = tomoyo_bprm_check_security, |
339 | #ifdef CONFIG_SYSCTL | ||
340 | .sysctl = tomoyo_sysctl, | ||
341 | #endif | ||
342 | .file_fcntl = tomoyo_file_fcntl, | 262 | .file_fcntl = tomoyo_file_fcntl, |
343 | .dentry_open = tomoyo_dentry_open, | 263 | .dentry_open = tomoyo_dentry_open, |
344 | .path_truncate = tomoyo_path_truncate, | 264 | .path_truncate = tomoyo_path_truncate, |