Commit graph

353 commits

Author SHA1 Message Date
Steve Beattie
11bfb9a737 Hook up the parser/tst 'make clean' target to the parser's makefile;
modify the parser/tst 'make clean' target to not blow away the readme
file.
2011-03-07 12:14:51 -08:00
Steve Beattie
03b8aee481 Merge from trunk revs 1676 and 1677: Override AF_MAX for kernels that
don't support proper masking. Older versions of the apparmor kernel
patches didn't handle receiving network tables of a larger size than
expected.  Allow the parser to detect the kernel version and override
the AF_MAX value for those kernels.  This also replaces the hack
using a hardcoded limit of 36 for kernels missing the features flag.

Also, ensure that the buffer read from /proc/sys/kernel/osrelease is
null terminated.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-03-07 07:05:37 -08:00
Steve Beattie
74ae28012f Merge from trunk rev 1666: Update the copyright message in
apparmor_parser --version

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-02-23 13:28:53 -08:00
Steve Beattie
955404ca00 Author: Jamie Strandboge <jamie@canonical.com>
Description: the Ubuntu buildds do not have the AppArmor securityfs mounted, so
 the cache tests fail. This patch skips these tests if the introspection
 directory is not mounted, but runs them if it is. This should allow testing of
 local builds while still allowing builds on the official buildds.

Acked-By: Steve Beattie <sbeattie@ubuntu.com> - both Ubuntu and
OpenSUSE were carrying patches that disabled the caching test,
though OpenSUSE's disabled it completely rather than checking. The
parser builds need to complete even when the kernel it's building on
doesn't support AppArmor or all the extensions that the parser needs
at runtime.
2011-02-15 10:34:17 -08:00
Steve Beattie
d788ceb928 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor-parser: Fix up translations
References: bnc#586070

Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-14 17:43:44 -06:00
Steve Beattie
c1a11fb8b6 Merge from trunk revision 1572: This patch fixes the parser's lexer to
not passthrough other invalid characters in variable declarations. It
also adds testcases demonstrating the issue.

Nominated-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-14 16:55:20 -06:00
Steve Beattie
d7e06b79bb Merge from trunk revision 1571: This patch fixes the parser to return
an error when variable declaration statements contain trailing commas,
instead of passing them through to STDOUT. It also adds parser
testcases demonstrating the issue.

