aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 16:43:13 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 20:15:09 -0400
commitadb5c2473d3f91526c79db972aafb20a56d3fbb3 (patch)
treef0427a11a91af2f5a5d0037ce52c32633019120b /kernel
parent669abf4e5539c8aa48bf28c965be05c0a7b58a27 (diff)
audit: make audit_inode take struct filename
Keep a pointer to the audit_names "slot" in struct filename. Have all of the audit_inode callers pass a struct filename ponter to audit_inode instead of a string pointer. If the aname field is already populated, then we can skip walking the list altogether and just use it directly. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/auditsc.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 521163a5d65f..2f186ed80c40 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2076,6 +2076,7 @@ void __audit_getname(struct filename *name)
2076 n->name = name; 2076 n->name = name;
2077 n->name_len = AUDIT_NAME_FULL; 2077 n->name_len = AUDIT_NAME_FULL;
2078 n->name_put = true; 2078 n->name_put = true;
2079 name->aname = n;
2079 2080
2080 if (!context->pwd.dentry) 2081 if (!context->pwd.dentry)
2081 get_fs_pwd(current->fs, &context->pwd); 2082 get_fs_pwd(current->fs, &context->pwd);
@@ -2166,7 +2167,7 @@ static void audit_copy_inode(struct audit_names *name, const struct dentry *dent
2166 * @dentry: dentry being audited 2167 * @dentry: dentry being audited
2167 * @parent: does this dentry represent the parent? 2168 * @parent: does this dentry represent the parent?
2168 */ 2169 */
2169void __audit_inode(const char *name, const struct dentry *dentry, 2170void __audit_inode(struct filename *name, const struct dentry *dentry,
2170 unsigned int parent) 2171 unsigned int parent)
2171{ 2172{
2172 struct audit_context *context = current->audit_context; 2173 struct audit_context *context = current->audit_context;
@@ -2179,9 +2180,29 @@ void __audit_inode(const char *name, const struct dentry *dentry,
2179 if (!name) 2180 if (!name)
2180 goto out_alloc; 2181 goto out_alloc;
2181 2182
2183#if AUDIT_DEBUG
2184 /* The struct filename _must_ have a populated ->name */
2185 BUG_ON(!name->name);
2186#endif
2187 /*
2188 * If we have a pointer to an audit_names entry already, then we can
2189 * just use it directly if the type is correct.
2190 */
2191 n = name->aname;
2192 if (n) {
2193 if (parent) {
2194 if (n->type == AUDIT_TYPE_PARENT ||
2195 n->type == AUDIT_TYPE_UNKNOWN)
2196 goto out;
2197 } else {
2198 if (n->type != AUDIT_TYPE_PARENT)
2199 goto out;
2200 }
2201 }
2202
2182 list_for_each_entry_reverse(n, &context->names_list, list) { 2203 list_for_each_entry_reverse(n, &context->names_list, list) {
2183 /* does the name pointer match? */ 2204 /* does the name pointer match? */
2184 if (!n->name || n->name->name != name) 2205 if (!n->name || n->name->name != name->name)
2185 continue; 2206 continue;
2186 2207
2187 /* match the correct record type */ 2208 /* match the correct record type */