mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
apparmor: release exe file resources on path failure
get_current_exe_path() takes both an exe_file reference and a path
reference before resolving the path name. If aa_path_name() failed, it
returned immediately and leaked both references.
Route the failure through the common cleanup path so fput() and path_put()
always run after the references are acquired.
Fixes: 8d34e16f7f ("apparmor: userns: Add support for execpath in userns")
Reviewed-by: Ryan Lee <ryan.lee@canonical.com>
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
45cf568241
commit
7306c41672
|
|
@ -313,9 +313,12 @@ static const char *get_current_exe_path(char *buffer, int buffer_size)
|
||||||
p = exe_file->f_path;
|
p = exe_file->f_path;
|
||||||
path_get(&p);
|
path_get(&p);
|
||||||
|
|
||||||
if (aa_path_name(&p, FLAG_VIEW_SUBNS, buffer, &path_str, NULL, NULL))
|
if (aa_path_name(&p, FLAG_VIEW_SUBNS, buffer, &path_str, NULL, NULL)) {
|
||||||
return ERR_PTR(-ENOMEM);
|
path_str = ERR_PTR(-ENOMEM);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
fput(exe_file);
|
fput(exe_file);
|
||||||
path_put(&p);
|
path_put(&p);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user