]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
audit: handle unknown status requests in audit_receive_msg()
authorRicardo Robaina <rrobaina@redhat.com>
Mon, 9 Mar 2026 13:05:33 +0000 (10:05 -0300)
committerPaul Moore <paul@paul-moore.com>
Tue, 10 Mar 2026 19:22:43 +0000 (15:22 -0400)
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.

Suggested-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Ricardo Robaina <rrobaina@redhat.com>
[PM: subject line tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/audit.h
kernel/audit.c

index b642b5faca654c8465b6839c32b633426e1d3d9a..d79218bf075a04398ee72b27debfe1bf22affe7d 100644 (file)
 #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)
 
index 08793e71b9759dffe3b9ad65f805ba9d9d1c7a8f..e1d489bc2dff99c27272106de879448b9deb7621 100644 (file)
@@ -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)