From a76f96003d63c6bcedd591c7f6821b10003f2b44 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 10 Oct 2012 15:25:28 -0400 Subject: [PATCH] --- yaml --- r: 333906 b: refs/heads/master c: 7ac86265dc8f665cc49d6e60a125e608cd2fca14 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/namei.c | 4 ++++ trunk/include/linux/audit.h | 11 +++++++++++ trunk/kernel/auditsc.c | 23 +++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 50bf5a413f38..6948d2e8461d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 91a27b2a756784714e924e5e854b919273082d26 +refs/heads/master: 7ac86265dc8f665cc49d6e60a125e608cd2fca14 diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index ec638d27642f..5dbc3f836934 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -130,6 +130,10 @@ getname_flags(const char __user *filename, int flags, int *empty) char *kname; int len; + result = audit_reusename(filename); + if (result) + return result; + /* FIXME: create dedicated slabcache? */ result = kzalloc(sizeof(*result), GFP_KERNEL); if (unlikely(!result)) diff --git a/trunk/include/linux/audit.h b/trunk/include/linux/audit.h index 94d29164803f..d5d7952ab7d8 100644 --- a/trunk/include/linux/audit.h +++ b/trunk/include/linux/audit.h @@ -471,6 +471,7 @@ extern void __audit_syscall_entry(int arch, int major, unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3); extern void __audit_syscall_exit(int ret_success, long ret_value); +extern struct filename *__audit_reusename(const __user char *uptr); extern void __audit_getname(struct filename *name); extern void audit_putname(struct filename *name); extern void __audit_inode(const char *name, const struct dentry *dentry, @@ -507,6 +508,12 @@ static inline void audit_syscall_exit(void *pt_regs) __audit_syscall_exit(success, return_code); } } +static inline struct filename *audit_reusename(const __user char *name) +{ + if (unlikely(!audit_dummy_context())) + return __audit_reusename(name); + return NULL; +} static inline void audit_getname(struct filename *name) { if (unlikely(!audit_dummy_context())) @@ -665,6 +672,10 @@ static inline int audit_dummy_context(void) { return 1; } +static inline struct filename *audit_reusename(const __user char *name) +{ + return NULL; +} static inline void audit_getname(struct filename *name) { } static inline void audit_putname(struct filename *name) diff --git a/trunk/kernel/auditsc.c b/trunk/kernel/auditsc.c index d4d82319eed5..521163a5d65f 100644 --- a/trunk/kernel/auditsc.c +++ b/trunk/kernel/auditsc.c @@ -2020,6 +2020,29 @@ static struct audit_names *audit_alloc_name(struct audit_context *context, return aname; } +/** + * audit_reusename - fill out filename with info from existing entry + * @uptr: userland ptr to pathname + * + * Search the audit_names list for the current audit context. If there is an + * existing entry with a matching "uptr" then return the filename + * associated with that audit_name. If not, return NULL. + */ +struct filename * +__audit_reusename(const __user char *uptr) +{ + struct audit_context *context = current->audit_context; + struct audit_names *n; + + list_for_each_entry(n, &context->names_list, list) { + if (!n->name) + continue; + if (n->name->uptr == uptr) + return n->name; + } + return NULL; +} + /** * audit_getname - add a name to the list * @name: name to add