Commit graph

2235 commits

Author SHA1 Message Date
Tyler Hicks
063095bcaa Subject: libapparmor: Move mode parsing into separate function
The getpeercon functions need to parse the mode from the confinement
string. This patch creates a function that aa_getpeercon_raw() and
aa_getprocattr_raw() can both use.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:53:39 -07:00
John Johansen
0d86e64114 Subject: libapparmor: fix return value of aa_getpeercon_raw
Return the total size of the security context on success
as documented.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:52:46 -07:00
John Johansen
b6c9a7623a Subject: libapparmor: Safeguard aa_getpeercon buffer reallocation
Protect against bugs in AppArmor's getsockopt() LSM hook from sending
aa_getpeercon() into an infinite loop.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:52:15 -07:00
Tyler Hicks
887c0a9a44 Subject: Fix mount rule preprocessor output
Currently, mount rule preprocessor output is incorrect:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mountmount =ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mountmount  in (ro) /s -> /d, }

This is due to incorrect placement of DUMP_PREPROCESS in parser_lex.l.
With this patch, the output is correct:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mount options=ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mount options in (ro) /s -> /d,

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:46:57 -07:00
John Johansen
a3a3624c57 More updates to the apparmor 3 docs - they are still not in a usable state 2013-06-14 12:35:51 -07:00
Seth Arnold
647d7c1585 move poppler cMap from gnome to fonts, thanks to Felix Geyer 2013-05-30 12:01:27 -07:00
Jamie Strandboge
58f5df11e6 deny writes to upstart user sessions jobs in abstractions/private-files
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:56:10 -05:00
Jamie Strandboge
e3c0425857 add @{HOME}/.gnome2/keyrings/** to abstractions/private-files-strict
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:55:23 -05:00
John Johansen
b643a42dfd This is a minimal fix to apparmor 2.8 for cache failures when the feature
file is larger than the feature buffer used for cache version comparison.

Ideally this would be dynamically allocated but for 2.8 just bumping the
buffer size is the quick fix.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-02 11:32:56 -07:00
John Johansen
c0123646f6 Add more wip apparmor documentation 2013-05-02 10:57:23 -07:00
John Johansen
5d220486e9 rename variable doc 2013-05-02 10:55:02 -07:00
John Johansen
8a2efb0dec Add wip AppArmor Policy document 2013-05-02 10:45:36 -07:00
Jamie Strandboge
ae2cdf0fad Fix two race conditions:
1) make sure that the xpra socket exists before trying to attach to it
2) make sure that the client has attached before we start the application

The fix for '1' solves a problem when the system is under load and the
one for '2' fixes a problem with firefox starting too soon and not
having system themes applied.

Exercising the 1 week rule. Seth Arnold commented on the added sleeps and I
adjusted one based on his comments and replied to the list that the other is
needed and that this improves the sandbox/xpra code but that there are
limitations with driving xpra.

Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:31:39 -05:00
Jamie Strandboge
5f871cfad2 profiles/apparmor.d/usr.sbin.nscd: remove read access to
@{PROC}/sys/vm/overcommit_memory, now included in base

Acked-By: Christian Boltz <apparmor@cboltz.de>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:19:55 -05:00
Jamie Strandboge
7679ac49b1 add read access to @{PROC}/sys/vm/overcommit_memory as used by glibc. See
http://sourceware.org/git/?p=glibc.git;a=commit;h=9fab36eb583c0e585e83a01253299afed9ea9a11

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-04-08 20:11:43 -05:00
Jamie Strandboge
7e9c7c37be update pulseaudio directory and cookie file paths
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-04-08 20:10:36 -05:00
Christian Boltz
53f9cd79f5 Add missing permissions to the nscd profile.
Also deny capability block_suspend because nobody can imagine why it 
would be needed.

References: https://bugzilla.novell.com/show_bug.cgi?id=807104

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-03-05 22:11:59 +01:00
Steve Beattie
0c3899065b Subject: libapparmor - use python-config if it exists when configuring
Author: Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>

Modifiy the libapparmor macro for python to use python-config if it
exists to determine what CPPFLAGS and LDFLAGS to use when building
the python swig libraries. Without this addition, python detection
fails on ubuntu 13.04. I've confirmed that with this patch applied,
the python libraries still build successfully on older releases as well
(as far back as ubuntu 11.10).

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Kees Cook <kees@ubuntu.com>
2013-01-29 15:21:47 -08:00
Steve Beattie
8f931d8fd6 jjohansen's recent commit to extend the datetime parsing of syslog
messages neglected to include the empty .err files in the testsute
directory, resulting in ERROR output. These files were included in the
patch submitted to the mail list. This commit adds them.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-28 11:19:54 -08:00
Steve Beattie
f4716805aa Merge from Michael Palimaka <kensington@gentoo.org>:
* parser - Respect LDFLAGS while building the parser
* libapparmor - Remove an unused configure option

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-28 11:15:57 -08:00
Jamie Strandboge
3c41028cd5 Committing per IRC discussions. Does not update the Makefile to install it yet.
= How it works =
There are basically two modes:
 1. using an existing profile with --profile
 2. dynamically generating a profile

For '1', aa-sandbox is just a wrapper around aa-exec.

For '2', aa-sandbox leverages easyprof and allows you to specify policy
in a limited way on the command line. It then loads the policy into the
kernel as a profile (ie, 'profile <foo> { ... }') so it doesn't get in
the way of existing profiles. It currently calls apparmor_parser via
sudo or pkexec. Once the profile is loaded, aa-exec the application
under the profile.

When -X is specified, the application is launched inside its own X
server using either xpra (the default, which uses Xvfb), xephyr and
xpra3d (xpra, but using Xorg with the xdummy[1] driver for now[2].
xpra3d doesn't currently perform well, but works ok with newer Gnome
applications that now require GLX). When using '-X', it:
- adds an explicit deny rule for ~/.Xauthority
- generates a dynamic Xauthority file for the session in 
  ~/.Xauthority-sandbox<DISPLAYNUMBER>
- adds an allow rule for ~/.Xauthority-sandbox<DISPLAYNUMBER>
- adds checks for xhost being properly setup
- honors the --with-xauthority option which can be used with --profile

With the above, the :0.0 display should no longer be accessible. Eg:
$ ./aa-sandbox -t ~/sandbox-xterm -X /usr/bin/xterm
$ XAUTHORITY=~/.Xauthority DISPLAY=:0.0 xinput
No protocol specified
Unable to connect to X server

This requires a specifically configured xauth/xhost setup, which is less common
on modern distributions. The man page details how to get this setup.


= Trying it out =
Apply the patch, then:
$ cd ./utils
# cli
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates --read-path=/proc/ /usr/bin/uptime

# 2d only
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X /usr/bin/gedit

# 2d alternate (xephyr)
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xephyr /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xephyr /usr/bin/gedit

# 3d
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xpra3d /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xpra3d /usr/bin/glxgears

# With an existing profile:
$ ./aa-sandbox --profile=/usr/bin/evolution -X --with-xserver=xpra3d /usr/bin/evolution


= The Patch =
The patch itself is pretty self contained:
utils/aa-easyprof:
- adjusted to import optparse

utils/easyprof/templates/sandbox*
- add two new templates to easyprof

utils/apparmor/easyprof.py:
- use 'profile <foo>' if '<foo>' is not an absolute path
- adjust parser handling so we can reuse it

utils/aa-sandbox:
- small script to drive utils/apparmor/sandbox.py

utils/apparmor/common.py:
- the start of our python library. aa-easyprof would eventually use 
  this (along with the various rewrites), but for now, only the 
  sandboxing uses it.

utils/apparmor/sandbox.py:
- the sandboxing code itself. Of particular note is the use of classing
  to support different X servers

utils/aa-sandbox.pod:
- the corresponding man page


= Improvements =
* don't use sudo
* make pulseaudio in xpra opt-in (currently it is off)
* take advantage of upstream's 3D patches when they stabilize
* investigate how applications can work with the Unity global menu
* surely lots more 

[1]http://xpra.org/Xdummy.html
[2]http://xpra.org/trac/ticket/147
2013-01-14 09:11:58 -06:00
Jamie Strandboge
e91ac70739 revert r2080, it doesn't actually help anything 2013-01-14 08:55:53 -06:00
Jamie Strandboge
52d8345a55 merge from trunk 2013-01-14 08:54:29 -06:00
Christian Boltz
c4947a5a1c abstractions/mysql: changed paths and MariaDB support
abstractions/mysql  contains
   /var/lib/mysql/mysql.sock rw,
   /usr/share/mysql/charsets/ r,
   /usr/share/mysql/charsets/*.xml r,

but the files moved (at least on openSUSE) to
    /usr/share/mysql-community-server/charsets/*.xml
    /var/run/mysql/mysql.sock
This causes denials for all applications using MySQL on 12.2 and 
Factory.

MariaDB has the *.xml files in
    /usr/share/mariadb/charsets/*.xml
and also seems to use /var/run/mysql/ for the socket.

Since MariaDB is basically a drop-in replacement for MySQL, it makes
sense to allow access to it via abstractions/mysql.

References: https://bugzilla.novell.com/show_bug.cgi?id=798183

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-01-13 14:38:28 +01:00
Michael Palimaka
f86e2858a2 Respect LDFLAGS. 2013-01-14 00:10:41 +11:00
Michael Palimaka
a9e0ae35ba Remove rootlib configure option.
This option is not referenced anywhere, so it should be safe to remove.
2013-01-13 01:56:56 +11:00
Steve Beattie
4962992516 Subject: libapparmor - remove deprecated libimmunix
The libimmunix library is a historical artifact and has generated a
deprecation warning when used to syslog for over 4 years. This patch
removes it entirely from the libapparmor tree.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-01-10 13:52:04 -08:00
Steve Beattie
cc2beb996e Subject: profiles - adjust pusleaudio in abstraction
I was testing out a profile for pulseaudio and hit an issue where my
pulseaudio process was getting the firefox profile applied to it. This
is because in abstractions/ubuntu-browsers.d/multimedia the rule for
pulseaudio is /usr/bin/pulseaudio ixr; attached is a patch to change it
to Pixr, so as to use a global pulseaudio policy if it exists.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-01-09 15:12:06 -08:00
John Johansen
902c48d748 The following patch extends the libraries log parsing to support more date
time formats.

currently the only supported format is
  <Month> ## hh:mm:ss

extend this to
  <Month> ## hh:mm:ss(.ms)?((+|-)timezone)?

  yyyy-mm-dd hh:mm:ss(.ms)?((+|-)timezone)?

  yyyy-mm-ddThh:mm:ss(.ms)?((+|-)timezone)?

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-08 14:22:00 -08:00
Steve Beattie
e80eeb3296 Subject: update sshd extra profile
From: Simon Déziel <simon.deziel@gmail.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/228229

Update sshd profile to function under 12.04 LTS.

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-04 22:31:00 -08:00
Steve Beattie
e3e47a7b61 Subject: profiles - owner usage for @{HOME} rules
From: Simon Deziel <simon.deziel@gmail.com>

A fair number of the rules that apply to files in @{HOME} predate the
existence of the 'owner' qualifier. This patch adds the 'owner'
qualifier in several places.

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-04 22:05:53 -08:00
Steve Beattie
33bfedb95a Add comment describing why check-logprof was dropped from the make check
target in the profiles Makefile, for future archaeological spelunking.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2013-01-04 16:33:41 -08:00
Steve Beattie
fd26b2c044 Disable the logprof check by default for the profiles tree, as logprof
has not kept pace with language changes.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-01-02 17:56:45 -08:00
Steve Beattie
ce8bb0863b Subject: profiles - dnsmasq: allow writes to
/{,var/}run/sendsigs.omit.d/*dnsmasq.pid for network manager
 integration

Author: Jamie Strandboge <jamie@canonical.com>
Description: allow writes to /{,var/}run/sendsigs.omit.d/*dnsmasq.pid
 for network manager integration
Bug-Ubuntu: https://launchpad.net/bugs/941808

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-02 15:47:28 -08:00
Steve Beattie
1cc0885890 Subject: profiles - use @{pid} tunable
This patch adds the kernelvars tunable to the global set that is usually
included by default in apparmor policies. It then converts the rules
that are intended to match /proc/pid to use this tunable.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-01-02 15:34:38 -08:00
Steve Beattie
3810ecb08b Subject: profiles - finish @{PROC} conversion
This patch finishes the conversion from /proc to the @{PROC}
tunable within profiles and abstractions. It also adjusts some of
the /proc/*/something usages to @{PROC}/[0-9]*/something to restrict
things to just the /proc/pid directories. (A followup patch will
convert these to use @{pid} from the kernelvars tunable.)

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-01-02 15:31:01 -08:00
Steve Beattie
39b1aa98eb Subject: profiles - add user's XCompose file to X abstraction
In testing the skype profile, I found access to my @{HOME}/.XCompose
was being rejected. This patch updates the X abstraction to take a
user's defined XCompose key shortcuts into account.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-01-02 15:23:08 -08:00
Steve Beattie
f536c8c50d Subject: profiles - update skype profile
Author: Jamie Strandboge <jamie@canonical.com>
Bug-Ubuntu: https://launchpad.net/bugs/933440 Forwarded: yes

