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 867FC606A6AE for ; Sat, 5 Dec 2026 03:27:55 +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=YJ+n4cpX Received: by kanga.kvack.org (Postfix) id 2CCFA6B05BE; Fri, 4 Dec 2026 22:27:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27DE86B05BF; Fri, 4 Dec 2026 22:27:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16D5E6B05C0; Fri, 4 Dec 2026 22:27:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7F8186B05BE for ; Fri, 4 Dec 2026 22:27:16 -0500 (EST) Received: from smtpin02.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E1DC91202E5 for ; Sat, 5 Dec 2026 03:27:15 +0000 (UTC) X-FDA: 85508493630.02.FE297D0 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf01.hostedemail.com (Postfix) with ESMTP id 3B37F40003 for ; Sat, 5 Dec 2026 03:27:14 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=YJ+n4cpX; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of jarkko@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796441234; b=t5uwnTCdmDRvNhZH3I4H7ZAz6RpCimC9EAAkRT9vozp8R23eCZb2+663B6GjNsdfgRRmae f0bTBNTT7qeCsNM4RGlZe1rKJqdMlHymoUVOxgfi2QU2q6rB/aTJcprr7pr+6IPDbdgzug C7zkJnEdgYOuPqc12S7MkqIZiO7XPio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796441234; 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=DZJHX/5L1Cxjcb5Povkq6vbW/tMK1sGrZDF0E+YGCrg=; b=Jin288v86ZCNKDOHaDFgAUU00lEiu97hozlq0ElFN0QxmyxXYc8qNLpfaSrKbVRaUjQrsq urSo9mma8ZQnXoC7+QJsiylqN2IuTKc/p94vNXUQJ4m6+fDaFrIEQzrElZtNupbtZmbs6H wSJAM2ClJjKclFxfb9Te3uUGd4HENP0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=YJ+n4cpX; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of jarkko@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=jarkko@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with UTF8SMTP id A07D84052F; Sat, 5 Dec 2026 03:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id CBD1B1F00AD7; Sat, 5 Dec 2026 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796441233; bh=DZJHX/5L1Cxjcb5Povkq6vbW/tMK1sGrZDF0E+YGCrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YJ+n4cpXo82DRpn6Qi4eNtcDGbLd0tjJSqxIojbjuvIVTn1hTqA4GGBmp4Ipcw46z aj4yl8BE+WP+i8IfJpeXmhwYs4dfALGP+8jN+ZP7Nsqpyr8KhHAgG8xA7gE4Pb1Bqr PHQMRMhVP8akNAGpMjeZmCVL+oaAnlXN55up5MEGHehOGm25+UXB/N1Q/hgm+JpclD x3RA1GYGxkGDML6d26LGMeF9EcJuShyj45lympivk3xn1OLlj8VSVEjsS088XdndLI XqIV5sJsmEw94JZ5yzZJUKk7/Swb1MgZgWMjuAez4G3ZatG3HnNUtl2mqKfbQGkfmd Z3lMBeouH/J9g== 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-integrity@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 , Alexei Starovoitov , Andrew Morton , Andrii Nakryiko , Andy Lutomirski , Arnd Bergmann , Baolin Wang , Ben Segall , Christian Brauner , Daniel Borkmann , David Hildenbrand , David Howells , David Woodhouse , Davidlohr Bueso , Dietmar Eggemann , Eduard Zingerman , Emil Tsalapatis , Eric Biggers , Georgia Garcia , Giuseppe Scrivano , =?UTF-8?q?G=C3=BCnther=20Noack?= , Hugh Dickins , Ihor Solodrai , Ingo Molnar , James Morris , Jan Kara , Jason Gunthorpe , Jeff Layton , Jiri Olsa , John Johansen , Jonathan Corbet , Josef Bacik , Juri Lelli , Kees Cook , K Prateek Nayak , KP Singh , Kumar Kartikeya Dwivedi , Lennart Poettering , "Liam R. Howlett" , Manfred Spraul , Martin KaFai Lau , Matt Bobrowski , Mel Gorman , Michal Hocko , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Mike Rapoport , Neal Gompa , Oleg Nesterov , Paul Moore , Pavel Tikhomirov , Peter Zijlstra , Randy Dunlap , "Serge E. Hallyn" , Serge Hallyn , Shuah Khan , Song Liu , Stephen Smalley , Steven Rostedt , Valentin Schneider , Vincent Guittot , Yonghong Song , Zygmunt Krynicki Subject: [RFC PATCH v10 06/28] security: Pass flags to security_move_mount() Date: Sat, 5 Dec 2026 05:26:11 +0200 Message-ID: <20261205032633.1702772-7-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261205032633.1702772-1-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspam-User: X-Rspamd-Queue-Id: 3B37F40003 X-Stat-Signature: yrihek6exzia1371ojk8o5jh5c86ewnp X-Spam-Status: No, score=-19.1 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: 1796441234-363737 X-HE-Meta: U2FsdGVkX19T1vYxhvVUAvbbAFlguA6G0mmdC7m4GEHeTG6N9GBw8SmQsBCEZ/UNeJQoYnuheqAnyvAzhXcE9IV85YzYDfd8sJ1BoyvuydBxTrZrrnbmcG9oBphT2sFlqgPMTbzvYy2sigEadpz3Tp4DPACO028vF+Z/SL0vKOTFKEYiG+3K+tVgvZLmuWdddzZuTUk2KXLSTiW6/RJkJJRyDKbF5B/t+0qcATid4hvLMVlv2FOppmhNhaUyfVjCkbvReUCmUs/p783Ax2gGLMjLVYrAfahZqcbewcd2pK7UIPkDS424NCDscRIa3yQLzpkeGF7+sz9d5tSzUobptBhqf8kzVLGR5UBFlIQlif1W3aOks3/TjGCgZjqJuyCxOtvYW4yMmtaoZKPObtQWuNmStTWTwHMcTozEM5vjOFfUswHcef61lOK8hlob2kBIZJ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-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 45a7f9547c8e..d73a215c9ae5 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4781,12 +4781,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; @@ -4908,8 +4909,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); } /* @@ -4979,7 +4980,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 c50f833d55a6..c93c94103d2e 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 5f6a81868341..efa003d0e142 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2835,7 +2835,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