aboutsummaryrefslogtreecommitdiffstats
path: root/security/apparmor
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2010-07-23 08:53:56 -0400
committerLeann Ogasawara <leann.ogasawara@canonical.com>2011-08-30 13:14:56 -0400
commit5e498fdb19f5b27699f063eb10040612b824160b (patch)
treed7d04d35391549d6f5047f0dac5d6cf0dd3db375 /security/apparmor
parentc25bf4b44483e64736d2c2a8c35bde7a948ca404 (diff)
UBUNTU: SAUCE: AppArmor: Allow dfa backward compatibility with broken userspace
Allow broken Lucid userspace tools to load policy, on Maverick kernel. The fix for http://launchpad.net/bugs/581525 blocks Lucid tools from loading policy, this provides compatibility with Lucid tools without reintroducing the bug. The apparmor_parser when compiling policy could generate invalid dfas that did not have sufficient padding to avoid invalid references, when used by the kernel. The kernels check to verify the next/check table size was broken meaning invalid dfas were being created by userspace and not caught. To remain compatible with old tools that are not fixed, pad the loaded dfas next/check table. The dfa's themselves are valid except for the high padding for potentially invalid transitions (high bounds error), which have a maximimum is 256 entries. So just allocate an extra null filled 256 entries for the next/check tables. This will guarentee all bounds are good and invalid transitions go to the null (0) state. Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Diffstat (limited to 'security/apparmor')
-rw-r--r--security/apparmor/match.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/security/apparmor/match.c b/security/apparmor/match.c
index 94de6b4907c..081491e3401 100644
--- a/security/apparmor/match.c
+++ b/security/apparmor/match.c
@@ -57,8 +57,17 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
57 if (bsize < tsize) 57 if (bsize < tsize)
58 goto out; 58 goto out;
59 59
60 /* Pad table allocation for next/check by 256 entries to remain
61 * backwards compatible with old (buggy) tools and remain safe without
62 * run time checks
63 */
64 if (th.td_id == YYTD_ID_NXT || th.td_id == YYTD_ID_CHK)
65 tsize += 256 * th.td_flags;
66
60 table = kvmalloc(tsize); 67 table = kvmalloc(tsize);
61 if (table) { 68 if (table) {
69 /* ensure the pad is clear, else there will be errors */
70 memset(table, 0, tsize);
62 *table = th; 71 *table = th;
63 if (th.td_flags == YYTD_DATA8) 72 if (th.td_flags == YYTD_DATA8)
64 UNPACK_ARRAY(table->td_data, blob, th.td_lolen, 73 UNPACK_ARRAY(table->td_data, blob, th.td_lolen,
@@ -134,11 +143,19 @@ static int verify_dfa(struct aa_dfa *dfa, int flags)
134 goto out; 143 goto out;
135 144
136 if (flags & DFA_FLAG_VERIFY_STATES) { 145 if (flags & DFA_FLAG_VERIFY_STATES) {
146 int warning = 0;
137 for (i = 0; i < state_count; i++) { 147 for (i = 0; i < state_count; i++) {
138 if (DEFAULT_TABLE(dfa)[i] >= state_count) 148 if (DEFAULT_TABLE(dfa)[i] >= state_count)
139 goto out; 149 goto out;
140 /* TODO: do check that DEF state recursion terminates */ 150 /* TODO: do check that DEF state recursion terminates */
141 if (BASE_TABLE(dfa)[i] + 255 >= trans_count) { 151 if (BASE_TABLE(dfa)[i] + 255 >= trans_count) {
152 if (warning)
153 continue;
154 printk(KERN_WARNING "AppArmor DFA next/check "
155 "upper bounds error fixed, upgrade "
156 "user space tools \n");
157 warning = 1;
158 } else if (BASE_TABLE(dfa)[i] >= trans_count) {
142 printk(KERN_ERR "AppArmor DFA next/check upper " 159 printk(KERN_ERR "AppArmor DFA next/check upper "
143 "bounds error\n"); 160 "bounds error\n");
144 goto out; 161 goto out;