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:
Jeff Layton
2012-10-10 15:25:23 -04:00
committed by Al Viro
parent 78e2e802a8
commit bfcec70874
8 changed files with 87 additions and 34 deletions

View File

@@ -456,6 +456,7 @@ extern int audit_classify_arch(int arch);
/* audit_names->type values */
#define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */
#define AUDIT_TYPE_NORMAL 1 /* a "normal" audit record */
#define AUDIT_TYPE_PARENT 2 /* a parent audit record */
#ifdef CONFIG_AUDITSYSCALL
/* These are defined in auditsc.c */
@@ -468,7 +469,8 @@ extern void __audit_syscall_entry(int arch,
extern void __audit_syscall_exit(int ret_success, long ret_value);
extern void __audit_getname(const char *name);
extern void audit_putname(const char *name);
extern void __audit_inode(const char *name, const struct dentry *dentry);
extern void __audit_inode(const char *name, const struct dentry *dentry,
unsigned int parent);
extern void __audit_inode_child(const struct inode *parent,
const struct dentry *dentry);
extern void __audit_seccomp(unsigned long syscall, long signr, int code);
@@ -505,9 +507,10 @@ static inline void audit_getname(const char *name)
if (unlikely(!audit_dummy_context()))
__audit_getname(name);
}
static inline void audit_inode(const char *name, const struct dentry *dentry) {
static inline void audit_inode(const char *name, const struct dentry *dentry,
unsigned int parent) {
if (unlikely(!audit_dummy_context()))
__audit_inode(name, dentry);
__audit_inode(name, dentry, parent);
}
static inline void audit_inode_child(const struct inode *parent,
const struct dentry *dentry) {
@@ -660,12 +663,14 @@ static inline void audit_getname(const char *name)
{ }
static inline void audit_putname(const char *name)
{ }
static inline void __audit_inode(const char *name, const struct dentry *dentry)
static inline void __audit_inode(const char *name, const struct dentry *dentry,
unsigned int parent)
{ }
static inline void __audit_inode_child(const struct inode *parent,
const struct dentry *dentry)
{ }
static inline void audit_inode(const char *name, const struct dentry *dentry)
static inline void audit_inode(const char *name, const struct dentry *dentry,
unsigned int parent)
{ }
static inline void audit_inode_child(const struct inode *parent,
const struct dentry *dentry)