Commit graph

5108 commits

Author SHA1 Message Date
Vincas Dargis
162e5086a5 xdg-open: update usage example
Add notes about optional abstractions that can be useful for making
(rare) message boxes created by *-open helpers work correctly.
2019-12-08 15:59:58 +02:00
Vincas Dargis
8b481d469b kde-open5: do not enable gstreamer support by default
Make kde-open5 abstraction more conservative by removing gstreamer
support by default. Update usage example to suggest conditionally including
gstreamer abstraction if required.
2019-12-08 15:53:36 +02:00
Vincas Dargis
d35faafdd2 kde-open5: do not enable a11y by default
Update kde-open5 abstraction to not include accessibility abstraction by
default.

Update documentation to suggest adding it manually in child profile when
using kde-open5 if accessibility access is required by profile author.
2019-12-08 15:25:52 +02:00
Vincas Dargis
e77abfa56a exo-open: update comment about DBUS denial
Make comment more clear about denied DBUS access, no need to raise
questions. Remove redundant comment.
2019-12-08 15:13:33 +02:00
Vincas Dargis
0a55babe9a exo-open: do not enable a11y by default
Update exo-open abstraction to not include accessibility abstraction by
default.

Update documentation to suggest adding it manually in child profile when
using exo-open if accessibility access is required by profile author.
2019-12-08 15:07:57 +02:00
Vincas Dargis
501aada843 gio-open: fix denies Ubuntu Eoan
gio-open abstraction is outdated for latest Ubuntu with Gnome.

Add rule to remove denial for reading snapd-related files.
2019-12-08 13:40:22 +02:00
Vincas Dargis
ac08dc66ec kde-open5: fix denies Ubuntu Eoan
kde-open5 abstraction is outdated for latest Ubuntu with KDE.

Add rules to make kde-open5 work again.
2019-12-08 13:17:38 +02:00
Vincas Dargis
80514906f0 kde-open5: use dbus-network-manager-strict abstraction
Remove inline dbus rules and include new dbus-network-manager-strict
abstraction instead.
2019-12-08 12:40:35 +02:00
Vincas Dargis
f07f077174 exo-open: Allow playing alert sounds
In case of error (for example failing to open provided uri) message box
is show, and alert sound is played. Currently `exo-open` abstraction
does not allow access to audio subsystems in result producing denials in
system logs.

Update abstraction to include `abstractions/audio`.
2019-12-08 12:22:52 +02:00
Vincas Dargis
af278ca691 exo-open: Fix denials on OpenSUSE
exo-open fails on OpenSUSE due to different/missing paths.

Update abstraction to fix denials on OpenSUSE.
2019-12-08 12:22:52 +02:00
Vincas Dargis
622fc44bd0 Add xdg-open (and friends) abstraction
Implement set of abstractions to handle opening uris via xdg-open and similar
helpers used on different desktop environments.

Abstractions are intended to be included into child profile, together
with bundle abstractions such as ubuntu-browsers, ubuntu-email and others, for
fine-grained control on what confined application can actually open via xdg-open
and similar helpers.
2019-12-08 12:22:52 +02:00
John Johansen
f421fbd92c CI: cat config.log if libapparmor configure fails
This helped a lot to debug the CI failure caused by 3db14e8e / !430 (merged), and won't add any noise as long as configure succeeds.

Note that this MR is based on master without !433 (merged) which means it will fail in CI (and display config.log). After !433 (merged) got merged, I'll rebase it to show that it won't add additional noise as long as everything works.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/434
Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-27 20:45:44 +00:00
Christian Boltz
b3020dfaf5
CI: cat config.log if libapparmor configure fails
This helped a lot to debug the CI failure caused by
3db14e8e49 / !430, and won't add any noise
as long as configure succeeds.
2019-11-27 21:09:32 +01:00
Christian Boltz
1cfd4d4bbc Merge branch 'cboltz-usr-etc' into 'master'
Allow /usr/etc/ in abstractions/authentication

openSUSE (and hopefully some other distributions) work on moving shipped
config files from /etc/ to /usr/etc/ so that /etc/ only contains files
written by the admin of each system.

See https://en.opensuse.org/openSUSE:Packaging_UsrEtc for details and
the first moved files.

Updating abstractions/authentication is the first step, and also fixes
bugzilla.opensuse.org/show_bug.cgi?id=1153162

See merge request apparmor/apparmor!426

