aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/namei.c4
-rw-r--r--include/linux/audit.h11
-rw-r--r--kernel/auditsc.c23
3 files changed, 38 insertions, 0 deletions
diff --git a/fs/namei.c b/fs/namei.c
index ec638d27642f..5dbc3f836934 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -130,6 +130,10 @@ getname_flags(const char __user *filename, int flags, int *empty)
130 char *kname; 130 char *kname;
131 int len; 131 int len;
132 132
133 result = audit_reusename(filename);
134 if (result)
135 return result;
136
133 /* FIXME: create dedicated slabcache? */ 137 /* FIXME: create dedicated slabcache? */
134 result = kzalloc(sizeof(*result), GFP_KERNEL); 138 result = kzalloc(sizeof(*result), GFP_KERNEL);
135 if (unlikely(!result)) 139 if (unlikely(!result))
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 94d29164803f..d5d7952ab7d8 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -471,6 +471,7 @@ extern void __audit_syscall_entry(int arch,
471 int major, unsigned long a0, unsigned long a1, 471 int major, unsigned long a0, unsigned long a1,
472 unsigned long a2, unsigned long a3); 472 unsigned long a2, unsigned long a3);
473extern void __audit_syscall_exit(int ret_success, long ret_value); 473extern void __audit_syscall_exit(int ret_success, long ret_value);
474extern struct filename *__audit_reusename(const __user char *uptr);
474extern void __audit_getname(struct filename *name); 475extern void __audit_getname(struct filename *name);
475extern void audit_putname(struct filename *name); 476extern void audit_putname(struct filename *name);
476extern void __audit_inode(const char *name, const struct dentry *dentry, 477extern void __audit_inode(const char *name, const struct dentry *dentry,
@@ -507,6 +508,12 @@ static inline void audit_syscall_exit(void *pt_regs)
507 __audit_syscall_exit(success, return_code); 508 __audit_syscall_exit(success, return_code);
508 } 509 }
509} 510}
511static inline struct filename *audit_reusename(const __user char *name)
512{
513 if (unlikely(!audit_dummy_context()))
514 return __audit_reusename(name);
515 return NULL;
516}
510static inline void audit_getname(struct filename *name) 517static inline void audit_getname(struct filename *name)
511{ 518{
512 if (unlikely(!audit_dummy_context())) 519 if (unlikely(!audit_dummy_context()))
@@ -665,6 +672,10 @@ static inline int audit_dummy_context(void)
665{ 672{
666 return 1; 673 return 1;
667} 674}
675static inline struct filename *audit_reusename(const __user char *name)
676{
677 return NULL;
678}
668static inline void audit_getname(struct filename *name) 679static inline void audit_getname(struct filename *name)
669{ } 680{ }
670static inline void audit_putname(struct filename *name) 681static inline void audit_putname(struct filename *name)
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index d4d82319eed5..521163a5d65f 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2021,6 +2021,29 @@ static struct audit_names *audit_alloc_name(struct audit_context *context,
2021} 2021}
2022 2022
2023/** 2023/**
2024 * audit_reusename - fill out filename with info from existing entry
2025 * @uptr: userland ptr to pathname
2026 *
2027 * Search the audit_names list for the current audit context. If there is an
2028 * existing entry with a matching "uptr" then return the filename
2029 * associated with that audit_name. If not, return NULL.
2030 */
2031struct filename *
2032__audit_reusename(const __user char *uptr)
2033{
2034 struct audit_context *context = current->audit_context;
2035 struct audit_names *n;
2036
2037 list_for_each_entry(n, &context->names_list, list) {
2038 if (!n->name)
2039 continue;
2040 if (n->name->uptr == uptr)
2041 return n->name;
2042 }
2043 return NULL;
2044}
2045
2046/**
2024 * audit_getname - add a name to the list 2047 * audit_getname - add a name to the list
2025 * @name: name to add 2048 * @name: name to add
2026 * 2049 *