This is a very slightly updated version of the skype profile
update that Jamie Strandboge submitted, but did not get a review.
The only addition over the previously submitted version is rw access
to @{HOME}/.config/Skype/Skype.conf.

(This commit incorporates the additional @{HOME}/.kde4 change proposed
by Christian Boltz <apparmor@cboltz.de>)

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-01-02 15:17:35 -08:00
Steve Beattie
fb510f8d5b Subject: profiles - fix apparmor_api abstractions
The apparmor_api abstractions make the mistake of including tunables
directly, which is a no-no since the variable definitions in tunables
need to occur in the preamble of a profile, not embedded within it.
This patch removes those includes, and replaces them documentation of
tunables are necessary, as some of the expected ones are not part of
tunables/global.

It also adjust the kernelvars tunable's definition of the @{pid}
regex, as the current parser does not support nesting of {} groupings,
which breaks any profile that attempts to use the tunable.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-01-02 15:02:29 -08:00
Steve Beattie
d19097c5e1 Subject: profiles - nvidia abstraction cleanups
This patch modifies the nvidia abstraction to add the livdpau wrapper
config file for nvidia workarounds. It also converts the /proc/
rules to use the @{PROC} tunable. And finally, it converts the
ubuntu-browsers.d/multimedia abstraction to use the nvidia abstraction.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-01-02 14:39:45 -08:00
Steve Beattie
f9b9212100 Subject: profiles - separate out logprof checks from parser checks
This patch separates out make check in the profiles/ directory into
two sub targets, for checking profiles against the built parser
and aa-logprof respectively. The logprof check currently makes some
assumptions about the environment that make it difficult to run in
a minimal chroot environment.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-01-02 14:33:12 -08:00
Christian Boltz
5a053dc580 speed up aa-decode by using a bash regex matching instead of calling egrep for each line.
Acked-by: Steve Beattie <sbeattie@ubuntu.com>

