You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
audit: set the name_len in audit_inode for parent lookups
Currently, this gets set mostly by happenstance when we call into audit_inode_child. While that might be a little more efficient, it seems wrong. If the syscall ends up failing before audit_inode_child ever gets called, then you'll have an audit_names record that shows the full path but has the parent inode info attached. Fix this by passing in a parent flag when we call audit_inode that gets set to the value of LOOKUP_PARENT. We can then fix up the pathname for the audit entry correctly from the get-go. While we're at it, clean up the no-op macro for audit_inode in the !CONFIG_AUDITSYSCALL case. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -1298,6 +1298,36 @@ int audit_gid_comparator(kgid_t left, u32 op, kgid_t right)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parent_len - find the length of the parent portion of a pathname
|
||||
* @path: pathname of which to determine length
|
||||
*/
|
||||
int parent_len(const char *path)
|
||||
{
|
||||
int plen;
|
||||
const char *p;
|
||||
|
||||
plen = strlen(path);
|
||||
|
||||
if (plen == 0)
|
||||
return plen;
|
||||
|
||||
/* disregard trailing slashes */
|
||||
p = path + plen - 1;
|
||||
while ((*p == '/') && (p > path))
|
||||
p--;
|
||||
|
||||
/* walk backward until we find the next slash or hit beginning */
|
||||
while ((*p != '/') && (p > path))
|
||||
p--;
|
||||
|
||||
/* did we find a slash? Then increment to include it in path */
|
||||
if (*p == '/')
|
||||
p++;
|
||||
|
||||
return p - path;
|
||||
}
|
||||
|
||||
/* Compare given dentry name with last component in given path,
|
||||
* return of 0 indicates a match. */
|
||||
int audit_compare_dname_path(const char *dname, const char *path,
|
||||
|
||||
Reference in New Issue
Block a user