Skip to contentSkip to conversation

ima: add dont_audit and fs_subtype to policy language

PATCH In review Jann Horn 2 participants 8 messages Sep 25, 2025 – Oct 16, 2025

Subsystems (4)
lore
Share & tools
lore

Jann Horn

author
#0 lore raw

cover ima: add dont_audit and fs_subtype to policy language

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

---
Jann Horn (2):
ima: add dont_audit action to suppress audit actions
ima: add fs_subtype condition for distinguishing FUSE instances

 Documentation/ABI/testing/ima_policy |  3 +-
 security/integrity/ima/ima_policy.c  | 57 ++++++++++++++++++++++++++++++++----
 2 files changed, 54 insertions(+), 6 deletions(-)

---
base-commit: 00642a06d60c897a8348784e1eee9e5369219ce5
change-id: 20250925-ima-audit-8bd219dcc6f6

Signature · 1 line
Jann Horn <[email protected]>
author
#1 lore raw

PATCH 1/2 ima: add dont_audit action to suppress audit actions

"measure", "appraise" and "hash" actions all have corresponding "dont_*" actions, but "audit" currently lacks that. This means it is not currently possible to have a policy that audits everything by default, but excludes specific cases.

This seems to have been an oversight back when the "audit" action was added.

Add a corresponding "dont_audit" action to enable such uses.

---
 Documentation/ABI/testing/ima_policy |  2 +-
 security/integrity/ima/ima_policy.c  | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
Documentation/ABI/testing/ima_policy +1 -1
index c2385183826c..5d548dd2c6e7 100644
@@ -20,7 +20,7 @@ Description:
 		  rule format: action [condition ...]
 
 		  action: measure | dont_measure | appraise | dont_appraise |