(Patch sent 2012-11-01, Acked-by from 2013-01-01)
2013-01-01 20:15:04 +01:00
Steve Beattie
3690a2e1c0 Subject: profiles - fix make check
When I corrected the profiles/Makefile to automatically find files to
install, I converted one variable name but missed a later location where
that variable was used, which broke the 'make check' target, because
directories would be handed to the apparmor parser. This patch corrects
that and also makes the VERBOSE flag report each profile name as it's
being handed to the parser.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2012-12-21 22:43:11 -08:00
Steve Beattie
039e8d285b Add a parser testcase that triggered the match flags state issue that
was addressed (however temporarily) in commit 2085.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2012-12-10 17:10:40 -08:00
John Johansen
66717a2aec temp fix using the 2.8 patch until the 3.0 patch is ready to land
fix a nasty little bug that can surface in apparmor 2.8 when
Hats/children profiles are used.
  
the matchflags in the dfa backend are not getting properly reset, which
results in a previously processed profiles match flags being used. This is
not a problem for most permissions but can result in x conflict errors.
  
Note: this should not result in profiles with the wrong x transitions loaded
as it causes compilation to file with an x conflict.
  
This is a minimal patch targeted at the 2.8 release. As such I have just
updated the delete_ruleset routine to clear the flags as it is already
being properly called for every rule set.

