Skip to content

Commit 3ea67c4

Browse files
committed
Merge tag 'audit-pr-20230829' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit updates from Paul Moore: "Six audit patches, the highlights are: - Add an explicit cond_resched() call when generating PATH records Certain tracefs/debugfs operations can generate a *lot* of audit PATH entries and if one has an aggressive system configuration (not the default) this can cause a soft lockup in the audit code as it works to process all of these new entries. This is in sharp contrast to the common case where only one or two PATH entries are logged. In order to fix this corner case without excessively impacting the common case we're adding a single cond_rescued() call between two of the most intensive loops in the __audit_inode_child() function. - Various minor cleanups We removed a conditional header file as the included header already had the necessary logic in place, fixed a dummy function's return value, and the usual collection of checkpatch.pl noise (whitespace, brace, and trailing statement tweaks)" * tag 'audit-pr-20230829' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: move trailing statements to next line audit: cleanup function braces and assignment-in-if-condition audit: add space before parenthesis and around '=', "==", and '<' audit: fix possible soft lockup in __audit_inode_child() audit: correct audit_filter_inodes() definition audit: include security.h unconditionally
2 parents 6c1b980 + b1a0f64 commit 3ea67c4

5 files changed

Lines changed: 21 additions & 17 deletions

File tree

kernel/acct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static void fill_ac(acct_t *ac)
470470
do_div(elapsed, AHZ);
471471
btime = ktime_get_real_seconds() - elapsed;
472472
ac->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX);
473-
#if ACCT_VERSION==2
473+
#if ACCT_VERSION == 2
474474
ac->ac_ahz = AHZ;
475475
#endif
476476

kernel/audit.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@
5353
#include <net/sock.h>
5454
#include <net/netlink.h>
5555
#include <linux/skbuff.h>
56-
#ifdef CONFIG_SECURITY
5756
#include <linux/security.h>
58-
#endif
5957
#include <linux/freezer.h>
6058
#include <linux/pid_namespace.h>
6159
#include <net/netns/generic.h>
@@ -323,7 +321,8 @@ static inline int audit_rate_check(void)
323321
unsigned long now;
324322
int retval = 0;
325323

326-
if (!audit_rate_limit) return 1;
324+
if (!audit_rate_limit)
325+
return 1;
327326

328327
spin_lock_irqsave(&lock, flags);
329328
if (++messages < audit_rate_limit) {

kernel/audit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static inline int audit_signal_info_syscall(struct task_struct *t)
334334
return 0;
335335
}
336336

337-
#define audit_filter_inodes(t, c) AUDIT_STATE_DISABLED
337+
#define audit_filter_inodes(t, c) do { } while (0)
338338
#endif /* CONFIG_AUDITSYSCALL */
339339

340340
extern char *audit_unpack_string(void **bufp, size_t *remain, size_t len);

kernel/auditfilter.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int audit_match_signal(struct audit_entry *entry)
221221
entry->rule.mask));
222222
}
223223

