Commit graph

1442 commits

Author SHA1 Message Date
Steve Beattie
b02e3ff0cd Fix up a couple of grotty bits around the debugging code. 2009-03-19 17:36:40 +00:00
Steve Beattie
be5ddfa59b utils/SubDomain.pm:
- Update matching regex for reordered kernel audit messages (when they
  come through syslog). Ideally, rather than use a regex, the utils would
  just use the log parsing library to determine whether it's a log even
  of interest.
- fix debugging code write a logfile in /var/log/apparmor and not a
  predictable location in /tmp; File::Temp would be the right solution
  except that the log file is created in a BEGIN clause, and
  File::Temp.new() ends up returning an unopened filehandle in that
  situation, so logging fails. Someone with more perl-fu may know how to
  fix that.
2009-03-19 15:32:02 +00:00
Steve Beattie
b1fab26057 Don't overwrite $STATUS if we've already hit a profile that failed
to parse.
2009-03-19 02:50:53 +00:00
Steve Beattie
19ddb3bfa4 Testcases that are vaguely related to
https://bugs.launchpad.net/bugs/340183
2009-03-13 06:39:05 +00:00
Steve Beattie
0208c5b5d6 whitespace bah. 2009-03-13 06:38:16 +00:00
Steve Beattie
62372fe628 Tentative fix for https://bugs.launchpad.net/bugs/340183 2009-03-13 06:37:39 +00:00
Steve Beattie
a9ff89cd5d Testcase reorg: rename all the ones that pertain to the old logging
style for clarity. Support for these should be dropped in the future,
because it just introduces bugs.
2009-03-13 05:48:06 +00:00
Steve Beattie
1acfd92d8a * set yydebug when YYDEBUG is set, this will cause mucho bison debuginfo
to be emitted.
* whitespace fixup
2009-03-13 05:19:39 +00:00
Steve Beattie
947a77bcde Add a case to the interface error reporting for -EACCES return, which
likely means that the admin attempted to load a policy while confined by
apparmor.
2009-03-13 03:44:26 +00:00
Steve Beattie
24ddc6f081 Debugging fixups:
- report applied modes (enforce, complain, audit)
- if local profile, report name of profile it is local to
2009-03-12 19:23:27 +00:00
Steve Beattie
27b8275d5a Add parsing testcases:
- basic local (interior) profile support testcase
- basic deny rules test
2009-03-12 19:22:08 +00:00
Steve Beattie
ff1dc201b1 Fix a bug where passing --Complain on the command line would override an
audit flag set in the profile(s).
2009-03-12 19:19:35 +00:00
Steve Beattie
13f73b626b Mild cruft cleanup (woo!)
- fix "Namespcae" tyop
- get rid of sub_name and default_deny from the main profile struct as
  they haven't been used for a long time; also eliminates their output
  from the debugging output.
- emit dumped parsing structure with only one -d, users were confuzzled
  and it was not documented that you needed to use -dd to get it to
  output anything if DEBUG wasn't set when compiling.
2009-03-12 16:05:19 +00:00
Steve Beattie
087182be9a Blarg, we actually documented --complain as --Complain, which of course
doesn't work. Making the parser match the documentation, though either
form should still work.