Nominated-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-14 16:53:51 -06:00
Steve Beattie
4edf5a5a06 Merge from trunk revision 1582: update the man pages to:
* add Canonical to the headers of the pod files touched
    * use aa_change_hat() instead of change_hat() (LP: #692216)
    * use http://wiki.apparmor.net in the SEE ALSO
    * use http://https://bugs.launchpad.net/apparmor/+filebug for bugs
    * prefix 'aa-' in SEE ALSO section for utilities (eg, 'aa-complain'
      for 'complain')

Nominated-by: Jamie Strandboge <jamie@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-13 16:29:20 -06:00
Steve Beattie
ddf1e922d0 Merge from trunk revision 1580: parser/apparmor.d.pod: more fully
document child profiles, including:
    - cx and Cx
    - change_profile()

Nominated-by: Jamie Strandboge <jamie@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-13 16:04:35 -06:00
Steve Beattie
2cc5b3ae70 Merge from trunk revision 1579: apparmor.d.pod: document [^]
Nominated-by: Jamie Strandboge <jamie@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-13 15:59:27 -06:00
Steve Beattie
e66c163042 Merge from trunk revision 1578: document audit, deny and owner rule
qualifiers (LP: #349049)

Nominated-by: Jamie Strandboge <jamie@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-13 15:58:04 -06:00
Steve Beattie
e638a8b3f4 Merge from trunk revision 1576: parser/apparmor.d.pod: clarify alias rules
Nominated-by: Jamie Strandboge <jamie@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-13 15:52:12 -06:00
Steve Beattie
0fb25b57e3 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor: Fix use after free in regexp parser

 There are two cases of use-after-free in the simply_tree_base code. It
 worked in the past because there aren't any allocations between the
 free and the use, so it was still around.

 With glibc's memory perturbing feature (set _MALLOC_PERTURB to anything),
 the freed memory is poisoned. This causes crashes in e.g. apparmor_parser
 while parsing certain profiles.

 This patch addresses it by saving a pointer to the node to free after
 the node is advanced.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-07 14:24:24 -08:00
Steve Beattie
2207e0b264 Fix two x transition conflict bugs.
The is_merged_x_consistend macro was incorrect in that is tested for
USER_EXEC_TYPE to determine if there was an x transition.  This fails
for unconfined execs so an unconfined exec would not correctly conflict
with another exec type.

The dfa match flag table for xtransitions was not large enough and not
indexed properly for pux, and cux transitions.  The index calculation did
not take into account the pux flag so that pux and px aliased to the same
location and cux and cx aliased to the same location.

This would result in the first rule being processed defining what the
transition type was for all following rules of the type following.  So
if a px transition was processed first all pux, transitions in the profile
would be treated pux.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>

Add auto generation of xtransition conflict tests

All the combiniation of xtransition conflics where not well represented in
the regression test suite.  Instead of relying on multiple static test
files, automatically generate all possible conflicts.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-07 12:46:15 -08:00
Steve Beattie
9fa6814900 Merge from trunk rev 1514: Have the parser makefile honor CFLAGS
environment variable.

Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: John Johansen <john.johansen@canonical.com>
2010-10-09 14:19:13 -07:00
Steve Beattie
9c183302b5 Merge from trunk rev 1388: Break out make targets so that distributors
that don't want full docs can pick targets they want. Comment out
debug dump of generate af_names.h.

Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: John Johansen <john.johansen@canonical.com>
2010-09-30 13:28:26 -07:00
Steve Beattie
b9172f195d When loading without the 2.4 compatibility patch, the parser needs the
following patch or it will explode when it can't find the "features"
file.

Bug: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/626984
Nominated-by: Kees Cook <kees@ubuntu.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-09-16 10:13:11 -07:00
Steve Beattie
266800554b Merge from trunk rev 1501: Reorder the timstamp check to move it to
the beginning of the script and add an additional sleep before the
parser invocation that generates the cache file for the first time.

Submitted-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Kees Cook <kees@ubuntu.com>
2010-09-15 14:37:53 -07:00
Steve Beattie
be77957326 Merge from trunk revs 1495 and 1496: Update how cache validation is
done to fix the bug where abstraction updates do not cause the cache
file to become invalid.

Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-09-15 12:01:21 -07:00
Steve Beattie
dba072c530 Merge from trunk rev 1498: Fix write_cache to not be a privileged
operation so that the caching tests can be added to the build. Update
caching tests to detect non-ns-resolution filesystems and back off
on the timing test.

Nominated-by: Kees Cook <kees.cook@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-09-15 11:34:38 -07:00
Steve Beattie
c2109f2c3b Cherry picked elements from trunk commit 1437: fix serious compiler
warnings, silence an error in non-rpm build environs.

Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Kees Cook <kees@ubuntu.com>
2010-09-15 10:24:55 -07:00
Steve Beattie
9578c217cb Much pared down version of trunk commit 1497: fix error checking so that
caching will work without needing kernel_load.

Nominated-by: Kees Cook <kees.cook@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-09-15 09:33:01 -07:00
Steve Beattie
8b79fb5fea Merge from trunk revs 1476, 1477, and 1478: cope with various elements
that the upstream 2.6.36 kernel is missing.

All Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-08-26 11:24:41 -07:00
Steve Beattie
030d97e3f1 Merge from r1430: fix for LP: #599450
Changes the table resizing so that there is always sufficient high
entries in the table, preventing bounds violations from occurring.

Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-07-24 16:16:14 +02:00
Steve Beattie
0eb5d7c050 Merge from r1429: combine the two separate table resize code segments
into a single functionally equivalent segment.

Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-07-24 16:09:25 +02:00
Steve Beattie
1c1de08f11 Partial merge r1419: add the -p flag to support the output of
flattened profiles.

Submitted-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-07-17 18:39:37 -07:00
Steve Beattie
1ad455c6da Merge r1385: Fix memory leak during dfa minimization.
Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Marc Deslauriers <marc.deslauriers@canonical.com>
2010-07-13 16:36:47 -07:00
Steve Beattie
b5c8c2bdaf Merge r1379: Fix leaking file descriptors on included files.
Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Marc Deslauriers <marc.deslauriers@canonical.com>
2010-07-13 16:31:57 -07:00
Steve Beattie
ac1a585bbe Merge from trunk rev 1424: Move expression tree node labeling into expr
node themselves to reduce memory usage and make node labeling per dfa
rather than global.

Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-07-12 15:53:51 -07:00
Steve Beattie
8187d02864 Merge in rev 1422 from trunk: Cleaning up the sets firstpos, lastpos,
and followpos early reduces peak memory usage.

Nominated-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-07-12 15:28:26 -07:00
Steve Beattie
8525087270 Merge in r1413 and r1418: report correct filename/line number on errors
in the parser.

r1413 Nominated-by: Kees Cook <kees@ubuntu.com>
r1413 Acked-By: Steve Beattie <sbeattie@ubuntu.com>
r1418 Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
r1418 Acked-By: Kees Cook <kees@ubuntu.com>
r1418 Acked-By: John Johansen <john.johansen@canonical.com>
2010-06-25 12:58:17 -07:00
Steve Beattie
21875a520d Fix leaking file descriptors on included files. 2010-03-12 01:50:26 -08:00
Steve Beattie
4094043011 Fix up some testcase description fields 2010-03-10 21:38:10 -08:00
John Johansen
04a872f927 Add some new profile flag tests to validate parsing of the new flags
controlling nameresolution.
2010-03-10 17:00:24 -08:00
Steve Beattie
69d59f80ed Don't (un)load flattened hats on removal, as the kernel pulls them out
automatically (and the parser emits an error due to this).
2010-03-09 01:38:12 -08:00
Steve Beattie
ebe59ca483 Add a simple 'cx' mode testcase. I *think* I'm specifying it correctly. 2010-03-08 22:28:22 -08:00
Steve Beattie
fc669861fe Yuck, fix up bogus type conversions. Also fix up some PDEBUG statements,
to make debugging why things are going wrong in specific examples
easier.
2010-03-08 21:49:16 -08:00
Steve Beattie
61c61f9aab Add some unit tests for processunquoted() -- sadly it handles octals
fairly wrong. Need to fix, but not tonight. Le sigh
2010-03-08 20:38:54 -08:00
John Johansen
5709d94710 Add the ability to control how path mediation is done at the profile level 2010-02-17 12:21:52 -08:00
Kees Cook
4f5686901b include *.dpkg-bak in files to ignore 2010-02-16 12:56:04 -08:00
John Johansen
725328c209 Allow for a location to alias to multiple locations. Ie.
alias / -> /rofs,
alias / -> /rwfs,
2010-02-12 13:51:27 -08:00
John Johansen
ee00b0cea2 Update aliases so that they apply properly to profile names.
Instead of updating the profile name, allow a profile to have multiple
alternate names.  Aliases are now added as alternate names and matched
through the xmatch dfa.
2010-02-12 13:49:58 -08:00
John Johansen
eafddd3cea Fix alias to keep old rule and add new one instead of updating old rule.
Alias was broken because it when an alias was made the old path was completely
removed and there was no way to specify it.  Update it so aliases just add
an new duplicate rule instead.
2010-02-12 13:46:55 -08:00
John Johansen
94b2a345f2 Fix -S flag so the profile can be dumped to stdout again
The changes to the loader permission logic broke the -S flag, so update
the test so that we can dump out the profile again.
2010-02-12 13:44:00 -08:00
John Johansen
8dd795dec1 Rework the partitioning to take advantage of Partitions now being a list 2010-01-31 23:21:00 -08:00
John Johansen
8bcfa1a32f Move partitions from using sets to lists as this is a better match
for what is being done.
2010-01-31 23:19:54 -08:00
John Johansen
e984b6ff74 Seperate Partition definition for States. This is a small step to cleaning
up the code
2010-01-31 23:18:14 -08:00
John Johansen
1179c1a42c Improve partitioning performance slightly by inserting new partitions
imediately after the current partition being considered, instead of
at the back of the parition list.  This does two things, it makes it
more likely the data is in cache, and it also in general results in
more partitions being created in a single pass.
2010-01-31 23:12:33 -08:00
John Johansen
80c7ee74a2 Speedup transition table compression. This is a basic improvement and
not an algorithmic improvement.  It does the same basic algorithm of
test until it can insert the data, but instead of only tracking the
first free entry (and recomputing it each pass).  It tracks all
free entries reducing the number of comparisons done and the table
grows in size.

This may actually result in a small loss on small tables, but is a win
for larger tables.
2010-01-27 17:20:13 -08:00
John Johansen
f9906a9584 Update hash calculation
Update the hash calculation to guarentee that states with a different
number of transition entries will be placed in seperate partitions.

This will allow for a better character transition based state comparison.
2010-01-20 05:10:38 -08:00