Skip to content

Commit d79e57d

Browse files
jrjohansengregkh
authored andcommitted
apparmor: ensure that dfa state tables have entries
commit c27c6bd upstream. Currently it is possible to specify a state machine table with 0 length, this is not valid as optional tables are specified by not defining the table as present. Further this allows by-passing the base tables range check against the next/check tables. Fixes: d901d6a ("apparmor: dfa split verification of table headers") Reported-by: Mike Salvatore <mike.salvatore@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b7d9b78 commit d79e57d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎security/apparmor/match.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
9797
th.td_flags == YYTD_DATA8))
9898
goto out;
9999

100+
/* if we have a table it must have some entries */
101+
if (th.td_lolen == 0)
102+
goto out;
100103
tsize = table_size(th.td_lolen, th.td_flags);
101104
if (bsize < tsize)
102105
goto out;
@@ -198,6 +201,8 @@ static int verify_dfa(struct aa_dfa *dfa)
198201

199202
state_count = dfa->tables[YYTD_ID_BASE]->td_lolen;
200203
trans_count = dfa->tables[YYTD_ID_NXT]->td_lolen;
204+
if (state_count == 0)
205+
goto out;
201206
for (i = 0; i < state_count; i++) {
202207
if (!(BASE_TABLE(dfa)[i] & MATCH_FLAG_DIFF_ENCODE) &&
203208
(DEFAULT_TABLE(dfa)[i] >= state_count))

0 commit comments

Comments
 (0)