Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
e6f901b
Documentation
arch
block
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
apparmor
include
.gitignore
Kconfig
Makefile
apparmorfs.c
audit.c
capability.c
context.c
domain.c
file.c
ipc.c
lib.c
lsm.c
match.c
path.c
policy.c
policy_unpack.c
procattr.c
resource.c
sid.c
integrity
keys
selinux
smack
tomoyo
Kconfig
Makefile
capability.c
commoncap.c
device_cgroup.c
inode.c
lsm_audit.c
min_addr.c
security.c
sound
tools
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
security
/
apparmor
/
lib.c
Blame
Blame
Latest commit
History
History
133 lines (121 loc) · 3.32 KB
Breadcrumbs
linux
/
security
/
apparmor
/
lib.c
Top
File metadata and controls
Code
Blame
133 lines (121 loc) · 3.32 KB
Raw
/* * 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. */ #include <linux/slab.h> #include <linux/string.h> #include <linux/vmalloc.h> #include "include/audit.h" /** * 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], ':'); *ns_name = skip_spaces(&name[1]); if (split) { /* overwrite ':' with \0 */ *split = 0; name = skip_spaces(split + 1); } else /* a ns name without a following profile is allowed */ name = NULL; } 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; COMMON_AUDIT_DATA_INIT(&sa, NONE); sa.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 * * 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 *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)) buffer = kmalloc(size, 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); } 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); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
You can’t perform that action at this time.