Skip to content

Commit de63934

Browse files
committed
Merge tag 'audit-pr-20260410' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit updates from Paul Moore: - Improved handling of unknown status requests from userspace The current kernel code ignores unknown/unused request bits sent from userspace and returns an error code based on the results of the request(s) it does understand. The patch from Ricardo fixes this so that unknown requests return an -EINVAL to userspace, making compatibility a bit easier moving forward. - A number of small style and formatting cleanups * tag 'audit-pr-20260410' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: handle unknown status requests in audit_receive_msg() audit: fix coding style issues audit: remove redundant initialization of static variables to 0 audit: fix whitespace alignment in include/uapi/linux/audit.h
2 parents ef3da34 + 360160f commit de63934

5 files changed

Lines changed: 20 additions & 10 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 ((u64)-1)
1928
#define AUDIT_DEV_UNSET ((dev_t)-1)
2029

include/uapi/linux/audit.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ enum {
350350
#define AUDIT_STATUS_ENABLED 0x0001
351351
#define AUDIT_STATUS_FAILURE 0x0002
352352
#define AUDIT_STATUS_PID 0x0004
353-
#define AUDIT_STATUS_RATE_LIMIT 0x0008
353+
#define AUDIT_STATUS_RATE_LIMIT 0x0008
354354
#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
355355
#define AUDIT_STATUS_BACKLOG_WAIT_TIME 0x0020
356356
#define AUDIT_STATUS_LOST 0x0040
@@ -386,8 +386,8 @@ enum {
386386
* These bits disambiguate different calling conventions that share an
387387
* ELF machine type, bitness, and endianness
388388
*/
389-
#define __AUDIT_ARCH_CONVENTION_MASK 0x30000000
390-
#define __AUDIT_ARCH_CONVENTION_MIPS64_N32 0x20000000
389+
#define __AUDIT_ARCH_CONVENTION_MASK 0x30000000
390+
#define __AUDIT_ARCH_CONVENTION_MIPS64_N32 0x20000000
391391

392392
/* distinguish syscall tables */
393393
#define __AUDIT_ARCH_64BIT 0x80000000
@@ -508,7 +508,7 @@ struct audit_tty_status {
508508
__u32 log_passwd; /* 1 = enabled, 0 = disabled */
509509
};
510510

511-
#define AUDIT_UID_UNSET (unsigned int)-1
511+
#define AUDIT_UID_UNSET ((unsigned int)-1)
512512
#define AUDIT_SID_UNSET ((unsigned int)-1)
513513

514514
/* audit_rule_data supports filter rules with both integer and string

kernel/audit.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ void audit_panic(const char *message)
355355

356356
static inline int audit_rate_check(void)
357357
{
358-
static unsigned long last_check = 0;
359-
static int messages = 0;
358+
static unsigned long last_check;
359+
static int messages;
360360
static DEFINE_SPINLOCK(lock);
361361
unsigned long flags;
362362
unsigned long now;
@@ -391,7 +391,7 @@ static inline int audit_rate_check(void)
391391
*/
392392
void audit_log_lost(const char *message)
393393
{
394-
static unsigned long last_msg = 0;
394+
static unsigned long last_msg;
395395
static DEFINE_SPINLOCK(lock);
396396
unsigned long flags;
397397
unsigned long now;
@@ -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)

kernel/auditfilter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule_data *
303303
return ERR_PTR(err);
304304
}
305305

306-
static u32 audit_ops[] =
307-
{
306+
static u32 audit_ops[] = {
308307
[Audit_equal] = AUDIT_EQUAL,
309308
[Audit_not_equal] = AUDIT_NOT_EQUAL,
310309
[Audit_bitmask] = AUDIT_BIT_MASK,

lib/audit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int audit_classify_syscall(int abi, unsigned syscall)
4242
if (audit_is_compat(abi))
4343
return audit_classify_compat_syscall(abi, syscall);
4444

45-
switch(syscall) {
45+
switch (syscall) {
4646
#ifdef __NR_open
4747
case __NR_open:
4848
return AUDITSC_OPEN;

0 commit comments

Comments
 (0)