Skip to content

Commit ada1986

Browse files
Tetsuo HandaTetsuo Handa
authored andcommitted
tomoyo: fallback to realpath if symlink's pathname does not exist
Alfred Agrell found that TOMOYO cannot handle execveat(AT_EMPTY_PATH) inside chroot environment where /dev and /proc are not mounted, for commit 51f39a1 ("syscalls: implement execveat() system call") missed that TOMOYO tries to canonicalize argv[0] when the filename fed to the executed program as argv[0] is supplied using potentially nonexistent pathname. Since "/dev/fd/<fd>" already lost symlink information used for obtaining that <fd>, it is too late to reconstruct symlink's pathname. Although <filename> part of "/dev/fd/<fd>/<filename>" might not be canonicalized, TOMOYO cannot use tomoyo_realpath_nofollow() when /dev or /proc is not mounted. Therefore, fallback to tomoyo_realpath_from_path() when tomoyo_realpath_nofollow() failed. Reported-by: Alfred Agrell <[email protected]> Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082001 Fixes: 51f39a1 ("syscalls: implement execveat() system call") Cc: [email protected] # v3.19+ Signed-off-by: Tetsuo Handa <[email protected]>
1 parent 8b985bb commit ada1986

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

security/tomoyo/domain.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,13 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
723723
ee->r.obj = &ee->obj;
724724
ee->obj.path1 = bprm->file->f_path;
725725
/* Get symlink's pathname of program. */
726-
retval = -ENOENT;
727726
exename.name = tomoyo_realpath_nofollow(original_name);
728-
if (!exename.name)
729-
goto out;
727+
if (!exename.name) {
728+
/* Fallback to realpath if symlink's pathname does not exist. */
729+
exename.name = tomoyo_realpath_from_path(&bprm->file->f_path);
730+
if (!exename.name)
731+
goto out;
732+
}
730733
tomoyo_fill_path_info(&exename);
731734
retry:
732735
/* Check 'aggregator' directive. */

0 commit comments

Comments
 (0)