From: Ricardo Robaina <rrobaina@redhat.com>
To: audit@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: paul@paul-moore.com, eparis@redhat.com, viro@zeniv.linux.org.uk,
brauner@kernel.org, jack@suse.cz, sgrubb@redhat.com,
Ricardo Robaina <rrobaina@redhat.com>
Subject: [PATCH] audit: add MOVE_MOUNT auxiliary record to log mount relocation
Date: Mon, 13 Jul 2026 14:00:35 -0300 [thread overview]
Message-ID: <20260713170035.4073532-1-rrobaina@redhat.com> (raw)
Modern mount tools (util-linux >= 2.39.1) use the new mount API
(fsopen, fsconfig, fsmount, move_mount) instead of the legacy mount(2)
syscall. The generic SYSCALL audit record logs the move_mount syscall
but does not capture the flags argument, creating an audit gap for
mount relocation operations.
Add a MOVE_MOUNT auxiliary record that logs the flags argument passed
to move_mount(2). Pathnames and file descriptors are captured through
existing PATH records and SYSCALL record arguments.
----
type=PATH : item=0 name=/mnt/test_src inode=1 dev=00:41 ...
type=SYSCALL : arch=x86_64 syscall=move_mount ...
type=MOVE_MOUNT : fs_flags=0x4
----
type=PATH : item=0 name=/mnt/test_dst inode=27460862 dev=fc:00 ...
type=SYSCALL : arch=x86_64 syscall=move_mount ...
type=MOVE_MOUNT : fs_flags=0x4
Link: https://github.com/linux-audit/audit-kernel/issues/152
Link: https://github.com/linux-audit/audit-kernel/issues/153
Signed-off-by: Ricardo Robaina <rrobaina@redhat.com>
---
fs/namespace.c | 3 +++
include/linux/audit.h | 10 ++++++++++
include/uapi/linux/audit.h | 1 +
kernel/auditsc.c | 13 +++++++++++++
4 files changed, 27 insertions(+)
diff --git a/fs/namespace.c b/fs/namespace.c
index 3d5cd5bf3b05..a6b0286744d9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -34,6 +34,7 @@
#include <linux/mnt_idmapping.h>
#include <linux/pidfs.h>
#include <linux/nstree.h>
+#include <linux/audit.h>
#include "pnode.h"
#include "internal.h"
@@ -4625,6 +4626,8 @@ SYSCALL_DEFINE5(move_mount,
if (flags & MOVE_MOUNT_F_EMPTY_PATH)
uflags = AT_EMPTY_PATH;
+ audit_log_move_mount(flags);
+
CLASS(filename_maybe_null,from_name)(from_pathname, uflags);
if (!from_name && from_dfd >= 0) {
CLASS(fd_raw, f_from)(from_dfd);
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 45abb3722d30..d1dc4035cb3c 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -449,6 +449,7 @@ extern void __audit_tk_injoffset(struct timespec64 offset);
extern void __audit_ntp_log(const struct audit_ntp_data *ad);
extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries,
enum audit_nfcfgop op, gfp_t gfp);
+extern void __audit_log_move_mount(unsigned int flags);
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
{
@@ -598,6 +599,12 @@ static inline void audit_log_nfcfg(const char *name, u8 af,
__audit_log_nfcfg(name, af, nentries, op, gfp);
}
+static inline void audit_log_move_mount(unsigned int flags)
+{
+ if (!audit_dummy_context())
+ __audit_log_move_mount(flags);
+}
+
extern int audit_n_rules;
extern int audit_signals;
#else /* CONFIG_AUDITSYSCALL */
@@ -730,6 +737,9 @@ static inline void audit_log_nfcfg(const char *name, u8 af,
enum audit_nfcfgop op, gfp_t gfp)
{ }
+static inline void audit_log_move_mount(unsigned int flags)
+{ }
+
#define audit_n_rules 0
#define audit_signals 0
#endif /* CONFIG_AUDITSYSCALL */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index e8f5ce677df7..40abf3dfd307 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -122,6 +122,7 @@
#define AUDIT_OPENAT2 1337 /* Record showing openat2 how args */
#define AUDIT_DM_CTRL 1338 /* Device Mapper target control */
#define AUDIT_DM_EVENT 1339 /* Device Mapper events */
+#define AUDIT_MOVE_MOUNT 1342 /* Record showing move_mount flags */
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 6610e667c728..4aca04d33d00 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2882,6 +2882,19 @@ void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries,
}
EXPORT_SYMBOL_GPL(__audit_log_nfcfg);
+void __audit_log_move_mount(unsigned int flags)
+{
+ struct audit_buffer *ab;
+
+ ab = audit_log_start(audit_context(), GFP_KERNEL,
+ AUDIT_MOVE_MOUNT);
+ if (!ab)
+ return;
+
+ audit_log_format(ab, "fs_flags=0x%x", flags);
+ audit_log_end(ab);
+}
+
static void audit_log_task(struct audit_buffer *ab)
{
kuid_t auid, uid;
--
2.53.0
next reply other threads:[~2026-07-13 17:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 17:00 Ricardo Robaina [this message]
2026-07-21 22:17 ` [PATCH] audit: add MOVE_MOUNT auxiliary record to log mount relocation Richard Guy Briggs
2026-07-22 15:59 ` Christian Brauner
2026-07-28 21:22 ` Paul Moore
2026-08-12 14:39 ` Ricardo Robaina
2026-08-12 16:00 ` Steve Grubb
2026-08-12 16:05 ` Paul Moore
2026-08-12 16:03 ` Paul Moore
2026-08-12 20:19 ` Steve Grubb
2026-08-12 20:43 ` Ricardo Robaina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260713170035.4073532-1-rrobaina@redhat.com \
--to=rrobaina@redhat.com \
--cc=audit@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=eparis@redhat.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sgrubb@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.