From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796094654; b=mU2hISCF22BkMw77xdDv0fl3P8gLmVyHAujnxWYC0L4BbprTyex6nolbN/OAxAZ0C69H g3uN7qC2J5LdMaZEUhlpMwVLX7L067MDE1G5MeWlW+Kh8mnWviGlB77DusllN05me0YOT DJ82NxVo/+GHFRNwECzBurf5QFThepUA/1HvVhY33HpM1QI1LiaGtamQYl9I0LwJzlnOq v4Uf1gel74eoYExAYFV7q/MhaEA+3IJ6jC/Y/j5Wv2k8DcNWyOPkYcsswp7iz/Vm1rDeV TQRB9aKyVa/REpXuGMh95lSe0EeQ8nKZnzZcr6GF+453WeJ0Xj0R3qBdc7HsjTcqTdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796094654; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=LRHW7KrdJm+gSovgiGxVgPV1JxEhlGgGanpdp7fC2h8=; b=HyfHJ6lUNaGnQjkOAiBbxAH42L2URpcVrm0Df45JDR1XsZoOsflopL87MSnTWQABcDPp B5KDy+VXuYFQTE9OIiXgW7YZtgXtrE1V5hMYfXGDEq/A8Ua/bcbPbUj9Z0h09MIqFSitp Xzw51O7tQ1tDX8gVsJfLv5GzfknPoPCGE8HYk0yrO2Ko599loaWZRCkInmaQpjtrb1ejr 7eB1Hnsf29s+wZL6n+jDApScBTS3ioXmI0YID4dqTnYg5eU9lpNP8WALcHxMnwh/pIy8n sJUEYSY15xZ7Wz8ASuKAP2uS20A8CzZOPdHfPbTmZpaTYJxCuw7NXnI0g4OvoN6ZlaQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=beBOVXyV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id F1795606A320; Tue, 1 Dec 2026 03:10:53 +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=beBOVXyV Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id C27E31F0089A; Tue, 1 Dec 2026 03:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796094653; bh=LRHW7KrdJm+gSovgiGxVgPV1JxEhlGgGanpdp7fC2h8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=beBOVXyVmuFk7xqnHMrn3pVifniEWpBJxw722vooefm1gpTFJJGTe1gXBNpwqaZ1J NuRRqCTKnb/AlpUGcvQqhOCyvZmGfjpURlrKdi8l74qW3xWlHjV1R2yY2w0rJ3KUD5 rVPFBR+hPyhjJv6pYYgdIz6HBMmEXq25pOqY5UJniE0hA2JIxM55y8ei+m6KYZ+GG+ 1ZKeZTqmmNX6JLyLbZ25c2Gld6PBxVqtnCjVmQfJlk+YwkY+R50bIwl0wXlz17ql24 rI9ozPvCNEIbdS2pZ5oJnPiJCy3cONCC/q+yBHObw9SHXZkolrYooxy0y/r9naOHYE KU19oI4Jj9QWA== 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 v9 07/29] security: Pass flags to security_move_mount() Date: Tue, 1 Dec 2026 05:09:39 +0200 Message-ID: <20261201031002.593830-8-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201031002.593830-1-jarkko@kernel.org> References: <20261201031002.593830-1-jarkko@kernel.org> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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