Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp672606ybv; Thu, 13 Feb 2020 07:32:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyLZuaMHTIRuP33dkBdTtmSJTkRHwnPcpylmWiOpV80bfTQ89faPvS48YgXzJq0OdTFqhh1 X-Received: by 2002:a9d:6b06:: with SMTP id g6mr13776635otp.93.1581607946744; Thu, 13 Feb 2020 07:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581607946; cv=none; d=google.com; s=arc-20160816; b=kIqhip8FRziIR95C11esmTXlp+TG+N1GIi128wwV93HUdNgakQjQE36Od+NCzslN3E 0QrAkUjLcQ8k8MgmAgg76wlCQ3VgrKBnvMi1S7jtQwxknOyhe9HyCeU9Pu5l1Qsh6Bau ymEO4ZtiaXgNf0kjxMFA3a09rCgJRE2MTeV+W+bYwTImRfhNzxu2AUojR7WG4ggYi7/+ Y1oClL/5+/gWHIrafT3899xFZWOcNWY9/UjoL/oeXH/H3UoxUliMbdY62Ze9QfJ7leno BiALDRqJAjucUP/Tz0QxcdYhUGlShbTgYLLFeJd3ZuyR0dkY1dEzFKCvMHNkOdVKdDc7 88+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hmunCsl0XMDp8NySLWdgd6508bipnT7NRST1kkSu73s=; b=HcZhlCM3TDI7SogGaTUf14mZI3B+UHB4HwOgVWTKQYFM8LpuF3m3/m/cNgDBSvS9Em Q87t5CmJMDLNooykvbAFCw/QFreBDgJ4PYRLM1cVY9Q0LTWBNCEU2cuKd6E0fzJgs/a5 d/RLbYlSfJwDGl5SWtDiReYPOQ5mqcjjFFtb+7pxE/jLYacgAqfyYV0gIWkKfO2W4yqi eV2QRKOPlL6T2fv5CBdM1rhmFe9JyIPB6/jwXYhbHX4MrNXl6nuBt1kfw3ebnpfsETAZ a3I62q+tO2jxlNNviFpZeYniGRXWZmYEhFYX0KQu6D30WKnzeO+IQ4uFFkZpMbqFEcIO 2G3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=flr+kXad; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si1320508otp.236.2020.02.13.07.32.14; Thu, 13 Feb 2020 07:32:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=flr+kXad; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388007AbgBMPbH (ORCPT + 99 others); Thu, 13 Feb 2020 10:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:52460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387471AbgBMP1q (ORCPT ); Thu, 13 Feb 2020 10:27:46 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 833A3222C2; Thu, 13 Feb 2020 15:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607665; bh=30lIdOgIR4E5Pr2Mp9zRhzVtOzIvckW45ctdrOnh4AM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flr+kXadkGPgkWfDBQ5iBakSQwip1NlFXJPWxGM2tbx5P4R4KXlzqzDmgFmb7+nCt jtsTM7DVmNMBJfgumC7sZfaNsRhY09r7wuPgwe4/dlzfPSZyE56FBY8i/ZBtUSYahF 0sSRXZm4kGN8+iF7uR3qOQordvdYoWNMZRYSfJ1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Smalley , Ondrej Mosnacek , Paul Moore Subject: [PATCH 5.4 86/96] selinux: fix regression introduced by move_mount(2) syscall Date: Thu, 13 Feb 2020 07:21:33 -0800 Message-Id: <20200213151911.459785249@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Smalley commit 98aa00345de54b8340dc2ddcd87f446d33387b5e upstream. 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: Greg Kroah-Hartman --- security/selinux/hooks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2766,6 +2766,14 @@ static int selinux_mount(const char *dev 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(); @@ -6835,6 +6843,8 @@ static struct security_hook_list selinux 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),