diff options
author | John Johansen <john.johansen@canonical.com> | 2017-05-23 03:25:14 -0700 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2017-06-08 11:29:34 -0700 |
commit | 4227c333f65cddc6c2f048e5b67cfe796b9df9a6 (patch) | |
tree | 4deee8d16246bc879036da19642451b8e7cdcde0 /security/apparmor/file.c | |
parent | 72c8a768641dc6ee8d1d9dcebd51bbec2817459b (diff) |
apparmor: Move path lookup to using preallocated buffers
Dynamically allocating buffers is problematic and is an extra layer
that is a potntial point of failure and can slow down mediation.
Change path lookup to use the preallocated per cpu buffers.
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor/file.c')
-rw-r--r-- | security/apparmor/file.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/security/apparmor/file.c b/security/apparmor/file.c index 83d43ac72134..22be62f0fc73 100644 --- a/security/apparmor/file.c +++ b/security/apparmor/file.c @@ -285,7 +285,8 @@ int aa_path_perm(const char *op, struct aa_profile *profile, int error; flags |= profile->path_flags | (S_ISDIR(cond->mode) ? PATH_IS_DIR : 0); - error = aa_path_name(path, flags, &buffer, &name, &info, + get_buffers(buffer); + error = aa_path_name(path, flags, buffer, &name, &info, profile->disconnected); if (error) { if (error == -ENOENT && is_deleted(path->dentry)) { @@ -304,7 +305,7 @@ int aa_path_perm(const char *op, struct aa_profile *profile, } error = aa_audit_file(profile, &perms, op, request, name, NULL, cond->uid, info, error); - kfree(buffer); + put_buffers(buffer); return error; } @@ -363,16 +364,17 @@ int aa_path_link(struct aa_profile *profile, struct dentry *old_dentry, unsigned int state; int error; + get_buffers(buffer, buffer2); lperms = nullperms; /* buffer freed below, lname is pointer in buffer */ - error = aa_path_name(&link, profile->path_flags, &buffer, &lname, + error = aa_path_name(&link, profile->path_flags, buffer, &lname, &info, profile->disconnected); if (error) goto audit; /* buffer2 freed below, tname is pointer in buffer2 */ - error = aa_path_name(&target, profile->path_flags, &buffer2, &tname, + error = aa_path_name(&target, profile->path_flags, buffer2, &tname, &info, profile->disconnected); if (error) goto audit; @@ -432,8 +434,7 @@ done_tests: audit: error = aa_audit_file(profile, &lperms, OP_LINK, request, lname, tname, cond.uid, info, error); - kfree(buffer); - kfree(buffer2); + put_buffers(buffer, buffer2); return error; } |