Skip to content

Commit af85d17

Browse files
Ondrej Mosnáčekpcmoore
authored andcommitted
audit: Fix extended comparison of GID/EGID
The audit_filter_rules() function in auditsc.c used the in_[e]group_p() functions to check GID/EGID match, but these functions use the current task's credentials, while the comparison should use the credentials of the task given to audit_filter_rules() as a parameter (tsk). Note that we can use group_search(cred->group_info, ...) as a replacement for both in_group_p and in_egroup_p as these functions only compare the parameter to cred->fsgid/egid and then call group_search. In fact, the usage of in_group_p was even more incorrect: it compares to cred->fsgid (which is usually equal to cred->egid) and not cred->gid. GitHub issue: linux-audit/audit-kernel#82 Fixes: 37eebe3 ("audit: improve GID/EGID comparation logic") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent d87de4a commit af85d17

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎kernel/auditsc.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,20 +494,20 @@ static int audit_filter_rules(struct task_struct *tsk,
494494
result = audit_gid_comparator(cred->gid, f->op, f->gid);
495495
if (f->op == Audit_equal) {
496496
if (!result)
497-
result = in_group_p(f->gid);
497+
result = groups_search(cred->group_info, f->gid);
498498
} else if (f->op == Audit_not_equal) {
499499
if (result)
500-
result = !in_group_p(f->gid);
500+
result = !groups_search(cred->group_info, f->gid);
501501
}
502502
break;
503503
case AUDIT_EGID:
504504
result = audit_gid_comparator(cred->egid, f->op, f->gid);
505505
if (f->op == Audit_equal) {
506506
if (!result)
507-
result = in_egroup_p(f->gid);
507+
result = groups_search(cred->group_info, f->gid);
508508
} else if (f->op == Audit_not_equal) {
509509
if (result)
510-
result = !in_egroup_p(f->gid);
510+
result = !groups_search(cred->group_info, f->gid);
511511
}
512512
break;
513513
case AUDIT_SGID:

0 commit comments

Comments
 (0)