Commit 95cb2ddb authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

files-reg: restore PR_SET_DUMPABLE flag after setfsuid

Restore dumpable flag after setfsuid to assure that created /proc/self/*
file inode had task's credentials. Without it it would have root creds
and trying to access proc files of task will fail from non-root user
in generic vfs permission check.
Signed-off-by: 's avatarDmitry Safonov <dsafonov@odin.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 48b19662
...@@ -1091,13 +1091,22 @@ static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner ...@@ -1091,13 +1091,22 @@ static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner
if (root_ns_mask & CLONE_NEWUSER) { if (root_ns_mask & CLONE_NEWUSER) {
setfsuid(old_fsuid); setfsuid(old_fsuid);
if (setfsuid(-1) != old_fsuid) if (setfsuid(-1) != old_fsuid) {
pr_warn("Failed to restore old fsuid!\n"); pr_warn("Failed to restore old fsuid!\n");
/* /*
* Don't fail here. We still have chances to run till * Don't fail here. We still have chances to run till
* the pie/restorer, and if _this_ guy fails to set * the pie/restorer, and if _this_ guy fails to set
* the proper fsuid, then we'll abort the restore. * the proper fsuid, then we'll abort the restore.
*/ */
}
/*
* Restoring PR_SET_DUMPABLE flag is required after setfsuid,
* as if it not set, proc inode will be created with root cred
* (see proc_pid_make_inode), which will result in permission
* check fail when trying to access files in /proc/self/
*/
prctl(PR_SET_DUMPABLE, 1, 0);
} }
errno = errno_save; errno = errno_save;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment