diff options
Diffstat (limited to 'security/apparmor/path.c')
-rw-r--r-- | security/apparmor/path.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/security/apparmor/path.c b/security/apparmor/path.c index a7936dfe0e6c..2daeea4f9266 100644 --- a/security/apparmor/path.c +++ b/security/apparmor/path.c | |||
@@ -157,7 +157,7 @@ out: | |||
157 | * Returns: %0 else error on failure | 157 | * Returns: %0 else error on failure |
158 | */ | 158 | */ |
159 | static int get_name_to_buffer(struct path *path, int flags, char *buffer, | 159 | static int get_name_to_buffer(struct path *path, int flags, char *buffer, |
160 | int size, char **name) | 160 | int size, char **name, const char **info) |
161 | { | 161 | { |
162 | int adjust = (flags & PATH_IS_DIR) ? 1 : 0; | 162 | int adjust = (flags & PATH_IS_DIR) ? 1 : 0; |
163 | int error = d_namespace_path(path, buffer, size - adjust, name, flags); | 163 | int error = d_namespace_path(path, buffer, size - adjust, name, flags); |
@@ -169,15 +169,27 @@ static int get_name_to_buffer(struct path *path, int flags, char *buffer, | |||
169 | */ | 169 | */ |
170 | strcpy(&buffer[size - 2], "/"); | 170 | strcpy(&buffer[size - 2], "/"); |
171 | 171 | ||
172 | if (info && error) { | ||
173 | if (error == -ENOENT) | ||
174 | *info = "Failed name lookup - deleted entry"; | ||
175 | else if (error == -ESTALE) | ||
176 | *info = "Failed name lookup - disconnected path"; | ||
177 | else if (error == -ENAMETOOLONG) | ||
178 | *info = "Failed name lookup - name too long"; | ||
179 | else | ||
180 | *info = "Failed name lookup"; | ||
181 | } | ||
182 | |||
172 | return error; | 183 | return error; |
173 | } | 184 | } |
174 | 185 | ||
175 | /** | 186 | /** |
176 | * aa_get_name - compute the pathname of a file | 187 | * aa_path_name - compute the pathname of a file |
177 | * @path: path the file (NOT NULL) | 188 | * @path: path the file (NOT NULL) |
178 | * @flags: flags controlling path name generation | 189 | * @flags: flags controlling path name generation |
179 | * @buffer: buffer that aa_get_name() allocated (NOT NULL) | 190 | * @buffer: buffer that aa_get_name() allocated (NOT NULL) |
180 | * @name: Returns - the generated path name if !error (NOT NULL) | 191 | * @name: Returns - the generated path name if !error (NOT NULL) |
192 | * @info: Returns - information on why the path lookup failed (MAYBE NULL) | ||
181 | * | 193 | * |
182 | * @name is a pointer to the beginning of the pathname (which usually differs | 194 | * @name is a pointer to the beginning of the pathname (which usually differs |
183 | * from the beginning of the buffer), or NULL. If there is an error @name | 195 | * from the beginning of the buffer), or NULL. If there is an error @name |
@@ -190,7 +202,8 @@ static int get_name_to_buffer(struct path *path, int flags, char *buffer, | |||
190 | * | 202 | * |
191 | * Returns: %0 else error code if could retrieve name | 203 | * Returns: %0 else error code if could retrieve name |
192 | */ | 204 | */ |
193 | int aa_get_name(struct path *path, int flags, char **buffer, const char **name) | 205 | int aa_path_name(struct path *path, int flags, char **buffer, const char **name, |
206 | const char **info) | ||
194 | { | 207 | { |
195 | char *buf, *str = NULL; | 208 | char *buf, *str = NULL; |
196 | int size = 256; | 209 | int size = 256; |
@@ -204,7 +217,7 @@ int aa_get_name(struct path *path, int flags, char **buffer, const char **name) | |||
204 | if (!buf) | 217 | if (!buf) |
205 | return -ENOMEM; | 218 | return -ENOMEM; |
206 | 219 | ||
207 | error = get_name_to_buffer(path, flags, buf, size, &str); | 220 | error = get_name_to_buffer(path, flags, buf, size, &str, info); |
208 | if (error != -ENAMETOOLONG) | 221 | if (error != -ENAMETOOLONG) |
209 | break; | 222 | break; |
210 | 223 | ||
@@ -212,6 +225,7 @@ int aa_get_name(struct path *path, int flags, char **buffer, const char **name) | |||
212 | size <<= 1; | 225 | size <<= 1; |
213 | if (size > aa_g_path_max) | 226 | if (size > aa_g_path_max) |
214 | return -ENAMETOOLONG; | 227 | return -ENAMETOOLONG; |
228 | *info = NULL; | ||
215 | } | 229 | } |
216 | *buffer = buf; | 230 | *buffer = buf; |
217 | *name = str; | 231 | *name = str; |