Skip to content

Commit 98aa003

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: fix regression introduced by move_mount(2) syscall
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>
1 parent dd89b9d commit 98aa003

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
@@ -2724,6 +2724,14 @@ static int selinux_mount(const char *dev_name,
27242724
return path_has_perm(cred, path, FILE__MOUNTON);
27252725
}
27262726

2727+
static int selinux_move_mount(const struct path *from_path,
2728+
const struct path *to_path)
2729+
{
2730+
const struct cred *cred = current_cred();
2731+
2732+
return path_has_perm(cred, to_path, FILE__MOUNTON);
2733+
}
2734+
27272735
static int selinux_umount(struct vfsmount *mnt, int flags)
27282736
{
27292737
const struct cred *cred = current_cred();
@@ -6913,6 +6921,8 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
69136921
LSM_HOOK_INIT(sb_set_mnt_opts, selinux_set_mnt_opts),
69146922
LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts),
69156923

6924+
LSM_HOOK_INIT(move_mount, selinux_move_mount),
6925+
69166926
LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security),
69176927
LSM_HOOK_INIT(dentry_create_files_as, selinux_dentry_create_files_as),
69186928

0 commit comments

Comments
 (0)