(Based on a secondary element of https://bugs.launchpad.net/bugs/341205)
2009-03-12 15:21:46 +00:00
John Johansen
01519b3ae0 Fix leak when AppArmor encounters a deleted file 2009-02-15 02:38:53 +00:00
John Johansen
59f0d08417 Update translation files 2009-02-07 12:16:03 +00:00
John Johansen
4fc0bd5881 Update translation files 2009-02-07 12:14:40 +00:00
John Johansen
262075ca80 Update translation files 2009-02-07 12:09:50 +00:00
John Johansen
1def78f1c4 Add missing gettext for "Repository" prompt 2009-02-06 11:09:54 +00:00
John Johansen
9574478aaa Fix compile bug reported by Mario Fetka, 2009-01-04 09:42:46 +00:00
John Johansen
458a6c0418 Apply patch from mario.fetka@gmail.com which fixes the config file for
the module being builtin in 2.6.27, 2.6.28
2008-12-13 10:16:05 +00:00
John Johansen
1910575215 Apply patch from mario.fetka@gmail.com to cleanup AppArmor build under
2.6.27/2.6.28
2008-12-13 10:08:32 +00:00
John Johansen
28ba83a313 Update kernel patches for 2.6.28 2008-12-10 17:57:41 +00:00
John Johansen
9d87470a60 update patch becuase tag is being set else where 2008-12-05 09:41:03 +00:00
John Johansen
5148942b90 Fix a missing case in the pcre-expression parsing "\\"
Change the globbing conversion to include [^\x00].  This reduces cases of
artifical overlap between globbing rules, and link rules.  Link rules
are encoded to use a \0 char to seperate the 2 match parts of the rule.

Before this fix a glob * or ** could match against the \0 seperator
resulting the generation of dfa states for that overlap.  This of course
can never happen as \0 is not a valid path name character.

In one example stress policy when adding the rule
  owner /** rwl,
this change made the difference between having a dfa with 55152 states
and one with 30019
2008-12-04 10:44:02 +00:00
John Johansen
037d7b5a57 Clean up the tree simplification code, and make the following improvements
- disable charter, charset merging.  This can actually hamper optimization
  in some cases and needs special cases added to the factoring code.

  The charset code is merged off into its own routines that can be
  reenabled at a later time.

- fix a couple bugs in tree simplifications that would cause earlier
  exit before the tree had even reached a local minima

  I particular the t != c portion of the simplify_tree, would cause
  the loop to exit early if it didn't change but other modifications
  had been made.

- remove the extra epsnode that was getting added to the created tree

- optimize the forward factor alt loop so that it will find all left
  factor matches down the alt subtree without having to loop and recompare
  against nodes that were already checked

These changes result in small improvements in most cases, but in some
policies the changes result in very large wins.  The early bailout of
optimizations was causing 2.5* as many dfa states in one particular
stress test policy.
2008-12-03 03:47:31 +00:00
John Johansen
c4a2786ff7 back port applicable patches from 2.6.27 branch 2008-11-28 13:11:22 +00:00
John Johansen
a4c3f33245 Setup base of 2.6.26 version of patches, copied from for mainline r1292 2008-11-28 11:56:09 +00:00
John Johansen
72bdec2f76 Several cleans, that will be merged in for final release
- fix-complain.diff
  Fixes deny rules in complain mode so that they don't reject events

- mount-capability.diff
  Allow confined applications to mount and unmount as long as they
  have capability sys_admin

- fix-config.diff
  Add the missing SECURITY_NETWORK dependency

- fix-security-param.diff
  Make apparmor respect the security= parameter

- securit_default.diff
  Add a new kernel config option to allow setting the default LSM,
  When multiple LSMs are compiled into the kernel this is often
  more desirable than taking the first LSM to register

- fork-tracking.diff
  Newer kernels have changed the allocation of child pid until after
  the security_clone hook.  This breaks AppArmor's fork tracking
  for processes that enter the null-complain-profile.

  To fix this the parent pid is output with every message.  A corresponding
  update in the tools also must be done.

- fix-d_namespace_path.diff
  It is possible that the root.mnt->mnt_ns has been unmounted, resulting
  in an oops.  In this case just test for it, and if it happens the
  ns_root.mnt passed to __d_path will be NULL resulting in a disconnected
  path.

- AppArmor-misc-cleanups.diff
  Some miscelleanous cleanups from Miklos Szeredi, covering some
  kernel coding style and defaults cleanups

- AppArmor-checkpatch.diff
  patch from Miklos Szeredi, to cleanup sparse warnings, and other misc
  coding style errors.
2008-11-28 09:22:54 +00:00
Steve Beattie
e18d431b0e Resurrect a random profile generator for stress testing the parser.
Needs love in the form of enhancements to support regexs, all the added
features in upcoming 2.3 release, etc.

Could also stand a bit of refactoring to make the ruby program not suck
up so much ram by writing out profiles as things go along rather than
generating a bunch of large objects and keeping them around.
2008-11-26 22:16:48 +00:00
Steve Beattie
edfa025814 Move preamble inclusions to a different directory since it was breaking
the test on including an entire directory.
Add some basic local profile tests.
2008-11-25 19:05:40 +00:00
Steve Beattie
2e5807b6c4 Add two tests for aliases within include files. 2008-11-24 19:53:36 +00:00
John Johansen
9bf970a4c1 Fix the utils to use the unconfined instead of unconstrained, as the kernel no
longer supports the word unconstrained.
2008-11-21 13:03:52 +00:00
John Johansen
e9e58b9887 Fix bnc#447566, where enforce, complain, and audit tools fail to work
for profiles that use the profile keyword before the profile name.
2008-11-21 13:03:00 +00:00
John Johansen
7fdf8d9925 Fix bnc#430358 where the utils make an invalid profile, by outputting
other rules with no permissions.

Since other rules are not currently supported, remove them.
2008-11-21 12:58:48 +00:00
John Johansen
4c3df3ae53 fix bnc#407491, where a solatary / is not properly handled by the utils
The / is stripped and permission is prompted for a "" path.
2008-11-21 12:57:08 +00:00
John Johansen
39343c8675 Fix fork track (bnc#447564)
Fork tracking is broken by the kernel message for clone no longer supplying
the child pid correctly.  Instead the parent pid will be output with each
message and the tools will fake a fork when they detect a previously
unknow parent child relationship.
2008-11-21 12:55:00 +00:00
John Johansen
77caea2cc7 'unconfined' can appear to mix up process names eg. (/usr/bin/rsync vs.
/usr/bin/rsyncd) bnc#408869

The unconfined tool shows:

[...]
29799 /usr/bin/rsync not confined
29799 /usr/bin/rsync not confined

This is because unconfined is grabbing the post symlink resolved exe filename
which for /usr/sbin/rsyncd is /usr/bin/rsync.

To fix this provide both the cmdline and exec name in parenthesis when the
exe name and the cmdline name differ.

For the above example you would see
29799 /usr/bin/rsync (/usr/sbin/rsyncd) not confined
2008-11-21 12:31:22 +00:00
John Johansen
07ded00bd3 Update klogd profile with rejects reported in bnc#436849 2008-11-21 11:51:01 +00:00
John Johansen
f1348fb693 Add missing firefox profile from previous commit 2008-11-21 11:26:27 +00:00
Steve Beattie
1e3e427263 Bleah, the previous code was killing the wrapper sh created by the
open("|")  call, but not the actual apparmor_parser process itself.
2008-11-21 05:00:06 +00:00
Steve Beattie
a64d8142c9 Add a 2 minute (by default, configurable) timeout to each testcase, this
should prevent runaway apparmor_parser processes.
2008-11-20 23:22:43 +00:00
Steve Beattie
e1a2c27cfd Update documentation on how many entries the 3rd stress test generates. 2008-11-20 17:38:38 +00:00
John Johansen
de3ed997a7 Add a test for dfa tree optimization. The test is a profile that could
OOM a machine without dfa tree optimization.
2008-11-20 17:27:32 +00:00
Steve Beattie
a8fea9babc With jjohansen@suse.de's latest optimisation commits, this test case is
now feasible once again.
2008-11-20 17:27:01 +00:00
John Johansen
b017899f12 Fix a bug in tree normalization, where it could get stuck in an infinite loop
when doing Epsnode move, when cating or alting two epsnodes.
2008-11-20 16:19:51 +00:00
John Johansen
0491e8d707 Add char node, and char node set merging. This does not have a substantive
impact on performance but makes tree debugging nicer.
2008-11-20 13:23:13 +00:00
John Johansen
c0533b390b Reintroduce calling back into tree simplification when any modifications have
been made but only from the top level.  This allows us to get the
optimizations that were missed, while not causing the massive recursive call
explosion we had before.
2008-11-20 13:21:23 +00:00
John Johansen
1855fde331 Reduce the use of simplify recursion, repeating the recursion of single
changes is a waste especially as we get to larger subtrees.

Unfortunately this also means that a fair bit of optimization is lost.
2008-11-20 13:18:30 +00:00
John Johansen
91eb71e9fa Improve tree normalization
- reduce the amount it is called, and the amount of recursion it does
- fix a bug that would prevent trees from being fully normalized
2008-11-19 16:54:26 +00:00