aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 20:15:08 -0400
commit7ac86265dc8f665cc49d6e60a125e608cd2fca14 (patch)
tree9e7941e2d8dfb2106c5fb28504531dafc72e14e6 /kernel/auditsc.c
parent91a27b2a756784714e924e5e854b919273082d26 (diff)
audit: allow audit code to satisfy getname requests from its names_list
Currently, if we call getname() on a userland string more than once, we'll get multiple copies of the string and multiple audit_names records. Add a function that will allow the audit_names code to satisfy getname requests using info from the audit_names list, avoiding a new allocation and audit_names records. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c23
1 files changed, 23 insertions, 0 deletions
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 *