Blame view
security/apparmor/lib.c
2.71 KB
cdff26426 AppArmor: misc. b... |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* * AppArmor security module * * This file contains basic common functions used in AppArmor * * Copyright (C) 1998-2008 Novell/SUSE * Copyright 2009-2010 Canonical Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. */ |
b7f080cfe net: remove mm.h ... |
14 |
#include <linux/mm.h> |
cdff26426 AppArmor: misc. b... |
15 16 17 18 19 |
#include <linux/slab.h> #include <linux/string.h> #include <linux/vmalloc.h> #include "include/audit.h" |
32c3df631 apparmor: sparse ... |
20 |
#include "include/apparmor.h" |
cdff26426 AppArmor: misc. b... |
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/** * aa_split_fqname - split a fqname into a profile and namespace name * @fqname: a full qualified name in namespace profile format (NOT NULL) * @ns_name: pointer to portion of the string containing the ns name (NOT NULL) * * Returns: profile name or NULL if one is not specified * * Split a namespace name from a profile name (see policy.c for naming * description). If a portion of the name is missing it returns NULL for * that portion. * * NOTE: may modify the @fqname string. The pointers returned point * into the @fqname string. */ char *aa_split_fqname(char *fqname, char **ns_name) { char *name = strim(fqname); *ns_name = NULL; if (name[0] == ':') { char *split = strchr(&name[1], ':'); |
04ccd53f0 AppArmor: Fix spl... |
44 |
*ns_name = skip_spaces(&name[1]); |
cdff26426 AppArmor: misc. b... |
45 46 |
if (split) { /* overwrite ':' with \0 */ |
2654bfbc2 apparmor: fix ful... |
47 48 49 50 |
*split++ = 0; if (strncmp(split, "//", 2) == 0) split += 2; name = skip_spaces(split); |
cdff26426 AppArmor: misc. b... |
51 52 53 |
} else /* a ns name without a following profile is allowed */ name = NULL; |
cdff26426 AppArmor: misc. b... |
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
} if (name && *name == 0) name = NULL; return name; } /** * aa_info_message - log a none profile related status message * @str: message to log */ void aa_info_message(const char *str) { if (audit_enabled) { struct common_audit_data sa; |
3b3b0e4fc LSM: shrink sizeo... |
69 |
struct apparmor_audit_data aad = {0,}; |
50c205f5e LSM: do not initi... |
70 |
sa.type = LSM_AUDIT_DATA_NONE; |
3b3b0e4fc LSM: shrink sizeo... |
71 72 |
sa.aad = &aad; aad.info = str; |
cdff26426 AppArmor: misc. b... |
73 74 75 76 77 78 79 |
aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL); } printk(KERN_INFO "AppArmor: %s ", str); } /** |
0ca554b9f apparmor: add kvz... |
80 81 82 |
* __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). |
cdff26426 AppArmor: misc. b... |
83 84 85 86 87 88 |
* * 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. */ |
0ca554b9f apparmor: add kvz... |
89 |
void *__aa_kvmalloc(size_t size, gfp_t flags) |
cdff26426 AppArmor: misc. b... |
90 91 92 93 94 95 96 97 |
{ void *buffer = NULL; if (size == 0) return NULL; /* do not attempt kmalloc if we need more than 16 pages at once */ if (size <= (16*PAGE_SIZE)) |
0ca554b9f apparmor: add kvz... |
98 |
buffer = kmalloc(size, flags | GFP_NOIO | __GFP_NOWARN); |
cdff26426 AppArmor: misc. b... |
99 |
if (!buffer) { |
0ca554b9f apparmor: add kvz... |
100 101 102 103 |
if (flags & __GFP_ZERO) buffer = vzalloc(size); else buffer = vmalloc(size); |
cdff26426 AppArmor: misc. b... |
104 105 106 |
} return buffer; } |