Acked-by: John Johansen <john.johansen@canonical.com> for 2.12..master
2019-11-27 19:40:47 +00:00
Christian Boltz
e90f01cd9d Merge branch 'cboltz-gitlab-ci-zlib' into 'master'
add zlib1g-dev to .gitlab-ci.yml

See merge request apparmor/apparmor!433

Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-27 19:30:41 +00:00
John Johansen
a10fa57fb6 Add dbus-network-manager-strict abstraction
Some applications queries network configuration (using QNetworkConfigurationManager class in Qt and similar), and that produces DBus denials under AppArmor confinement when NetworkManager backend is used.

Add abstraction that allows most common read-only DBus queries for getting current network configuration from NetworkManager backend.


PR: https://gitlab.com/apparmor/apparmor/merge_requests/409
Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-27 18:01:42 +00:00
John Johansen
48fdd0ef76 Remove a selection of obsolete support
Requires NPAPI which no major browsers support anymore: Mozplugger npviewer / nspluginwrapper

The following have been discontinued Google Talk (and plugin) f-spot conkeror galeon Mozilla Prism rekonq Adobe Reader for Linux

Other gnome-codec-install is not in Ubuntu anymore gstreamer0.10 was replaced by 1.0

PR: https://gitlab.com/apparmor/apparmor/merge_requests/417
Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-27 06:14:05 +00:00
John Johansen
6757434350 libapparmor: force -fPIC on .a library generation
currently the .a version of the library is not being generated with
PIC code. This is a problem when you try to link it to PIE binaries.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/422
BugLink: http://bugs.launchpad.net/bugs/1824384
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Time Out
2019-11-26 21:40:45 -08:00
John Johansen
fb3fbd8da5 Out of band transitions
Add support for out of band transitions that be to separate elements that can contain any input character. Out of band transitions can only be triggered by explicit transitions in the code (instruction stream). They function the same as the null transition except they work for all input and when writing expressions there is no need to not match them.

The out of band transitions show up in the dfa as negative offsets from the base. Currently only a single out of band transition of -1 is supported, but it is fairly trivial to add new ones if needed. The negative offset for out of band transitions were chosen instead of positive offsets that are out of input range to leave open the option of extending the input range in the future.

kernel patches: apparmor-kernel!6

v2.

    fix spacing error identified by cboltz
    update commit messages and signed-off-bys
    allow globbing in xattrs to match NULL character
    free leaked xattr cond_entry_list
    make xattr generation conditional on kernel support

v3.

    fix crash in commit: parser: make sure xattr cond_entry_list is not leaked
    port eric's patch from !362 "support matching xattr keys but not values" to work with out of band transitions, and not a separate value array

v4.

    double free fix crash of xattr.name in parser: make sure xattr cond_entry_list is not leaked
    remove xattr/bad_XX tests that are no longer bad because attr names do not have to have a value specified

v5

    fix bug in append_rule where the out of band transition was being converted to character 255

v6

    fix bug in writing of dfa header flags value

v7

    fix bug in out of band transitions where they could in certain cases be matched by an expression and hence not function as a separator.
    fix xattr encoding so xattr presence can be determined distinctly from xattr value
    fix xattr encoding so xattrs are not treated as optional
    fix xattr encoding so that permissions are properly encoded at the end of each segment match
    update xattr regression tests to make failures unique and reflect that nul character values are now allowed

v8

    update transchar comment

v9

    update tranchar comment

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Time Out
2019-11-26 21:35:02 -08:00
John Johansen
3e3c8744f6 regression tests: update xattr_profile.sh to reflect recent improvements
Update the xattr_profile.sh tests so that
- each test can be uniquely identified
- the embedded nul tests are updated to the now supported/passing state

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
444b8e3836 parser: change xattr encoding and allow append_rule to embedd permissions
The current encoding makes every xattr optional and uses this to
propogate the permission from the tail to the individual rule match
points.

This however is wrong. Instead change the encoding so that an xattr
(unless optional) is required to be matched before allowing moving
onto the next xattr match.

The permission is carried on the end on each rule portion file match,
xattr 1, xattr 2, ...

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
e13af5dc96 parser: fix xattr match encoding so optional xattr is distinct
Make sure we can support optional xattrs distinct from optional xattr
values in the encoding.

Currently all xattrs specified are required to be present even
if there value is not specified. However under the old encoding there
was no way to distinguish if the presence of the xattr vs. the
xattr having a null length value.