224-
switch(audit_classify_arch(arch->val)) {
224+
switch (audit_classify_arch(arch->val)) {
225225
case 0: /* native */
226226
return (audit_match_class_bits(AUDIT_CLASS_SIGNAL,
227227
entry->rule.mask));
@@ -243,7 +243,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule_data *
243243

244244
err = -EINVAL;
245245
listnr = rule->flags & ~AUDIT_FILTER_PREPEND;
246-
switch(listnr) {
246+
switch (listnr) {
247247
default:
248248
goto exit_err;
249249
#ifdef CONFIG_AUDITSYSCALL
@@ -344,7 +344,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f)
344344

345345
switch (entry->rule.listnr) {
346346
case AUDIT_FILTER_FS:
347-
switch(f->type) {
347+
switch (f->type) {
348348
case AUDIT_FSTYPE:
349349
case AUDIT_FILTERKEY:
350350
break;
@@ -651,7 +651,7 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
651651

652652
data->fields[i] = f->type;
653653
data->fieldflags[i] = audit_ops[f->op];
654-
switch(f->type) {
654+
switch (f->type) {
655655
case AUDIT_SUBJ_USER:
656656
case AUDIT_SUBJ_ROLE:
657657
case AUDIT_SUBJ_TYPE:
@@ -694,7 +694,8 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
694694
data->values[i] = f->val;
695695
}
696696
}
697-
for (i = 0; i < AUDIT_BITMASK_SIZE; i++) data->mask[i] = krule->mask[i];
697+
for (i = 0; i < AUDIT_BITMASK_SIZE; i++)
698+
data->mask[i] = krule->mask[i];
698699

699700
return data;
700701
}
@@ -717,7 +718,7 @@ static int audit_compare_rule(struct audit_krule *a, struct audit_krule *b)
717718
a->fields[i].op != b->fields[i].op)
718719
return 1;
719720

720-
switch(a->fields[i].type) {
721+
switch (a->fields[i].type) {
721722
case AUDIT_SUBJ_USER:
722723
case AUDIT_SUBJ_ROLE:
723724
case AUDIT_SUBJ_TYPE:
@@ -946,7 +947,7 @@ static inline int audit_add_rule(struct audit_entry *entry)
946947
int dont_count = 0;
947948

948949
/* If any of these, don't count towards total */
949-
switch(entry->rule.listnr) {
950+
switch (entry->rule.listnr) {
950951
case AUDIT_FILTER_USER:
951952
case AUDIT_FILTER_EXCLUDE:
952953
case AUDIT_FILTER_FS:
@@ -1029,7 +1030,7 @@ int audit_del_rule(struct audit_entry *entry)
10291030
int dont_count = 0;
10301031

10311032
/* If any of these, don't count towards total */
1032-
switch(entry->rule.listnr) {
1033+
switch (entry->rule.listnr) {
10331034
case AUDIT_FILTER_USER:
10341035
case AUDIT_FILTER_EXCLUDE:
10351036
case AUDIT_FILTER_FS:
@@ -1083,7 +1084,7 @@ static void audit_list_rules(int seq, struct sk_buff_head *q)
10831084

10841085
/* This is a blocking read, so use audit_filter_mutex instead of rcu
10851086
* iterator to sync with list writers. */
1086-
for (i=0; i<AUDIT_NR_FILTERS; i++) {
1087+
for (i = 0; i < AUDIT_NR_FILTERS; i++) {
10871088
list_for_each_entry(r, &audit_rules_list[i], list) {
10881089
struct audit_rule_data *data;
10891090

kernel/auditsc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ static void audit_filter_syscall(struct task_struct *tsk,
880880
*/
881881
static int audit_filter_inode_name(struct task_struct *tsk,
882882
struct audit_names *n,
883-
struct audit_context *ctx) {
883+
struct audit_context *ctx)
884+
{
884885
int h = audit_hash_ino((u32)n->ino);
885886
struct list_head *list = &audit_inode_hash[h];
886887

@@ -1064,7 +1065,8 @@ int audit_alloc(struct task_struct *tsk)
10641065
return 0;
10651066
}
10661067

1067-
if (!(context = audit_alloc_context(state))) {
1068+
context = audit_alloc_context(state);
1069+
if (!context) {
10681070
kfree(key);
10691071
audit_log_lost("out of memory in audit_alloc");
10701072
return -ENOMEM;
@@ -2124,7 +2126,7 @@ static void handle_path(const struct dentry *dentry)
21242126
d = dentry;
21252127
rcu_read_lock();
21262128
seq = read_seqbegin(&rename_lock);
2127-
for(;;) {
2129+
for (;;) {
21282130
struct inode *inode = d_backing_inode(d);
21292131

21302132
if (inode && unlikely(inode->i_fsnotify_marks)) {
@@ -2456,6 +2458,8 @@ void __audit_inode_child(struct inode *parent,
24562458
}
24572459
}
24582460

2461+
cond_resched();
2462+
24592463
/* is there a matching child entry? */
24602464
list_for_each_entry(n, &context->names_list, list) {
24612465
/* can only match entries that have a name */

0 commit comments

Comments
 (0)