Skip to contentSkip to conversation

audit: handle unknown status requests in audit_receive_msg

PATCH Applied Ricardo Robaina 2 participants 3 messages Mar 9 – Mar 10 Audit

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 audit: handle unknown status requests in audit_receive_msg

Currently, audit_receive_msg() ignores unknown status bits in AUDIT_SET requests, incorrectly returning success to newer user space tools querying unsupported features. This breaks forward compatibility.

Fix this by defining AUDIT_STATUS_ALL and returning -EINVAL if any unrecognized bits are set (s.mask & ~AUDIT_STATUS_ALL). This ensures invalid requests are safely rejected, allowing user space to reliably test for and gracefully handle feature detection on older kernels.

---
v1 -> v2:
- Moved AUDIT_STATUS_ALL from include/uapi/linux/audit.h to include/linux/audit.h.

 include/linux/audit.h | 9 +++++++++
 kernel/audit.c        | 2 ++
 2 files changed, 11 insertions(+)
include/linux/audit.h +9 -0
index b642b5faca65..d79218bf075a 100644
@@ -15,6 +15,15 @@
 #include <uapi/linux/audit.h>
 #include <uapi/linux/fanotify.h>
 
+#define AUDIT_STATUS_ALL (AUDIT_STATUS_ENABLED | \
+			  AUDIT_STATUS_FAILURE | \
+			  AUDIT_STATUS_PID | \
+			  AUDIT_STATUS_RATE_LIMIT | \
+			  AUDIT_STATUS_BACKLOG_LIMIT | \
+			  AUDIT_STATUS_BACKLOG_WAIT_TIME | \
+			  AUDIT_STATUS_LOST | \
+			  AUDIT_STATUS_BACKLOG_WAIT_TIME_ACTUAL)
+
 #define AUDIT_INO_UNSET ((unsigned long)-1)
 #define AUDIT_DEV_UNSET ((dev_t)-1)
 
kernel/audit.c +2 -0
index 5a0216056524..592383dce090 100644
@@ -1295,6 +1295,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
 		memset(&s, 0, sizeof(s));
 		/* guard against past and future API changes */
 		memcpy(&s, data, min_t(size_t, sizeof(s), data_len));
+		if (s.mask & ~AUDIT_STATUS_ALL)
+			return -EINVAL;
 		if (s.mask & AUDIT_STATUS_ENABLED) {
 			err = audit_set_enabled(s.enabled);
 			if (err < 0)
Signature · 1 line
2.53.0
maintainer Applied
#1 lore raw
Quoted 13 lines · On Mar 9, 2026 Ricardo Robaina <[email protected]> wrote:

Currently, audit_receive_msg() ignores unknown status bits in AUDIT_SET requests, incorrectly returning success to newer user space tools querying unsupported features. This breaks forward compatibility.

Fix this by defining AUDIT_STATUS_ALL and returning -EINVAL if any unrecognized bits are set (s.mask & ~AUDIT_STATUS_ALL). This ensures invalid requests are safely rejected, allowing user space to reliably test for and gracefully handle feature detection on older kernels.

Quoted 8 lines

---
v1 -> v2:
- Moved AUDIT_STATUS_ALL from include/uapi/linux/audit.h to include/linux/audit.h.

 include/linux/audit.h | 9 +++++++++
 kernel/audit.c        | 2 ++
 2 files changed, 11 insertions(+)

Merged into audit/dev, thanks.

--
paul-moore.com

#2 lore raw
Quoted 20 lines · Paul Moore
Quoted 18 lines · On Mar 9, 2026 Ricardo Robaina <[email protected]> wrote:

Currently, audit_receive_msg() ignores unknown status bits in AUDIT_SET requests, incorrectly returning success to newer user space tools querying unsupported features. This breaks forward compatibility.

Fix this by defining AUDIT_STATUS_ALL and returning -EINVAL if any unrecognized bits are set (s.mask & ~AUDIT_STATUS_ALL). This ensures invalid requests are safely rejected, allowing user space to reliably test for and gracefully handle feature detection on older kernels.

---
v1 -> v2:
- Moved AUDIT_STATUS_ALL from include/uapi/linux/audit.h to include/linux/audit.h.

Quoted 9 lines
Quoted 3 lines
 include/linux/audit.h | 9 +++++++++
 kernel/audit.c        | 2 ++
 2 files changed, 11 insertions(+)

Merged into audit/dev, thanks.

--
paul-moore.com

Thanks, Paul!