apparmor/parser
John Johansen 22855508e8 Add Differential State Compression to the DFA
Differential state compression encodes a state's transitions as the
difference between the state and its default state (the state it is
relative too).

This reduces the number of transitions that need to be stored in the
transition table, hence reducing the size of the dfa.  There is a
trade off in that a single input character may have to traverse more
than one state.  This is somewhat offset by reduced table sizes providing
better locality and caching properties.

With carefully encoding we can still make constant match time guarentees.
This patch guarentees that a state that is differentially encoded will do at
most 3m state traversal to match an input of length m (as opposed to a
non-differentially compressed dfa doing exactly m state traversals).
In practice the actually number of extra traversals is less than this becaus
we selectively choose which states are differentially encoded.

In addition to reducing the size of the dfa by reducing the number of
transitions that have to be stored.  Differential encoding reduces the
number of transitions that need to be considered by comb compression,
which can result in tighter packing, due to a reduction in sparseness, and
also reduces the time spent in comb compression which currently uses an
O(n^2) algorithm.

Differential encoding will always result in a DFA that is smaller or equal
in size to the encoded DFA, and will usually improve compilation times,
with the performance improvements increasing as the DFA gets larger.

Eg. Given a example DFA that created 8991 states after minimization.
* If only comb compression (current default) is used

 52057 transitions are packed into a table of 69591 entries. Achieving an
 efficiency of about 75% (an average of about 7.74 table entries per state).
 With a resulting compressed dfa16 size of 404238 bytes and a run time for
 the dfa compilation of
   real 0m9.037s
   user 0m8.893s
   sys  0m0.036s

