Skip to content

Commit 8a3e214

Browse files
stephensmalleygregkh
authored andcommitted
selinux: fix regression introduced by move_mount(2) syscall
commit 98aa003 upstream. commit 2db154b ("vfs: syscall: Add move_mount(2) to move mounts around") introduced a new move_mount(2) system call and a corresponding new LSM security_move_mount hook but did not implement this hook for any existing LSM. This creates a regression for SELinux with respect to consistent checking of mounts; the existing selinux_mount hook checks mounton permission to the mount point path. Provide a SELinux hook implementation for move_mount that applies this same check for consistency. In the future we may wish to add a new move_mount filesystem permission and check as well, but this addresses the immediate regression. Fixes: 2db154b ("vfs: syscall: Add move_mount(2) to move mounts around") Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f08a5e6 commit 8a3e214

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎security/selinux/hooks.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,14 @@ static int selinux_mount(const char *dev_name,
27622762
return path_has_perm(cred, path, FILE__MOUNTON);
27632763
}
27642764

2765+
static int selinux_move_mount(const struct path *from_path,
2766+
const struct path *to_path)
2767+
{
2768+
const struct cred *cred = current_cred();
2769+
2770+
return path_has_perm(cred, to_path, FILE__MOUNTON);
2771+
}
2772+
27652773
static int selinux_umount(struct vfsmount *mnt, int flags)
27662774
{
27672775
const struct cred *cred = current_cred();
@@ -6904,6 +6912,8 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
69046912
LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts),
69056913
LSM_HOOK_INIT(sb_add_mnt_opt, selinux_add_mnt_opt),
69066914

6915+
LSM_HOOK_INIT(move_mount, selinux_move_mount),
6916+
69076917
LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security),
69086918
LSM_HOOK_INIT(dentry_create_files_as, selinux_dentry_create_files_as),
69096919

0 commit comments

Comments
 (0)