From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38370C3B1A6 for ; Fri, 14 Feb 2020 17:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13A5B2082F for ; Fri, 14 Feb 2020 17:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581701014; bh=FqLsbdvy18ocGeZkFW4cQQKjgKjQZOzZP80pZtfOvKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gGGAZr3Pp5dLhspCcGEBWCatX289RWFWulDOjnBLvG1xQDTgPA96QIeFaOERXUp/J fbyijXEZQd8F0uI5CneOdJKywGjdp5DEB7wuX6jC/raiOvdUvoU5vosD+VmYqUSqxg XNu+/A0a3aHaLjjFM9RdOMjw1Arm7NaZ2HNEX44Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391277AbgBNQJ2 (ORCPT ); Fri, 14 Feb 2020 11:09:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:33846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391270AbgBNQJ2 (ORCPT ); Fri, 14 Feb 2020 11:09:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BA51222C2; Fri, 14 Feb 2020 16:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581696567; bh=FqLsbdvy18ocGeZkFW4cQQKjgKjQZOzZP80pZtfOvKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/BjOwzpBry3/geEMKQqTinb5xowPnEo70ihWYD/0/hOk9frTEk862kc0rxjZGgf7 np3KZ4WBQ+ib3OzmEEvNs4/R8MCiJASDm92XCzaE/2ewWuZ4RmBKqqDcwSuZO2mF58 BcFZaFwksi3Ol0OQZjLG3dEEH+S9v+f9767L/7z0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stephen Smalley , Ondrej Mosnacek , Paul Moore , Sasha Levin , selinux@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 357/459] selinux: fix regression introduced by move_mount(2) syscall Date: Fri, 14 Feb 2020 11:00:07 -0500 Message-Id: <20200214160149.11681-357-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214160149.11681-1-sashal@kernel.org> References: <20200214160149.11681-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org From: Stephen Smalley [ Upstream commit 98aa00345de54b8340dc2ddcd87f446d33387b5e ] commit 2db154b3ea8e ("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: 2db154b3ea8e ("vfs: syscall: Add move_mount(2) to move mounts around") Signed-off-by: Stephen Smalley Reviewed-by: Ondrej Mosnacek Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- security/selinux/hooks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 44e2f46d46d2c..39410913a6949 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2766,6 +2766,14 @@ static int selinux_mount(const char *dev_name, return path_has_perm(cred, path, FILE__MOUNTON); } +static int selinux_move_mount(const struct path *from_path, + const struct path *to_path) +{ + const struct cred *cred = current_cred(); + + return path_has_perm(cred, to_path, FILE__MOUNTON); +} + static int selinux_umount(struct vfsmount *mnt, int flags) { const struct cred *cred = current_cred(); @@ -6838,6 +6846,8 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts), LSM_HOOK_INIT(sb_add_mnt_opt, selinux_add_mnt_opt), + LSM_HOOK_INIT(move_mount, selinux_move_mount), + LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security), LSM_HOOK_INIT(dentry_create_files_as, selinux_dentry_create_files_as), -- 2.20.1