Skip to content

Commit 360160f

Browse files
rprobainapcmoore
authored andcommitted
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. 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>
1 parent f3e334f commit 360160f

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

include/linux/audit.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
#include <uapi/linux/audit.h>
1616
#include <uapi/linux/fanotify.h>
1717

18+
#define AUDIT_STATUS_ALL (AUDIT_STATUS_ENABLED | \
19+
AUDIT_STATUS_FAILURE | \
20+
AUDIT_STATUS_PID | \
21+
AUDIT_STATUS_RATE_LIMIT | \
22+
AUDIT_STATUS_BACKLOG_LIMIT | \
23+
AUDIT_STATUS_BACKLOG_WAIT_TIME | \
24+
AUDIT_STATUS_LOST | \
25+
AUDIT_STATUS_BACKLOG_WAIT_TIME_ACTUAL)
26+
1827
#define AUDIT_INO_UNSET ((unsigned long)-1)
1928
#define AUDIT_DEV_UNSET ((dev_t)-1)
2029

kernel/audit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
12951295
memset(&s, 0, sizeof(s));
12961296
/* guard against past and future API changes */
12971297
memcpy(&s, data, min_t(size_t, sizeof(s), data_len));
1298+
if (s.mask & ~AUDIT_STATUS_ALL)
1299+
return -EINVAL;
12981300
if (s.mask & AUDIT_STATUS_ENABLED) {
12991301
err = audit_set_enabled(s.enabled);
13001302
if (err < 0)

0 commit comments

Comments
 (0)