* [PATCH 0/2] ima: don't measure/appraise files on configfs
@ 2026-08-18 19:35 Frederick Lawler
2026-08-18 19:35 ` [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler
2026-08-18 19:35 ` [PATCH 2/2] ima: don't measure/appraise files on configfs Frederick Lawler
0 siblings, 2 replies; 6+ messages in thread
From: Frederick Lawler @ 2026-08-18 19:35 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
When IMA appraises/measures a file configfs, it has an opportunity to
hold onto the ima_iint_mutex while another file from a different file
system is attempting to appraise/measure. This may cause a cyclical
lock dependency.
Add configfs to the default don't measure/appraise lists, similarly to
other pseudo file systems.
Link: https://lore.kernel.org/all/6a77c7cd.b50370da.49fe0.0031.GAE@google.com/#t
Signed-off-by: Frederick Lawler <fred@cloudflare.com>
---
Frederick Lawler (2):
configfs: move CONFIGFS_MAGIC definition to magic.h
ima: don't measure/appraise files on configfs
fs/configfs/mount.c | 4 +---
include/uapi/linux/magic.h | 1 +
security/integrity/ima/ima_policy.c | 7 ++++++-
3 files changed, 8 insertions(+), 4 deletions(-)
---
base-commit: f1e10b10874051e4d99911dae0dd7b75a9f8ae66
change-id: 20260818-configfs-a248c410b083
Best regards,
--
Frederick Lawler <fred@cloudflare.com>
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-18 19:35 [PATCH 0/2] ima: don't measure/appraise files on configfs Frederick Lawler @ 2026-08-18 19:35 ` Frederick Lawler 2026-08-19 9:21 ` Breno Leitao 2026-08-18 19:35 ` [PATCH 2/2] ima: don't measure/appraise files on configfs Frederick Lawler 1 sibling, 1 reply; 6+ messages in thread From: Frederick Lawler @ 2026-08-18 19:35 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] 6+ messages in thread
* Re: [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-18 19:35 ` [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler @ 2026-08-19 9:21 ` Breno Leitao 2026-08-19 14:39 ` Frederick Lawler 0 siblings, 1 reply; 6+ messages in thread From: Breno Leitao @ 2026-08-19 9:21 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 Tue, Aug 18, 2026 at 02:35:15PM -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> Reviewed-by: Breno Leitao <leitao@debian.org> > +#define CONFIGFS_MAGIC 0x62656570 /* some random number */ 0x62656570 is ASCII "beep", I didn't know that :-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h 2026-08-19 9:21 ` Breno Leitao @ 2026-08-19 14:39 ` Frederick Lawler 0 siblings, 0 replies; 6+ messages in thread From: Frederick Lawler @ 2026-08-19 14:39 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 On Wed, Aug 19, 2026 at 02:21:58AM -0700, Breno Leitao wrote: > On Tue, Aug 18, 2026 at 02:35:15PM -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> > > Reviewed-by: Breno Leitao <leitao@debian.org> > > > +#define CONFIGFS_MAGIC 0x62656570 /* some random number */ > > 0x62656570 is ASCII "beep", I didn't know that :-) I can't tell if it's a better joke to leave "some random number" as the comment, or to change the comment to the more interesting fun fact about the number. Best, Fred ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] ima: don't measure/appraise files on configfs 2026-08-18 19:35 [PATCH 0/2] ima: don't measure/appraise files on configfs Frederick Lawler 2026-08-18 19:35 ` [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler @ 2026-08-18 19:35 ` Frederick Lawler 2026-08-19 18:39 ` Mimi Zohar 1 sibling, 1 reply; 6+ messages in thread From: Frederick Lawler @ 2026-08-18 19:35 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 When IMA appraises/measures a file configfs, it has an opportunity to hold onto the ima_iint_mutex while another file from a different file system is attempting to appraise/measure. This may cause a cyclical lock dependency. Add configfs to the default don't measure/appraise lists, similarly to other pseudo file systems. 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> --- security/integrity/ima/ima_policy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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] 6+ messages in thread
* Re: [PATCH 2/2] ima: don't measure/appraise files on configfs 2026-08-18 19:35 ` [PATCH 2/2] ima: don't measure/appraise files on configfs Frederick Lawler @ 2026-08-19 18:39 ` Mimi Zohar 0 siblings, 0 replies; 6+ messages in thread From: Mimi Zohar @ 2026-08-19 18:39 UTC (permalink / raw) To: Frederick Lawler, Andreas Hindborg, Breno Leitao, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris, Serge E. Hallyn Cc: linux-kernel, linux-integrity, linux-security-module, kernel-team, syzbot+448c2e24b1ceff13ed2a On Tue, 2026-08-18 at 14:35 -0500, Frederick Lawler wrote: > When IMA appraises/measures a file configfs, it has an opportunity to > hold onto the ima_iint_mutex while another file from a different file > system is attempting to appraise/measure. This may cause a cyclical > lock dependency. The locking description is off a bit. Suggested patch desciption from AI: 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. > > Add configfs to the default don't measure/appraise lists, similarly to > other pseudo file systems. > > 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> Sashiko is now enabled for the linux-integrity mailing list - https://sashiko.dev/#/?list=org.kernel.vger.linux-integrity. Please address Sashiko's 2/2 review. thanks, Mimi > --- > security/integrity/ima/ima_policy.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > 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}, ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-19 18:40 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-18 19:35 [PATCH 0/2] ima: don't measure/appraise files on configfs Frederick Lawler 2026-08-18 19:35 ` [PATCH 1/2] configfs: move CONFIGFS_MAGIC definition to magic.h Frederick Lawler 2026-08-19 9:21 ` Breno Leitao 2026-08-19 14:39 ` Frederick Lawler 2026-08-18 19:35 ` [PATCH 2/2] ima: don't measure/appraise files on configfs Frederick Lawler 2026-08-19 18:39 ` Mimi Zohar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox