mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
ima: don't measure/appraise files on configfs
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: [email protected] Link: https://lore.kernel.org/all/[email protected]/ Suggested-by: Mimi Zohar <[email protected]> Signed-off-by: Frederick Lawler <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
This commit is contained in:
1 parent
ab84c31441
commit
8e22ce504f
2 files changed
+9
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in new issue
Block a user