Skip to content

Commit 12886f8

Browse files
adrianreberChristian Brauner
authored andcommitted
proc: allow access in init userns for map_files with CAP_CHECKPOINT_RESTORE
Opening files in /proc/pid/map_files when the current user is CAP_CHECKPOINT_RESTORE capable in the root namespace is useful for checkpointing and restoring to recover files that are unreachable via the file system such as deleted files, or memfd files. Signed-off-by: Adrian Reber <[email protected]> Signed-off-by: Nicolas Viennot <[email protected]> Reviewed-by: Cyrill Gorcunov <[email protected]> Reviewed-by: Serge Hallyn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent b9a3db9 commit 12886f8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/proc/base.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,16 +2189,16 @@ struct map_files_info {
21892189
};
21902190

21912191
/*
2192-
* Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the
2193-
* symlinks may be used to bypass permissions on ancestor directories in the
2194-
* path to the file in question.
2192+
* Only allow CAP_SYS_ADMIN and CAP_CHECKPOINT_RESTORE to follow the links, due
2193+
* to concerns about how the symlinks may be used to bypass permissions on
2194+
* ancestor directories in the path to the file in question.
21952195
*/
21962196
static const char *
21972197
proc_map_files_get_link(struct dentry *dentry,
21982198
struct inode *inode,
21992199
struct delayed_call *done)
22002200
{
2201-
if (!capable(CAP_SYS_ADMIN))
2201+
if (!checkpoint_restore_ns_capable(&init_user_ns))
22022202
return ERR_PTR(-EPERM);
22032203

22042204
return proc_pid_get_link(dentry, inode, done);

0 commit comments

Comments
 (0)