From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83F36606A331 for ; Sat, 28 Nov 2026 23:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mWoWwRH6 Received: by kanga.kvack.org (Postfix) id 04E456B05BD; Sat, 28 Nov 2026 18:58:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0262E6B05BE; Sat, 28 Nov 2026 18:58:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4DA6B05BF; Sat, 28 Nov 2026 18:58:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C626A6B05BD for ; Sat, 28 Nov 2026 18:58:49 -0500 (EST) Received: from smtpin07.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 510DA407C0 for ; Sat, 28 Nov 2026 23:58:49 +0000 (UTC) X-FDA: 85486195578.07.3898B3C Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf26.hostedemail.com (Postfix) with ESMTP id 8B58F140003 for ; Sat, 28 Nov 2026 23:58:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=mWoWwRH6; spf=pass (imf26.hostedemail.com: domain of jarkko@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1795910327; b=TMFBjVNWiL3h2ZVQmOddOVGPetyqhIsKYTj91Pkq93ShZ13Pmw2Xnv7BZsr770nlM8ooKG t2CLytJH60u1K2p/+KvrmuLViR/z6UVeAzJGcoX3fCEhy7K+m8TRo65KAqPac+F/fP6gCz Lcjxurlcj9TkeyAbfqED3mXUXuf3YAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1795910327; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LRHW7KrdJm+gSovgiGxVgPV1JxEhlGgGanpdp7fC2h8=; b=XLKQfcQuHYgouZ6lwSGzRY3/g7xU7bJx6Dqj4n9jhwWZyg29L3xD8iZhNLhgypapm8aKlJ wfKRyGpl6vm++L8FT1QlTw6xmCYabA/TX3TYkm4TGs58r69X7LF2vv9CfeaVwJ/eROJedN KegerMTgftqcJrlFIa/+EjnNCaMfF1g= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=mWoWwRH6; spf=pass (imf26.hostedemail.com: domain of jarkko@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with UTF8SMTP id D1C3743BE3; Sat, 28 Nov 2026 23:58:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 11F3F1F00919; Sat, 28 Nov 2026 23:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795910326; bh=LRHW7KrdJm+gSovgiGxVgPV1JxEhlGgGanpdp7fC2h8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mWoWwRH6YQYjuiKy5R0+pv70rAljmLwPQy28XtHP7o4rSBnj8Qzjt1uZ8394WYly3 15kpegVxvaGpbD/F448KNTO1V40TwrjzOawxPfYPisZptN+damIIVzf2oMY/ZWtUK3 Zkgfkt/YhaKal8cxtuiCdTJabvMyb19dDuOx/YvqXjMzQVx/XVQG/5/IxfSe8MoLyQ x+3xaczTJprH3lPrCUscdRchf6T4LrKzDZI9prUd+ElJTvC2MomZVonGbQEy/0rdpm VLCpzCoe2SPXfypgVxWVXPRcTS/8LQNwTgE4jlP3IQTlaaSmJ8TF1lC/jtlPP0BeHH W8UxVIutpgz+w== From: Jarkko Sakkinen To: fsdevel@vger.kernel.org Cc: Jarkko Sakkinen , bpf@vger.kernel.org, containers@lists.linux.dev, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, Aleksa Sarai , Alexander Mikhalitsyn , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Christian Brauner , David Howells , Eric Biggers , Georgia Garcia , Giuseppe Scrivano , Hugh Dickins , James Morris , Jan Kara , Jeff Layton , John Johansen , Jonathan Corbet , Josef Bacik , Kees Cook , KP Singh , Lennart Poettering , Matt Bobrowski , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Neal Gompa , Oleg Nesterov , Paul Moore , Pavel Tikhomirov , Serge Hallyn , Shuah Khan , Stephen Smalley , Zygmunt Krynicki Subject: [RFC PATCH v8 07/29] security: Pass flags to security_move_mount() Date: Sun, 29 Nov 2026 01:57:46 +0200 Message-ID: <20261128235808.2369970-8-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261128235808.2369970-1-jarkko@kernel.org> References: <20261128235808.2369970-1-jarkko@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 8B58F140003 X-Stat-Signature: wzfxwgj68yt9kb3beqzejtfiq8q7s9in X-Rspamd-Server: rspam12 X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1795910327-797381 X-HE-Meta: U2FsdGVkX1/RIzWMPWn7FKFUiNr32AlxWe2r8Vju3nJ6p3BQR2FNXgsM4xAv4tfrZuoaD0hSx+5qhgd/QeErUqlUplr1kRRInf0VGz0YH5Nwfv73d73TTyErXoKnC/w8FgQ12AQ6OAi0HHNBLZ1f0rfK/dLgDLpBuE1qWcpniekAIz9V5HDRke8VT6mBYKEsT4UKF72yoz/zvZO5hidaMkWiMtIdTcrX+dGxusZ+RuvLKepF7QPCfT2d4MP/Fp2rqfYCbUAdi8Hqjw6M0iPR81geFPmF5uvRHBU55P9j6hEJvyk4e0kaCzmcF+mmwuKwKbjxeBJ1VHqMh5mSY5485wRIwPsro6n7zONPmRxGEVzvndK1h6Dm4m5VtAGqV1f+r2WP5bFhth2eWN3/hwW1Rp3wbbWI5NC6r3HBi6SUoQKPBTJXhP4bbYPNHjh22FC+ePiFuNtdUP1snerTDxZj2X8R9UHHCzNTbwczBIl1QO08vaycc2KU9YM4OwnHWZ9Rop0LA6JbPIY807k7kV8gqI4tflKnTIKIbVAfBP0mp13dubx8m+A3j52t22MhvGNeeD1FHOTrlzLJ1sZx2xR7kUfYUlbOXEAWDuCRylEWcT2apIqukNs60II7KQayQUZAcQ4z10iSnYodzGKzOtC29E4U0zxXoGvGHj8lqYmCcU6Pb5H/BrpgKoSdciZgNOoNDREIhAY7cpYdJFx69rqSwNMxGT/SjOBOCtvhooqfZndkHtIquwjk0Dr4uY8MuDN0ATekpbpfUgOTNHzrYpghhdT+JC4E0Ct9R/JLpDW71+lrrCbg3TA3kNc9pRnGI7TTbVLR16svJn1AQ1dp5EL4JI831PNTD6afrk1TLiGBET9HAFkG3Y92rdFx1xzuGIsds6l3KBQ8OYUJSoXufGvlGr6b0B7tv+wlmVRW8amG74aPBl/25wDnjxizoGfYm/xGIxVq/8IzwsSUisF1wHn RWnw5YHm zEJwoGqLIIlmF0P6xw23TLRBO4qMWCDfC7nlvCGV3KDTOB8kPSm2EWYiXrUb/p0SlUQRKXhy+2ZGj4pJM79sqpIk8yJ5QTMaTOpFPAXGERXJ+IsUyZJkCopexfDB93mH6Gxz9ZuBLjztoPRmcPCw2s86Bvk8YQ9QrzlYlGPBnoWif+OSPI3KI0d2x8ARGKRizFbYUEDtSYcKmS6rJPqG8DjLSxgbPZUSrZHah8fx3XAjP7rNTqdF1tkNK8QvRgRdCHfCP50Cjro+yb7NzPdlD7bb5/3/oZhV0pfXsR2ttlcEM/+HihA3qPf/LQGNxtwkK6CKPLJ5JfgVRIPxOPQR9MezU8DayEcXW8LBad+x5jSk/G2CsVUkDYZpE9zzf9GbOvKKw7z1gMdGAqJEchJnfE8LTwgEzPLTi5ZGb5dNU50aFbop9YOEdsu4BjbBh01ayBrrwwK25q9aUIArX67Yy5YQFEwoy4XOcXBZXnpmyUeNfVwsxeI/5xlBY0GpULMfv7eZNeEpawZ6WA3T72W7Aiv9KArNnh/4q5pEo Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Pass the MOVE_MOUNT_* flags from move_mount() to security_move_mount() and the move_mount LSM hook so security modules can distinguish mount operations that carry behavioral flags such as cloning versus moving. Signed-off-by: Jarkko Sakkinen --- fs/namespace.c | 9 +++++---- include/linux/lsm_hook_defs.h | 2 +- include/linux/security.h | 6 ++++-- security/apparmor/lsm.c | 2 +- security/landlock/fs.c | 3 ++- security/security.c | 7 ++++--- security/selinux/hooks.c | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 8eea00d1dbdb..fadc4c3b1fb2 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4782,12 +4782,13 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, static inline int vfs_move_mount(const struct path *from_path, const struct path *to_path, + unsigned int flags, enum mnt_tree_flags_t mflags, struct mnt_namespace *target_mnt_ns) { int ret; - ret = security_move_mount(from_path, to_path); + ret = security_move_mount(from_path, to_path, flags); if (ret) return ret; @@ -4909,8 +4910,8 @@ static int move_mount_mntns(int from_dfd, const char __user *from_pathname, if (ret) return ret; - return vfs_move_mount(&from_path, &to_path, mflags | MNT_TREE_MNTNS, - target_mnt_ns); + return vfs_move_mount(&from_path, &to_path, flags, + mflags | MNT_TREE_MNTNS, target_mnt_ns); } /* @@ -4980,7 +4981,7 @@ SYSCALL_DEFINE5(move_mount, if (ret) return ret; - return vfs_move_mount(&from_path, &to_path, mflags, NULL); + return vfs_move_mount(&from_path, &to_path, flags, mflags, NULL); } /* diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index 87d9d06710cb..005a350681c3 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -80,7 +80,7 @@ LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb, struct super_block *newsb, unsigned long kern_flags, unsigned long *set_kern_flags) LSM_HOOK(int, 0, move_mount, const struct path *from_path, - const struct path *to_path) + const struct path *to_path, unsigned int flags) LSM_HOOK(int, -EOPNOTSUPP, dentry_init_security, struct dentry *dentry, int mode, const struct qstr *name, const char **xattr_name, struct lsm_context *cp) diff --git a/include/linux/security.h b/include/linux/security.h index 40831fab5470..9c8f8da83251 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -387,7 +387,8 @@ int security_sb_clone_mnt_opts(const struct super_block *oldsb, struct super_block *newsb, unsigned long kern_flags, unsigned long *set_kern_flags); -int security_move_mount(const struct path *from_path, const struct path *to_path); +int security_move_mount(const struct path *from_path, + const struct path *to_path, unsigned int flags); int security_dentry_init_security(struct dentry *dentry, int mode, const struct qstr *name, const char **xattr_name, @@ -858,7 +859,8 @@ static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb, } static inline int security_move_mount(const struct path *from_path, - const struct path *to_path) + const struct path *to_path, + unsigned int flags) { return 0; } diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index eaebc3c60c5a..aefa71bc1cd2 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -742,7 +742,7 @@ static int apparmor_sb_mount(const char *dev_name, const struct path *path, } static int apparmor_move_mount(const struct path *from_path, - const struct path *to_path) + const struct path *to_path, unsigned int flags) { struct aa_label *label; int error = 0; diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 2ab67bcad198..32d882a79001 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1547,7 +1547,8 @@ static int hook_sb_mount(const char *const dev_name, } static int hook_move_mount(const struct path *const from_path, - const struct path *const to_path) + const struct path *const to_path, + unsigned int flags) { size_t handle_layer; const struct landlock_cred_security *const subject = diff --git a/security/security.c b/security/security.c index 4727b8347fc4..b4d60dcf4880 100644 --- a/security/security.c +++ b/security/security.c @@ -1185,15 +1185,16 @@ EXPORT_SYMBOL(security_sb_clone_mnt_opts); * security_move_mount() - Check permissions for moving a mount * @from_path: source mount point * @to_path: destination mount point + * @flags: MOVE_MOUNT_* flags * - * Check permission before a mount is moved. + * Check permission before a mount is moved or cloned. * * Return: Returns 0 if permission is granted. */ int security_move_mount(const struct path *from_path, - const struct path *to_path) + const struct path *to_path, unsigned int flags) { - return call_int_hook(move_mount, from_path, to_path); + return call_int_hook(move_mount, from_path, to_path, flags); } /** diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 6c4c64d6e904..67079105e9de 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2833,7 +2833,7 @@ static int selinux_mount(const char *dev_name, } static int selinux_move_mount(const struct path *from_path, - const struct path *to_path) + const struct path *to_path, unsigned int flags) { const struct cred *cred = current_cred(); -- 2.47.3