Skip to content

Commit c4b9570

Browse files
committed
Merge tag 'audit-pr-20250121' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit update from Paul Moore: "A single audit patch that fixes a problem when collecting pathnames for audit PATH records that was caused by some faulty pathname matching logic" * tag 'audit-pr-20250121' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: fix suffixed '/' filename matching
2 parents 690ffcd + e92eebb commit c4b9570

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

kernel/auditfilter.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,13 +1319,20 @@ int audit_compare_dname_path(const struct qstr *dname, const char *path, int par
13191319
if (pathlen < dlen)
13201320
return 1;
13211321

1322-
parentlen = parentlen == AUDIT_NAME_FULL ? parent_len(path) : parentlen;
1323-
if (pathlen - parentlen != dlen)
1324-
return 1;
1322+
if (parentlen == AUDIT_NAME_FULL)
1323+
parentlen = parent_len(path);
13251324

13261325
p = path + parentlen;
13271326

1328-
return strncmp(p, dname->name, dlen);
1327+
/* handle trailing slashes */
1328+
pathlen -= parentlen;
1329+
while (p[pathlen - 1] == '/')
1330+
pathlen--;
1331+
1332+
if (pathlen != dlen)
1333+
return 1;
1334+
1335+
return memcmp(p, dname->name, dlen);
13291336
}
13301337

13311338
int audit_filter(int msgtype, unsigned int listtype)

0 commit comments

Comments
 (0)