-			  audit | hash | dont_hash
+			  audit | dont_audit | hash | dont_hash
 		  condition:= base | lsm  [option]
 			base:	[[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=]
 				[uid=] [euid=] [gid=] [egid=]
security/integrity/ima/ima_policy.c +13 -1
index 128fab897930..c5bad3a0c43a 100644
@@ -45,6 +45,7 @@
 #define APPRAISE	0x0004	/* same as IMA_APPRAISE */
 #define DONT_APPRAISE	0x0008
 #define AUDIT		0x0040
+#define DONT_AUDIT	0x0080
 #define HASH		0x0100
 #define DONT_HASH	0x0200
 
@@ -1064,7 +1065,7 @@ void ima_update_policy(void)
 enum policy_opt {
 	Opt_measure, Opt_dont_measure,
 	Opt_appraise, Opt_dont_appraise,
-	Opt_audit, Opt_hash, Opt_dont_hash,
+	Opt_audit, Opt_dont_audit, Opt_hash, Opt_dont_hash,
 	Opt_obj_user, Opt_obj_role, Opt_obj_type,
 	Opt_subj_user, Opt_subj_role, Opt_subj_type,
 	Opt_func, Opt_mask, Opt_fsmagic, Opt_fsname, Opt_fsuuid,
@@ -1086,6 +1087,7 @@ static const match_table_t policy_tokens = {
 	{Opt_appraise, "appraise"},
 	{Opt_dont_appraise, "dont_appraise"},
 	{Opt_audit, "audit"},
+	{Opt_dont_audit, "dont_audit"},
 	{Opt_hash, "hash"},
 	{Opt_dont_hash, "dont_hash"},
 	{Opt_obj_user, "obj_user=%s"},
@@ -1478,6 +1480,14 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
 
 			entry->action = AUDIT;
 			break;
+		case Opt_dont_audit:
+			ima_log_string(ab, "action", "dont_audit");
+
+			if (entry->action != UNKNOWN)
+				result = -EINVAL;
+
+			entry->action = DONT_AUDIT;
+			break;
 		case Opt_hash:
 			ima_log_string(ab, "action", "hash");
 
@@ -2097,6 +2107,8 @@ int ima_policy_show(struct seq_file *m, void *v)
 		seq_puts(m, pt(Opt_dont_appraise));
 	if (entry->action & AUDIT)
 		seq_puts(m, pt(Opt_audit));
+	if (entry->action & DONT_AUDIT)
+		seq_puts(m, pt(Opt_dont_audit));
 	if (entry->action & HASH)
 		seq_puts(m, pt(Opt_hash));
 	if (entry->action & DONT_HASH)
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
author
#2 lore raw

PATCH 2/2 ima: add fs_subtype condition for distinguishing FUSE instances

In reply to Jann Horn

Linux systems often use FUSE for several different purposes, where the contents of some FUSE instances can be of more interest for auditing than others.

Allow distinguishing between them based on the filesystem subtype (s_subtype) using the new condition "fs_subtype".

The subtype string is supplied by userspace FUSE daemons when a FUSE connection is initialized, so policy authors who want to filter based on subtype need to ensure that FUSE mount operations are sufficiently audited or restricted.

---
 Documentation/ABI/testing/ima_policy |  1 +
 security/integrity/ima/ima_policy.c  | 43 ++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)
Documentation/ABI/testing/ima_policy +1 -0
index 5d548dd2c6e7..d4b3696a9efb 100644
@@ -23,6 +23,7 @@ Description:
 			  audit | dont_audit | hash | dont_hash
 		  condition:= base | lsm  [option]
 			base:	[[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=]
+				[fs_subtype=]
 				[uid=] [euid=] [gid=] [egid=]
 				[fowner=] [fgroup=]]
 			lsm:	[[subj_user=] [subj_role=] [subj_type=]
security/integrity/ima/ima_policy.c +39 -4

109 lines not on this page · raw message

Signature · 1 line
2.51.0.536.g15c5d4f767-goog
maintainer
#3 lore raw
In reply to Jann Horn
Quoted 14 lines · Jann Horn

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

Quoted 7 lines
```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

Thanks, Jann. The patches look fine. Assuming the "toy" test program creates and mounts the fuse filesystems, not just loads the IMA policy rules, could you share it?

thanks,

Mimi

author
#4 lore raw
Quoted 21 lines · Mimi Zohar
Quoted 20 lines · Jann Horn

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

Quoted 6 lines
Quoted 1 line

Thanks, Jann. The patches look fine. Assuming the "toy" test program creates and mounts the fuse filesystems, not just loads the IMA policy rules, could you share it?

Thanks for the quick review! To clarify, by "toy example" I meant that while I was using real FUSE filesystems, the policy I was using is not very sensible.

I used real FUSE filesystems for this since I figured that would be the easiest way to test, https://github.com/libfuse/sshfs and
https://bitbucket.org/agalanin/fuse-zip. These are packaged in distros like Debian (as "sshfs" and "fuse-zip"). I mounted sshfs with these commands (mounting the home directory over ssh at ~/mnt/ssh):

user@vm:~$ cp /usr/bin/echo ~/ima/
user@vm:~$ sshfs localhost: ~/mnt/ssh

and mounted fuse-zip with:

user@vm:~/ima$ zip -rD echo.zip /usr/bin/echo
  adding: usr/bin/echo (deflated 62%)
user@vm:~/ima$ mkdir zipmount
user@vm:~/ima$ fuse-zip echo.zip zipmount/

I then ran the executables ~/ima/zipmount/usr/bin/echo and ~/mnt/ssh/ima/echo.

author
#7 lore raw
In reply to Mimi Zohar

Hi!

Quoted 21 lines · Mimi Zohar
Quoted 20 lines · Jann Horn

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

Quoted 4 lines
Quoted 1 line

Thanks, Jann. The patches look fine.

What's the next step here - are the patches going to land in the next-integrity branch, so that they will go into 6.19?

author
#6 lore raw
In reply to Mimi Zohar
Quoted 50 lines · Mimi Zohar
Quoted 49 lines · Jann Horn
Quoted 21 lines · Mimi Zohar
Quoted 20 lines · Jann Horn

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

Quoted 6 lines
Quoted 1 line

Thanks, Jann. The patches look fine. Assuming the "toy" test program creates and mounts the fuse filesystems, not just loads the IMA policy rules, could you share it?

Thanks for the quick review! To clarify, by "toy example" I meant that while I was using real FUSE filesystems, the policy I was using is not very sensible.

I used real FUSE filesystems for this since I figured that would be the easiest way to test, https://github.com/libfuse/sshfs and
https://bitbucket.org/agalanin/fuse-zip. These are packaged in distros like Debian (as "sshfs" and "fuse-zip"). I mounted sshfs with these commands (mounting the home directory over ssh at ~/mnt/ssh):

user@vm:~$ cp /usr/bin/echo ~/ima/
user@vm:~$ sshfs localhost: ~/mnt/ssh

and mounted fuse-zip with:

user@vm:~/ima$ zip -rD echo.zip /usr/bin/echo
  adding: usr/bin/echo (deflated 62%)
user@vm:~/ima$ mkdir zipmount
user@vm:~/ima$ fuse-zip echo.zip zipmount/
Quoted 4 lines
Quoted 1 line

I then ran the executables ~/ima/zipmount/usr/bin/echo and ~/mnt/ssh/ima/echo.

Thank you for the instructions. Due to the holidays, there was a delay. The patches are now queued in next-integrity for 6.19.

Thanks a lot!

maintainer
#5 lore raw
In reply to Jann Horn
Quoted 42 lines · Jann Horn
Quoted 21 lines · Mimi Zohar
Quoted 20 lines · Jann Horn

This series adds a "dont_audit" action that cancels out following "audit" actions (as we already have for other action types), and also adds an "fs_subtype" that can be used to distinguish between FUSE filesystems.

With these two patches applied, as a toy example, you can use the following policy:

```
dont_audit fsname=fuse fs_subtype=sshfs
audit func=BPRM_CHECK fsname=fuse
```

I have tested that with this policy, executing a binary from a "fuse-zip" FUSE filesystem results in an audit log entry:

```
type=INTEGRITY_RULE msg=audit([...]): file="/home/user/ima/zipmount/usr/bin/echo" hash="sha256:1d82e8[...]
```

while executing a binary from an "sshfs" FUSE filesystem does not generate any audit log entries.

Quoted 6 lines
Quoted 1 line

Thanks, Jann. The patches look fine. Assuming the "toy" test program creates and mounts the fuse filesystems, not just loads the IMA policy rules, could you share it?

Thanks for the quick review! To clarify, by "toy example" I meant that while I was using real FUSE filesystems, the policy I was using is not very sensible.

I used real FUSE filesystems for this since I figured that would be the easiest way to test, https://github.com/libfuse/sshfs and
https://bitbucket.org/agalanin/fuse-zip. These are packaged in distros like Debian (as "sshfs" and "fuse-zip"). I mounted sshfs with these commands (mounting the home directory over ssh at ~/mnt/ssh):

user@vm:~$ cp /usr/bin/echo ~/ima/
user@vm:~$ sshfs localhost: ~/mnt/ssh
Quoted 8 lines

and mounted fuse-zip with:

user@vm:~/ima$ zip -rD echo.zip /usr/bin/echo
  adding: usr/bin/echo (deflated 62%)
user@vm:~/ima$ mkdir zipmount
user@vm:~/ima$ fuse-zip echo.zip zipmount/

I then ran the executables ~/ima/zipmount/usr/bin/echo and ~/mnt/ssh/ima/echo.

Thank you for the instructions. Due to the holidays, there was a delay. The patches are now queued in next-integrity for 6.19.

Mimi