* [PATCH v2 0/2] ima: don't measure/appraise files on configfs
@ 2026-08-19 23:45 Frederick Lawler
2026-08-19 23:45 ` [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler
2026-08-19 23:45 ` [PATCH v2 2/2] ima: don't measure/appraise files on configfs Frederick Lawler
0 siblings, 2 replies; 7+ messages in thread
From: Frederick Lawler @ 2026-08-19 23:45 UTC (permalink / raw)
To: Andreas Hindborg, Breno Leitao, Mimi Zohar, Roberto Sassu,
Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris,
Serge E. Hallyn
Cc: linux-kernel, linux-integrity, linux-security-module, kernel-team,
Frederick Lawler, syzbot+448c2e24b1ceff13ed2a
IMA measurement of a configfs file causes process_measurement() to hold
iint->mutex while performing a kernel_read() to hash it, which re-enters
configfs's own file locking (buffer->mutex, frag_sem).
Separately, opening any file with O_TRUNC now causes ima_file_truncate()
to take iint->mutex to reset the cached action flags, while sb_writers is
already held for that mount.
When a configfs-backed nvmet namespace is involved, these two independent
lock chains combine into a cycle:
iint->mutex -> configfs locks -> subsys->lock -> sb_writers -> iint->mutex
Add configfs to the builtin don't measure/appraise rules, similarly to
other pseudo file systems, so IMA never takes iint->mutex for configfs
file in the first place.
Link: https://lore.kernel.org/all/6a77c7cd.b50370da.49fe0.0031.GAE@google.com/#t
Signed-off-by: Frederick Lawler <fred@cloudflare.com>
---
Changes in v2:
- Add CONFIGFS_MAGIC to IMA documentation in patch 2 (per shashiko)
- Update cover letter + commit message as suggested
- Link to v1: https://lore.kernel.org/r/20260818-configfs-v1-0-a2329043cf86@cloudflare.com
---
Frederick Lawler (2):
configfs: move CONFIGFS_MAGIC definition to magic.h
ima: don't measure/appraise files on configfs
Documentation/ABI/testing/ima_policy | 3 +++
fs/configfs/mount.c | 4 +---
include/uapi/linux/magic.h | 1 +
security/integrity/ima/ima_policy.c | 7 ++++++-
4 files changed, 11 insertions(+), 4 deletions(-)
---
base-commit: f1e10b10874051e4d99911dae0dd7b75a9f8ae66
change-id: 20260818-configfs-a248c410b083
Best regards,
--
Frederick Lawler <fred@cloudflare.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-19 23:45 [PATCH v2 0/2] ima: don't measure/appraise files on configfs Frederick Lawler @ 2026-08-19 23:45 ` Frederick Lawler 2026-08-25 14:10 ` Breno Leitao 2026-08-19 23:45 ` [PATCH v2 2/2] ima: don't measure/appraise files on configfs Frederick Lawler 1 sibling, 1 reply; 7+ messages in thread From: Frederick Lawler @ 2026-08-19 23:45 UTC (permalink / raw) To: Andreas Hindborg, Breno Leitao, Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn Cc: linux-kernel, linux-integrity, linux-security-module, kernel-team, Frederick Lawler IMA shouldn't measure or appraise configfs, but currently does because it's missing from the default exclusion policies. Move CONFIGFS_MAGIC to magic.h to expose the file system's magic to IMA, as well as other userland applications. Suggested-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Frederick Lawler <fred@cloudflare.com> --- fs/configfs/mount.c | 4 +--- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 4929f343118946eaa55a539db4192e9c6621a8dc..d8cac1cbf3bd573a0549f2f044714c9d669205a4 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -9,6 +9,7 @@ */ #include <linux/fs.h> +#include <linux/magic.h> #include <linux/module.h> #include <linux/mount.h> #include <linux/fs_context.h> @@ -19,9 +20,6 @@ #include <linux/configfs.h> #include "configfs_internal.h" -/* Random magic number */ -#define CONFIGFS_MAGIC 0x62656570 - static struct vfsmount *configfs_mount = NULL; struct kmem_cache *configfs_dir_cachep; static int configfs_mnt_count = 0; diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 4f2da935a76ccae6e1c3310b2fae5379186548b8..d5b9958ddfaae90b270b66fe7853c5a3d49ce739 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -8,6 +8,7 @@ #define AUTOFS_SUPER_MAGIC 0x0187 #define CEPH_SUPER_MAGIC 0x00c36400 #define CODA_SUPER_MAGIC 0x73757245 +#define CONFIGFS_MAGIC 0x62656570 /* some random number */ #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ #define DEBUGFS_MAGIC 0x64626720 -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-19 23:45 ` [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler @ 2026-08-25 14:10 ` Breno Leitao 2026-08-25 16:47 ` Frederick Lawler 0 siblings, 1 reply; 7+ messages in thread From: Breno Leitao @ 2026-08-25 14:10 UTC (permalink / raw) To: Frederick Lawler Cc: Andreas Hindborg, Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn, linux-kernel, linux-integrity, linux-security-module, kernel-team On Wed, Aug 19, 2026 at 06:45:22PM -0500, Frederick Lawler wrote: > IMA shouldn't measure or appraise configfs, but currently does because > it's missing from the default exclusion policies. Move CONFIGFS_MAGIC to > magic.h to expose the file system's magic to IMA, as well as other userland > applications. > > Suggested-by: Mimi Zohar <zohar@linux.ibm.com> > Signed-off-by: Frederick Lawler <fred@cloudflare.com> Do you want this change to go thorugh the configfs tree, or the tree specific for IMA? ? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-25 14:10 ` Breno Leitao @ 2026-08-25 16:47 ` Frederick Lawler 2026-08-25 17:49 ` Mimi Zohar 0 siblings, 1 reply; 7+ messages in thread From: Frederick Lawler @ 2026-08-25 16:47 UTC (permalink / raw) To: Breno Leitao Cc: Andreas Hindborg, Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn, linux-kernel, linux-integrity, linux-security-module, kernel-team Hi Breno, On Tue, Aug 25, 2026 at 07:10:02AM -0700, Breno Leitao wrote: > On Wed, Aug 19, 2026 at 06:45:22PM -0500, Frederick Lawler wrote: > > IMA shouldn't measure or appraise configfs, but currently does because > > it's missing from the default exclusion policies. Move CONFIGFS_MAGIC to > > magic.h to expose the file system's magic to IMA, as well as other userland > > applications. > > > > Suggested-by: Mimi Zohar <zohar@linux.ibm.com> > > Signed-off-by: Frederick Lawler <fred@cloudflare.com> > > Do you want this change to go thorugh the configfs tree, or the tree > specific for IMA? > ? Unless you have a user asking for it, I personally think it makes sense for linux-integrity to take it since the two patches are related. I don't mind spinning a v3 for integrity if you choose to take it now. Best, Fred PS. Sorry for not keeping the Reviewed-by tag from v1. I usually forget _something_ with re-spins until after the fact. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-25 16:47 ` Frederick Lawler @ 2026-08-25 17:49 ` Mimi Zohar 2026-08-26 8:07 ` Breno Leitao 0 siblings, 1 reply; 7+ messages in thread From: Mimi Zohar @ 2026-08-25 17:49 UTC (permalink / raw) To: Frederick Lawler, Breno Leitao Cc: Andreas Hindborg, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn, linux-kernel, linux-integrity, linux-security-module, kernel-team On Tue, 2026-08-25 at 11:47 -0500, Frederick Lawler wrote: > Hi Breno, > > On Tue, Aug 25, 2026 at 07:10:02AM -0700, Breno Leitao wrote: > > On Wed, Aug 19, 2026 at 06:45:22PM -0500, Frederick Lawler wrote: > > > IMA shouldn't measure or appraise configfs, but currently does because > > > it's missing from the default exclusion policies. Move CONFIGFS_MAGIC to > > > magic.h to expose the file system's magic to IMA, as well as other userland > > > applications. > > > > > > Suggested-by: Mimi Zohar <zohar@linux.ibm.com> > > > Signed-off-by: Frederick Lawler <fred@cloudflare.com> > > > > Do you want this change to go thorugh the configfs tree, or the tree > > specific for IMA? > > ? > > Unless you have a user asking for it, I personally think it makes sense > for linux-integrity to take it since the two patches are related. > > I don't mind spinning a v3 for integrity if you choose to take it now. > > Best, > Fred > > PS. Sorry for not keeping the Reviewed-by tag from v1. I usually > forget _something_ with re-spins until after the fact. Breno, thank you for the Reviewed-by. The patch set didn't quite make it in time for the open window, but I plan on upstreaming them. Can we change the Reviewed-by to an Acked-by? thanks, Mimi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-25 17:49 ` Mimi Zohar @ 2026-08-26 8:07 ` Breno Leitao 0 siblings, 0 replies; 7+ messages in thread From: Breno Leitao @ 2026-08-26 8:07 UTC (permalink / raw) To: Mimi Zohar Cc: Frederick Lawler, Andreas Hindborg, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn, linux-kernel, linux-integrity, linux-security-module, kernel-team On Tue, Aug 25, 2026 at 01:49:53PM -0400, Mimi Zohar wrote: > On Tue, 2026-08-25 at 11:47 -0500, Frederick Lawler wrote: > > Hi Breno, > > > > On Tue, Aug 25, 2026 at 07:10:02AM -0700, Breno Leitao wrote: > > > On Wed, Aug 19, 2026 at 06:45:22PM -0500, Frederick Lawler wrote: > > > > IMA shouldn't measure or appraise configfs, but currently does because > > > > it's missing from the default exclusion policies. Move CONFIGFS_MAGIC to > > > > magic.h to expose the file system's magic to IMA, as well as other userland > > > > applications. > > > > > > > > Suggested-by: Mimi Zohar <zohar@linux.ibm.com> > > > > Signed-off-by: Frederick Lawler <fred@cloudflare.com> > > > > > > Do you want this change to go thorugh the configfs tree, or the tree > > > specific for IMA? > > > ? > > > > Unless you have a user asking for it, I personally think it makes sense > > for linux-integrity to take it since the two patches are related. > > > > I don't mind spinning a v3 for integrity if you choose to take it now. > > > > Best, > > Fred > > > > PS. Sorry for not keeping the Reviewed-by tag from v1. I usually > > forget _something_ with re-spins until after the fact. > > Breno, thank you for the Reviewed-by. The patch set didn't quite make it in > time for the open window, but I plan on upstreaming them. Can we change the > Reviewed-by to an Acked-by? Sure. Feel free to do it. Acked-by: Breno Leitao <leitao@debian.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] ima: don't measure/appraise files on configfs 2026-08-19 23:45 [PATCH v2 0/2] ima: don't measure/appraise files on configfs Frederick Lawler 2026-08-19 23:45 ` [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler @ 2026-08-19 23:45 ` Frederick Lawler 1 sibling, 0 replies; 7+ messages in thread From: Frederick Lawler @ 2026-08-19 23:45 UTC (permalink / raw) To: Andreas Hindborg, Breno Leitao, Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn Cc: linux-kernel, linux-integrity, linux-security-module, kernel-team, Frederick Lawler, syzbot+448c2e24b1ceff13ed2a IMA measurement of a configfs file causes process_measurement() to hold iint->mutex while performing a kernel_read() to hash it, which re-enters configfs's own file locking (buffer->mutex, frag_sem). Separately, opening any file with O_TRUNC now causes ima_file_truncate() to take iint->mutex to reset the cached action flags, while sb_writers is already held for that mount. When a configfs-backed nvmet namespace is involved, these two independent lock chains combine into a cycle: iint->mutex -> configfs locks -> subsys->lock -> sb_writers -> iint->mutex Add configfs to the builtin don't measure/appraise rules, similarly to other pseudo file systems, so IMA never takes iint->mutex for configfs file in the first place. Reported-by: syzbot+448c2e24b1ceff13ed2a@syzkaller.appspotmail.com Link: https://lore.kernel.org/all/6a77c7cd.b50370da.49fe0.0031.GAE@google.com/ Suggested-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Frederick Lawler <fred@cloudflare.com> --- Documentation/ABI/testing/ima_policy | 3 +++ security/integrity/ima/ima_policy.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy index 19258471b7b26b2c42c1ab2d11b4fd630b2e6f81..b8a763e4c9fb1a5ccca97518e80e0452554c9e96 100644 --- a/Documentation/ABI/testing/ima_policy +++ b/Documentation/ABI/testing/ima_policy @@ -108,6 +108,9 @@ Description: # NSFS_MAGIC dont_measure fsmagic=0x6e736673 dont_appraise fsmagic=0x6e736673 + # CONFIGFS_MAGIC + dont_measure fsmagic=0x62656570 + dont_appraise fsmagic=0x62656570 measure func=BPRM_CHECK measure func=FILE_MMAP mask=MAY_EXEC diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index f79d07bb63c6fc4ba6fe594140de8d59f57e4f0b..68d9a5e6c232ea0678e9f51f105cebecccccb43e 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -165,7 +165,10 @@ static struct ima_rule_entry dont_measure_rules[] __ro_after_init = { {.action = DONT_MEASURE, .fsmagic = CGROUP2_SUPER_MAGIC, .flags = IMA_FSMAGIC}, {.action = DONT_MEASURE, .fsmagic = NSFS_MAGIC, .flags = IMA_FSMAGIC}, - {.action = DONT_MEASURE, .fsmagic = EFIVARFS_MAGIC, .flags = IMA_FSMAGIC} + {.action = DONT_MEASURE, .fsmagic = EFIVARFS_MAGIC, + .flags = IMA_FSMAGIC}, + {.action = DONT_MEASURE, .fsmagic = CONFIGFS_MAGIC, + .flags = IMA_FSMAGIC} }; static struct ima_rule_entry original_measurement_rules[] __ro_after_init = { @@ -211,6 +214,8 @@ static struct ima_rule_entry default_appraise_rules[] __ro_after_init = { {.action = DONT_APPRAISE, .fsmagic = EFIVARFS_MAGIC, .flags = IMA_FSMAGIC}, {.action = DONT_APPRAISE, .fsmagic = CGROUP_SUPER_MAGIC, .flags = IMA_FSMAGIC}, {.action = DONT_APPRAISE, .fsmagic = CGROUP2_SUPER_MAGIC, .flags = IMA_FSMAGIC}, + {.action = DONT_APPRAISE, .fsmagic = CONFIGFS_MAGIC, + .flags = IMA_FSMAGIC}, #ifdef CONFIG_IMA_WRITE_POLICY {.action = APPRAISE, .func = POLICY_CHECK, .flags = IMA_FUNC | IMA_DIGSIG_REQUIRED}, -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-26 8:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-19 23:45 [PATCH v2 0/2] ima: don't measure/appraise files on configfs Frederick Lawler 2026-08-19 23:45 ` [PATCH v2 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler 2026-08-25 14:10 ` Breno Leitao 2026-08-25 16:47 ` Frederick Lawler 2026-08-25 17:49 ` Mimi Zohar 2026-08-26 8:07 ` Breno Leitao 2026-08-19 23:45 ` [PATCH v2 2/2] ima: don't measure/appraise files on configfs Frederick Lawler
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox