diff options
Diffstat (limited to 'security/apparmor/lib.c')
| -rw-r--r-- | security/apparmor/lib.c | 65 | 
1 files changed, 19 insertions, 46 deletions
diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c index 506d2baf614..c1827e06845 100644 --- a/security/apparmor/lib.c +++ b/security/apparmor/lib.c @@ -12,11 +12,13 @@   * License.   */ +#include <linux/mm.h>  #include <linux/slab.h>  #include <linux/string.h>  #include <linux/vmalloc.h>  #include "include/audit.h" +#include "include/apparmor.h"  /** @@ -43,8 +45,10 @@ char *aa_split_fqname(char *fqname, char **ns_name)  		*ns_name = skip_spaces(&name[1]);  		if (split) {  			/* overwrite ':' with \0 */ -			*split = 0; -			name = skip_spaces(split + 1); +			*split++ = 0; +			if (strncmp(split, "//", 2) == 0) +				split += 2; +			name = skip_spaces(split);  		} else  			/* a ns name without a following profile is allowed */  			name = NULL; @@ -63,23 +67,26 @@ void aa_info_message(const char *str)  {  	if (audit_enabled) {  		struct common_audit_data sa; -		COMMON_AUDIT_DATA_INIT(&sa, NONE); -		sa.aad.info = str; +		struct apparmor_audit_data aad = {0,}; +		sa.type = LSM_AUDIT_DATA_NONE; +		sa.aad = &aad; +		aad.info = str;  		aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);  	}  	printk(KERN_INFO "AppArmor: %s\n", 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; @@ -88,46 +95,12 @@ 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;  } - -/** - * do_vfree - workqueue routine for freeing vmalloced memory - * @work: data to be freed - * - * The work_struct is overlaid to the data being freed, as at the point - * the work is scheduled the data is no longer valid, be its freeing - * needs to be delayed until safe. - */ -static void do_vfree(struct work_struct *work) -{ -	vfree(work); -} - -/** - * kvfree - free an allocation do by kvmalloc - * @buffer: buffer to free (MAYBE_NULL) - * - * Free a buffer allocated by kvmalloc - */ -void kvfree(void *buffer) -{ -	if (is_vmalloc_addr(buffer)) { -		/* Data is no longer valid so just use the allocated space -		 * as the work_struct -		 */ -		struct work_struct *work = (struct work_struct *) buffer; -		INIT_WORK(work, do_vfree); -		schedule_work(work); -	} else -		kfree(buffer); -}  | 