* If differential encoding + comb compression is used, 8292 of the 8991
  states are differentially encoded, with 31557 trans removed.  Resulting in

  20500 transitions are packed into a table of 20675 entries.  Acheiving an
  efficiency of about 99.2% (an average of about 2.3 table entries per state
  With a resulting compressed dfa16 size of 207874 bytes (about 48.6%
  reduction) and a run time for the dfa compilation of
   real 0m5.416s (about 40% faster)
   user 0m5.280s
   sys  0m0.040s

Repeating with a larger DFA that has 17033 states after minimization.
* If only comb compression (current default) is used

 102992 transitions are packed into a table of 137987 entries.  Achieving
 an efficiency of about 75% (an average of about 8.10 entries per state).
 With a resultant compressed dfa16 size of 790410 bytes and a run time for d
 compilation of
  real  0m28.153s
  user  0m27.634s
  sys   0m0.120s

* with differential encoding
 39374 transition are packed into a table of 39594 entries. Achieving an
 efficiency of about 99.4% (an average of about 2.32 entries per state).
 With a resultant compressed dfa16 size of 396838 bytes (about 50% reduction
 and a run time for dfa compilation of
  real  0m11.804s (about 58% faster)
  user  0m11.657s
  sys   0m0.084s

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-01-09 16:55:55 -08:00
..
libapparmor_re Add Differential State Compression to the DFA 2014-01-09 16:55:55 -08:00
po Update parser translations as discussed in yesterdays meeting 2013-11-14 10:20:43 -08:00
tst parser: remove length restriction in convert_aaregex_to_pcre usage 2013-12-16 01:15:17 -08:00
apparmor-parser.spec.in Add an example parser.conf file 2011-10-07 14:43:54 -07:00
apparmor.d.pod parser: Document eavesdropping permission syntax in apparmor.d(5) 2013-12-06 11:18:17 -08:00
apparmor.pod can ?not fix apparmor.pod 2013-12-12 03:07:37 +01:00
apparmor_parser.pod fix broken URLs in various utils/*.pod files. 2013-09-19 21:17:39 +02:00
COPYING.GPL rpmlint complains about an outdated FSF address in parser/COPYING.GPL. 2011-11-27 13:52:06 +01:00
dbus.c parser: Add make variable to build against local or system libapparmor [v3] 2014-01-06 14:46:10 -08:00
dbus.h parser - add support for variable expansion in dbus rules 2013-08-29 12:34:13 -07:00
frob_slack_rc as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
immunix.h Move public mediation class types and perms to apparmor.h 2013-12-06 11:20:06 -08:00
lib.c Convert the parser to C++ 2013-09-27 16:13:22 -07:00
lib.h apparmor: abstract out the directory walking routine 2012-08-16 16:26:03 -07:00
Makefile parser: Add make variable to build against local or system libapparmor [v3] 2014-01-06 14:46:10 -08:00
mount.c Convert the parser to C++ 2013-09-27 16:13:22 -07:00
mount.h Fix mnt_flags passed for remount 2012-03-22 07:55:58 -07:00
parser.conf Commit the example parser.conf file that was supposed to be part of 2011-10-09 20:15:03 -07:00
parser.h parser: Check for kernel support prior to processing dbus entries 2013-10-29 17:03:23 -07:00
parser_alias.c Convert codomain to a class 2013-09-27 16:16:37 -07:00
parser_common.c parser: Check for kernel support prior to processing dbus entries 2013-10-29 17:03:23 -07:00
parser_include.c allow directories to be passed to the parser 2013-10-26 00:15:13 -07:00
parser_include.h allow directories to be passed to the parser 2013-10-26 00:15:13 -07:00
parser_interface.c parser - fix void* warnings 2013-10-14 14:37:48 -07:00
parser_lex.l parser: Add dbus eavesdrop permission support to apparmor_parser 2013-12-06 11:17:43 -08:00
parser_main.c Add Differential State Compression to the DFA 2014-01-09 16:55:55 -08:00
parser_merge.c Convert codomain to a class 2013-09-27 16:16:37 -07:00
parser_misc.c parser: Add make variable to build against local or system libapparmor [v3] 2014-01-06 14:46:10 -08:00
parser_policy.c Convert codomain to a class 2013-09-27 16:16:37 -07:00
parser_regex.c parser: Add make variable to build against local or system libapparmor [v3] 2014-01-06 14:46:10 -08:00
parser_symtab.c Convert codomain to a class 2013-09-27 16:16:37 -07:00
parser_variable.c parser: remove now unused clone_and_chain functions 2013-12-16 01:30:13 -08:00
parser_yacc.y parser: Add make variable to build against local or system libapparmor [v3] 2014-01-06 14:46:10 -08:00
policydb.h Move public mediation class types and perms to apparmor.h 2013-12-06 11:20:06 -08:00
profile.cc parser - fix more memory leaks 2013-10-14 14:34:12 -07:00
profile.h parser: fix rlimit missing initializer warning 2013-12-10 12:42:50 -08:00
rc.aaeventd.redhat as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
rc.aaeventd.suse openSUSE patch to remove the "-f" parameter from startproc in rc.aaeventd.suse / 2011-08-13 14:22:35 +02:00
rc.apparmor.debian as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
rc.apparmor.functions Update the copyright dates for the apparmor_parser 2012-02-24 04:21:59 -08:00
rc.apparmor.redhat as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
rc.apparmor.slackware as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
rc.apparmor.suse It looks like rc.apparmor.functions renamed "aa_log_action_begin()" to 2011-09-15 20:20:23 +02:00
README parser - update README information 2013-10-11 22:14:28 -07:00
README.devel parser: add some developer documentation 2013-12-10 14:15:02 -08:00
subdomain.conf Here's an update to rename another chunk of things that still used 2011-01-13 13:58:26 -08:00
subdomain.conf.pod fix broken URLs in various utils/*.pod files. 2013-09-19 21:17:39 +02:00
techdoc.tex various changes in building techdoc.tex: 2012-05-09 00:41:06 +02:00
unit_test.h Convert codomain to a class 2013-09-27 16:16:37 -07:00

The apparmor_parser allows you to add, replace, and remove AppArmor
policy through the use of command line options. The default is to add.
`apparmor_parser --help` shows what the command line options are.

You can also find more information at http://wiki.apparmor.net

Please send all complaints, feature requests, rants about the software,
and questions to the apparmor@lists.ubuntu.com mailing list. Bug
reports can be filed against the AppArmor project on launchpad.net at
https://launchpad.net/apparmor or reported to the mailing list directly
for those who wish not to register for an account on launchpad.

Security issues can be filed as security bugs on launchpad
or directed to security@ubuntu.com. We will attempt to
conform to the RFP vulnerability disclosure protocol:
http://www.wiretrip.net/rfp/policy.html

Thanks.

-- The AppArmor development team