Apparmor 2.9/3.0 will have a different approach where it is not possible
to reuse the flags.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2012-12-10 17:08:19 -08:00
Steve Beattie
40d4e22249 Add a small sleep call to the onexec test to give the forked process a
chance to run before verifying it's current and future confinement
state. In testing the combined sleeps added roughly a second to
onexec.sh's total time on relatively reasonable hardware.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: John Johansen <john.johansen@canonical.com> (via IRC)
2012-12-10 10:01:38 -08:00
Steve Beattie
3298ac489c This patch modifies the parser's caching test to more accurately detect
whether or not the filesystem has a fine enough timestamp resolution.
Occasionally even on filesystems like ext3, the two files' creation
dates would differ when created less than a second apart, which would
typically cause the 'Cache is used when cache is newer' test to fail
because the cached file would have the same timestamp as the profile.

The fix creates 10 files 0.1 seconds apart and ensures that all ten
have distinct timestamps.

(The occasional failure was caught in testing runs like
 https://bugs.launchpad.net/qa-regression-testing/+bug/1087061/ )

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2012-12-07 23:18:40 -08:00
Jamie Strandboge
7baf9a4d36 utils/apparmor/sandbox.py: sigh, add another sleep to avoid a race in firefox 2012-12-04 10:15:34 -06:00
Jamie Strandboge
826a84aca1 merge from trunk 2012-12-04 10:12:09 -06:00
Steve Beattie
6a8e98d4b7 Add a small sleep call to the onexec test to give the forked process a
chance to run before verifying it's current and future confinement
state. In testing the combined sleeps added roughly a second to
onexec.sh's total time on relatively reasonable hardware.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-By: John Johansen <john.johansen@canonical.com> (via IRC)
2012-11-30 21:25:23 -08:00