summaryrefslogtreecommitdiffstats
path: root/security/apparmor/lib.c
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2013-02-18 16:04:34 -0800
committerJohn Johansen <john.johansen@canonical.com>2013-04-28 00:36:09 -0700
commit0ca554b9fca425eb58325a36290deef698cef34b (patch)
treeaa9cd7544db53f617f8bf6b0e441f97a55ed4181 /security/apparmor/lib.c
parent3cfcc19e0b5390c04cb5bfa4e8fde39395410e61 (diff)
downloadlinux-0ca554b9fca425eb58325a36290deef698cef34b.tar.bz2
apparmor: add kvzalloc to handle zeroing for kvmalloc
Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <sbeattie@ubuntu.com>
Diffstat (limited to 'security/apparmor/lib.c')
-rw-r--r--security/apparmor/lib.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c
index 7430298116d6..d6e1f2148398 100644
--- a/security/apparmor/lib.c
+++ b/security/apparmor/lib.c
@@ -75,15 +75,16 @@ void aa_info_message(const char *str)
}
/**
- * kvmalloc - do allocation preferring kmalloc but falling back to vmalloc
- * @size: size of allocation
+ * __aa_kvmalloc - do allocation preferring kmalloc but falling back to vmalloc
+ * @size: how many bytes of memory are required
+ * @flags: the type of memory to allocate (see kmalloc).
*
* Return: allocated buffer or NULL if failed
*
* It is possible that policy being loaded from the user is larger than
* what can be allocated by kmalloc, in those cases fall back to vmalloc.
*/
-void *kvmalloc(size_t size)
+void *__aa_kvmalloc(size_t size, gfp_t flags)
{
void *buffer = NULL;
@@ -92,14 +93,17 @@ void *kvmalloc(size_t size)
/* do not attempt kmalloc if we need more than 16 pages at once */
if (size <= (16*PAGE_SIZE))
- buffer = kmalloc(size, GFP_NOIO | __GFP_NOWARN);
+ buffer = kmalloc(size, flags | GFP_NOIO | __GFP_NOWARN);
if (!buffer) {
/* see kvfree for why size must be at least work_struct size
* when allocated via vmalloc
*/
if (size < sizeof(struct work_struct))
size = sizeof(struct work_struct);
- buffer = vmalloc(size);
+ if (flags & __GFP_ZERO)
+ buffer = vzalloc(size);
+ else
+ buffer = vmalloc(size);
}
return buffer;
}