Fix this so that if we decide to support optional xattrs it is possible
without having to change the abi.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
2416faac54 parser: support matching xattr keys but not values
Support profiles that choose to match the presence of an extended
attribute without validating its value. This lets AppArmor target xattrs
with binary data, such as security.ima and security.evm values. For
example, it's now possible to write a profile such as:

        profile signed_binaries /** xattrs=(security.ima) {
                # ...
        }

Both presence and value matches can be used in the same profile. To
match a signed xattr, target both the xattr and the security.ima value:

        profile python_script /** xattrs=(
                security.evm
                security.apparmor="python"
        ) {
                # ...
        }

Updated to work using out of band matching instead of separate data
array.

Signed-off-by: Eric Chiang <ericchiang@google.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
e5ea3e4a0d parser: Make xattr attachment generation conditional on kernel support
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
9b0a98d00e parser: make sure xattr cond_entry_list is not leaked
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
6b47b8de25 parser: Allow xattr globbing to match the NULL character
xattrs are a byte string that can contain all input characters including
the null character. Allow * ** and ? glob patterns to match the null
character while retaining their apparmor characteristics for '/'.

That is * and ? won't traverse a '/' treating it as a path element.
While ** will match anything.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
2992e6973f parser: convert xmatch to use out of band transitions
xattrs can contain NULL characters in their values which means we can
not user regular NULL transitions to separate values. To fix this
use out of band transition instead.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
53dffc5304 parser/libapparmor_re: add basic documentation about components
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
16b67ddbd6 add ability to use out of band transitions
Currently the NULL character is used as an out of band transition
for string/path elements. This works for them as the NULL character
is not valid for this data. However this does not work for binary
data that can contain a NULL character.

So far we have only dealt with fixed length fields of binary data
making the NULL separator either unnecessary.

However binary data like in the xattr match and mount data field are
variable length and can contain NULL characters. To deal with this
add the ability to specify out of band transitions, that can only
be triggered by code not input data.

The out of band transition can be used to separate variable length
data fields just as the NULL transition has been used to separate
variable length strings.

In the compressed hfa out of band transitions are expressed as a
negative offset from the states base. This leaves us room to expand
the character match range in the future if desired and on average
makes the range between the out of band transition and the input
transitions smaller than would be had if the out of band transition
had been stored after the valid input transitions.

Out of band transitions in the dfa will not break old kernels
that don't know about them, but they won't be able to trigger
the out of band transition match. So they should not be used unless
the kernel indicates that it supports them.

It should be noted that this patch only adds support for a single
out of band transition. If multiple out of band transitions are
required. It is trivial to extend.
- Add a tag indicating support in the kernel
- add a oob max range field to the dfa header so the kernel knows
  what the max range that needs verifying is.
- extend oob generation fns to generate oob based on value instead
  of a fixed -1.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
6062262ccd parser: fix writing dfa flags
Currently the parser is not correctly setting the dfa flag value
and it hasn't been caught because base policy uses a flag value
of 0.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
7c29bfebe3 parser: improve debug output of transhar
Make transchar stream output work with a broader range of values.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
72f93d9aba parser: rename uchar to transchar
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
daa10d3ce1 parser: rework backend to allow for more transitions
As a step in preparing for out of band transitions and double walk
transitions rework the backend from using a char index to a class
with an larger range than char.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
e958da7678 Nnp unconfined exception tests
Add nnp tests around the unconfined exception.

An unconfined task is allowed changing to a profile under nnp restrictions. However this has implications when the task has stacked confinement.

  profile//&unconfined

  profile//&:ns:unconfined

  ...

will not be caught by the unconfined test. Instead the unconfined exception needs to be tested as part of the subset test. Add tests to ensure we can catch regressions around a stacked unconfined profile.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/424
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-27 05:29:13 +00:00
Christian Boltz
6c85836be5
add zlib1g-dev to .gitlab-ci.yml
This fixes the CI failures introduced with
3db14e8e49 - either conf('BLDLIBRARY') or
$PYTHON_EXTRA_LIBS introduce a dependency on zlib-dev ("-lz").
2019-11-19 22:52:22 +01:00
Christian Boltz
663546c284 Merge branch 'cboltz-abstractions-kerberos' into 'master'
abstractions/kerberosclient: allow reading /etc/krb5.conf.d/

See merge request apparmor/apparmor!425

Acked-by: Steve Beattie <steve@nxnw.org> for 2.10..master
Acked-by: John Johansen <john.johansen@canonical.com> for 2.10..master
2019-11-18 21:35:29 +00:00
Christian Boltz
b017f8f8a9 Merge branch 'cboltz-drop-localinclude' into 'master'
Drop 'localinclude' in parse_profile_data() and ProfileStorage

See merge request apparmor/apparmor!427

Acked-by: John Johansen <john.johansen@canonical.com> for 2.12..master
Acked-by: Steve Beattie <steve@nxnw.org> for 2.12..master
2019-11-18 21:32:24 +00:00
Christian Boltz
3db14e8e49 Merge branch 'fix-autoconf-check-for-python-3.8' into 'master'
Fix a Python 3.8 autoconf check

See merge request apparmor/apparmor!430

Acked-by: Christian Boltz <apparmor@cboltz.de> for master and 2.13
Acked-by: Steve Beattie <steve@nxnw.org> for master and 2.13
2019-11-18 20:16:33 +00:00
John Johansen
095efb821f docs: update apparmor.d language description
Update the language description to provide some over arching
principles, such as the policy is declarative.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2019-11-09 14:05:22 -08:00
John Johansen
d6384641c2 added missing functions to slackware init script
There where some functions missing in the Slackware init script which has been added with this commit.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/432
Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-09 11:00:01 +00:00
lmoeller
32105d0816 added missing functions to slackware init script 2019-11-08 13:49:48 +01:00
intrigeri
ccbf1e0bf1 Fix a Python 3.8 autoconf check
Bug-Debian: https://bugs.debian.org/943657

Author: Matthias Klose <doko@debian.org>
2019-10-29 17:53:11 +00:00
Christian Boltz
1567ea6f4c Merge branch 'cboltz-pyflakes-version' into 'master'
README: add PYFLAKES=/usr/bin/pyflakes3 env variable

See merge request apparmor/apparmor!429

Acked-by: John Johansen <john.johansen@canonical.com> for 2.11..master
2019-10-24 21:08:28 +00:00
Christian Boltz
556bb94aa5
README: add PYFLAKES=/usr/bin/pyflakes3 env variable
pyflakes 2.x nowadays complains about
    aa-genprof:60: undefined name 'PermissionError'

We already deprecated py2 support in 2.11 (and obviously nobody tests
with py2 anymore), therefore recommending pyflakes3 makes sense.

Maybe we should also change our Makefiles to use py3 and pyflakes3 by
default, but that will be another (master-only) commit.
2019-10-24 15:36:22 +02:00
Christian Boltz
001ea9e3af
Drop 'localinclude' in parse_profile_data() and ProfileStorage
'localinclude' is/was meant to have 'local/*' includes separate, but
it's write-only and never used, which makes it useless.

Additionally, it causes a crash in the aa-* tools which gets fixed by
removing all the 'localinclude'-related code (what a big word for two
lines ;-)

References: https://bugs.launchpad.net/apparmor/+bug/1848227
2019-10-16 21:30:43 +02:00
Christian Boltz
ee7194a714
Allow /usr/etc/ in abstractions/authentication
openSUSE (and hopefully some other distributions) work on moving shipped
config files from /etc/ to /usr/etc/ so that /etc/ only contains files
written by the admin of each system.

See https://en.opensuse.org/openSUSE:Packaging_UsrEtc for details and
the first moved files.

Updating abstractions/authentication is the first step, and also fixes
bugzilla.opensuse.org/show_bug.cgi?id=1153162
2019-10-07 21:47:25 +02:00
Christian Boltz
5066dc6195 Merge branch 'profile-usr.sbin.winbindd' into 'master'
Update usr.sbin.winbindd profile

Winbind requires access to `/var/cache/samba/msg.lock/*`.

On Arch Linux Winbind's pid is set to `/run/winbindd.pid` ( https://git.archlinux.org/svntogit/packages.git/tree/trunk/winbindd.service?h=packages/samba ).

See merge request apparmor/apparmor!411

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-10-03 17:53:21 +00:00
Christian Boltz
a2d43e7546 Merge branch 'avoid-blhc-false-positive' into 'master'
Avoid blhc "CPPFLAGS missing" false positive.

See merge request apparmor/apparmor!403

Acked-by: John Johansen <john.johansen@canonical.com>
2019-09-30 21:53:50 +00:00
John Johansen
cb5aeec433 regression tests: add unconfined exception tests to nnp.sh
The unconfined exception needs to be applied even when a stack is
being used. When a stack is in use it prevents the unconfined
test from being used and instead it must be done as part of the
subset test.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-09-29 19:58:02 -04:00
Christian Boltz
dffed83161
abstractions/kerberosclient: allow reading /etc/krb5.conf.d/
Permit the use of /etc/krb5.conf.d configuration snippets

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>

Originally submitted as https://build.opensuse.org/request/show/733763
2019-09-28 17:25:39 +02:00