Skip to content

Commit 1cfecec

Browse files
rgbriggsgregkh
authored andcommitted
audit: restore AUDIT_LOGINUID unset ABI
commit 041d7b9 upstream. A regression was caused by commit 780a765: audit: Make testing for a valid loginuid explicit. (which in turn attempted to fix a regression caused by e1760bd) When audit_krule_to_data() fills in the rules to get a listing, there was a missing clause to convert back from AUDIT_LOGINUID_SET to AUDIT_LOGINUID. This broke userspace by not returning the same information that was sent and expected. The rule: auditctl -a exit,never -F auid=-1 gives: auditctl -l LIST_RULES: exit,never f24=0 syscall=all when it should give: LIST_RULES: exit,never auid=-1 (0xffffffff) syscall=all Tag it so that it is reported the same way it was set. Create a new private flags audit_krule field (pflags) to store it that won't interact with the public one from the API. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Paul Moore <pmoore@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 64701c8 commit 1cfecec

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎include/linux/audit.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct sk_buff;
4747

4848
struct audit_krule {
4949
int vers_ops;
50+
u32 pflags;
5051
u32 flags;
5152
u32 listnr;
5253
u32 action;
@@ -64,6 +65,9 @@ struct audit_krule {
6465
u64 prio;
6566
};
6667

68+
/* Flag to indicate legacy AUDIT_LOGINUID unset usage */
69+
#define AUDIT_LOGINUID_LEGACY 0x1
70+
6771
struct audit_field {
6872
u32 type;
6973
u32 val;

‎kernel/auditfilter.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
429429
if ((f->type == AUDIT_LOGINUID) && (f->val == AUDIT_UID_UNSET)) {
430430
f->type = AUDIT_LOGINUID_SET;
431431
f->val = 0;
432+
entry->rule.pflags |= AUDIT_LOGINUID_LEGACY;
432433
}
433434

434435
err = audit_field_valid(entry, f);
@@ -604,6 +605,13 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
604605
data->buflen += data->values[i] =
605606
audit_pack_string(&bufp, krule->filterkey);
606607
break;
608+
case AUDIT_LOGINUID_SET:
609+
if (krule->pflags & AUDIT_LOGINUID_LEGACY && !f->val) {
610+
data->fields[i] = AUDIT_LOGINUID;
611+
data->values[i] = AUDIT_UID_UNSET;
612+
break;
613+
}
614+
/* fallthrough if set */
607615
default:
608616
data->values[i] = f->val;
609617
}
@@ -620,6 +628,7 @@ static int audit_compare_rule(struct audit_krule *a, struct audit_krule *b)
620628
int i;
621629

622630
if (a->flags != b->flags ||
631+
a->pflags != b->pflags ||
623632
a->listnr != b->listnr ||
624633
a->action != b->action ||
625634
a->field_count != b->field_count)
@@ -738,6 +747,7 @@ struct audit_entry *audit_dupe_rule(struct audit_krule *old)
738747
new = &entry->rule;
739748
new->vers_ops = old->vers_ops;
740749
new->flags = old->flags;
750+
new->pflags = old->pflags;
741751
new->listnr = old->listnr;
742752
new->action = old->action;
743753
for (i = 0; i < AUDIT_BITMASK_SIZE; i++)

0 commit comments

Comments
 (0)