Re: [PATCH v2] audit: add FSCONFIG auxiliary record to log filesystem configuration

Steve Grubb <[email protected]> Wed, 29 Jul 2026 14:11:19 -0400
Newsgroups org.kernel.vger.audit,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Organization Red Hat
Message-ID <[email protected]>
On Tuesday, July 28, 2026 4:35:20=E2=80=AFPM Eastern Daylight Time Paul Moo=
re wrote:
> On Jul 27, 2026 Ricardo Robaina <[email protected]> wrote:
> > Modern mount tools (util-linux >=3D 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 fsconfig syscall but
> > does not capture the configuration parameters, creating an audit gap fo=
r
> > critical mount information such as the device being mounted.
> >=20
> > Add an FSCONFIG auxiliary record that logs the command type, parameter
> > name (key), parameter value, and aux parameter passed to fsconfig(2).
> >=20
> >  ----
> >  type=3DSYSCALL : syscall=3Dfsconfig ... a1=3DFSCONFIG_SET_STRING ...
> >  type=3DFSCONFIG : fs_cmd=3D1 fs_key=3Dsource fs_val=3D"tmpfs" fs_aux=
=3D0
> >  ----
> >  type=3DSYSCALL : syscall=3Dfsconfig ... a1=3DFSCONFIG_CMD_CREATE ...
> >  type=3DFSCONFIG : fs_cmd=3D6 fs_key=3D(null) fs_val=3D(null) fs_aux=3D=
0
> >  ----
> >  type=3DSYSCALL : syscall=3Dfsconfig ... a1=3DFSCONFIG_SET_BINARY ...
> >  type=3DFSCONFIG : fs_cmd=3D2 fs_key=3Dhidepid fs_val=3D"<binary>" fs_a=
ux=3D4
> >=20
> > Link: https://github.com/linux-audit/audit-kernel/issues/153
> > Acked-by: Christian Brauner <[email protected]>
> > Signed-off-by: Ricardo Robaina <[email protected]>
> > ---
> > Changes in v2:
> > - Fixed null-check for fs_key field.
> > - Clarified trimmed SYSCALL output in commit message examples.
> >=20
> >  fs/fsopen.c                |  7 +++++++
> >  include/linux/audit.h      | 13 +++++++++++++
> >  include/uapi/linux/audit.h |  1 +
> >  kernel/auditsc.c           | 27 +++++++++++++++++++++++++++
> >  4 files changed, 48 insertions(+)
> >=20
> > diff --git a/fs/fsopen.c b/fs/fsopen.c
> > index ae19e5136598..9b3c02f59df4 100644
> > --- a/fs/fsopen.c
> > +++ b/fs/fsopen.c
> > @@ -15,6 +15,7 @@
> >=20
> >  #include <linux/namei.h>
> >  #include <linux/file.h>
> >  #include <uapi/linux/mount.h>
> >=20
> > +#include <linux/audit.h>
> >=20
> >  #include "internal.h"
> >  #include "mount.h"
> >=20
> > @@ -357,6 +358,7 @@ SYSCALL_DEFINE5(fsconfig,
> >=20
> >  =09struct fs_context *fc;
> >  =09int ret;
> >  =09int lookup_flags =3D 0;
> >=20
> > +=09const char *value_str =3D NULL;
> >=20
> >  =09struct fs_parameter param =3D {
> >  =09
> >  =09=09.type=09=3D fs_value_is_undefined,
> >=20
> > @@ -423,6 +425,7 @@ SYSCALL_DEFINE5(fsconfig,
> >=20
> >  =09=09=09goto out_key;
> >  =09=09
> >  =09=09}
> >  =09=09param.size =3D strlen(param.string);
> >=20
> > +=09=09value_str =3D param.string;
> >=20
> >  =09=09break;
> >  =09
> >  =09case FSCONFIG_SET_BINARY:
> >  =09=09param.type =3D fs_value_is_blob;
> >=20
> > @@ -432,6 +435,7 @@ SYSCALL_DEFINE5(fsconfig,
> >=20
> >  =09=09=09ret =3D PTR_ERR(param.blob);
> >  =09=09=09goto out_key;
> >  =09=09
> >  =09=09}
> >=20
> > +=09=09value_str =3D "<binary>";
>=20
> Is there a reason why we're not logging the binary data?  We might want
> to impose a size limit to truncate the logged data (although we have
> provisions to log rather large binary chunks), but I don't see a reason
> why we couldn't log the binary data as a hex string.

I did a search for any user of this. There are no known consumers. Last=20
February, fsparam_blob() / fs_param_is_blob parser support was removed. Tha=
t=20
means we don't really have a use case. If, for example, someone decided to=
=20
use this API to insert a private key used for decryption or something, we=
=20
probably don't want that in logs. So, without an actual use case, it's hard=
=20
to say if logging this would be a liability or something needed. But yes, i=
t=20
could be done with the hex string encoding if required.

-Steve


> >  =09=09break;
> >  =09
> >  =09case FSCONFIG_SET_PATH_EMPTY:
> >  =09=09lookup_flags =3D LOOKUP_EMPTY;
> >=20
> > @@ -445,6 +449,7 @@ SYSCALL_DEFINE5(fsconfig,
> >=20
> >  =09=09}
> >  =09=09param.dirfd =3D aux;
> >  =09=09param.size =3D strlen(param.name->name);
> >=20
> > +=09=09value_str =3D param.name->name;
> >=20
> >  =09=09break;
> >  =09
> >  =09case FSCONFIG_SET_FD:
> >  =09=09param.type =3D fs_value_is_file;
> >=20
> > @@ -458,6 +463,8 @@ SYSCALL_DEFINE5(fsconfig,
> >=20
> >  =09=09break;
> >  =09
> >  =09}
> >=20
> > +=09audit_log_fsconfig(cmd, param.key, value_str, aux);
> > +
> >=20
> >  =09ret =3D mutex_lock_interruptible(&fc->uapi_mutex);
> >  =09if (ret =3D=3D 0) {
> >  =09
> >  =09=09ret =3D vfs_fsconfig_locked(fc, cmd, &param);
>=20
> ...
>=20
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index 6610e667c728..fefc5c5dd4aa 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -2882,6 +2882,33 @@ void __audit_log_nfcfg(const char *name, u8 af,
> > unsigned int nentries,>=20
> >  }
> >  EXPORT_SYMBOL_GPL(__audit_log_nfcfg);
> >=20
> > +void __audit_log_fsconfig(unsigned int cmd, const char *key,
> > +=09=09=09  const char *value, int aux)
> > +{
> > +=09struct audit_buffer *ab;
> > +
> > +=09ab =3D audit_log_start(audit_context(), GFP_KERNEL, AUDIT_FSCONFIG)=
;
> > +=09if (!ab)
> > +=09=09return;
> > +
> > +=09audit_log_format(ab, "fs_cmd=3D%u", cmd);
> > +=09audit_log_format(ab, " fs_key=3D");
>=20
> Calling into audit_log_format() is expensive due to the string
> processing, we should combine this into a single audit_log_format()
> call:
>=20
>  audit_log_format(ab, "fs_cmd=3D%u fs_key=3D", cmd);
>=20
> > +=09if (key)
> > +=09=09audit_log_untrustedstring(ab, key);
> > +=09else
> > +=09=09audit_log_format(ab, "(null)");
> > +
> > +=09audit_log_format(ab, " fs_val=3D");
> > +=09if (value)
> > +=09=09audit_log_untrustedstring(ab, value);
> > +=09else
> > +=09=09audit_log_format(ab, "(null)");
> > +
> > +=09audit_log_format(ab, " fs_aux=3D%d", aux);
> > +
> > +=09audit_log_end(ab);
> > +}
> > +
> >=20
> >  static void audit_log_task(struct audit_buffer *ab)
> >  {
> > =20
> >  =09kuid_t auid, uid;
>=20
> --
> paul-moore.com