Commit graph

4921 commits

Author SHA1 Message Date
Steve Beattie
a090a6377b socketpair regression test: add aa_getpeercon() enabled perm
Because of the need to be stacking LSM aware, aa_getpeercon() calls
aa_enable to ensure that apparmor is enabled. Without the permission,
aa_getpeercon() fails, causing test failures.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit fb773fec36)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-13 05:15:57 -07:00
John Johansen
4527abd028 regression tests: fix aa_policy_cache to use correct config file
The aa_policy_cache test is using the system parser.conf file even
when the tests are set to use source. This can lead to failures
if the system parser.conf contain options not understood by
the source parser.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/653
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 1033e19171)
2020-10-13 05:07:28 -07:00
John Johansen
350b4a5358 regression test: Fix regression tests when using in tree parser
When using the in tree parser we should not be using the system
parser.conf file, as if the system apparmor is newer than the
tree being tested the parser.conf file could contain options not
understood by the in tree apparmor_parser.

Use --config-file to specify the default in tree parser.conf

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/653
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 5ac368bce7)
2020-10-13 05:07:23 -07:00
Steve Beattie
3f8cfac384 parser/Makefile: fix generated cap comparison against known list
The sed command to manipulate the known cap list (base_cap_names.h) into
a format to match the generated_cap_names.h was buggy because the
trailing '}' would never match anything, leading to failures when built
against 5.8 kernel headers, due to it not replacing the base capabilities
correctly.

Fix this by removing the trailing '}" match and instead match the third
comma-delimited field that matches a capability name, and replace that.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/596
(cherry picked from commit a7fc8bb500)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-13 03:00:53 -07:00
John Johansen
054079b271 parser: call filter slashes for mount conditionals
The mnt_point and devices conditionals in mount rules are generally
paths and should have slashes filtered after variable expansion.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit a1978fb1b2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:44:50 -07:00
John Johansen
f6eb8553dc parser: call filter slashes for the dbus path conditional
Similar to unix addr rules, the dbus path conditional is more a path
than a profile name and should get its slashes filtered after variable
expansion.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 35f6d49ec6)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:44:50 -07:00
John Johansen
8b5e4a45a9 parser: enable variable expansion for mount type= and options=
Currently mount options type= and options= do not expand variables
but they should. Fix it.

Note: this does not treat either as paths because their use is
too device dependent for it to be safe to filter slashes.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/99
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/638
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 882380ad3d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:44:50 -07:00
Patrick Steinhardt
8771cff94b libapparmor: add missing include for socklen_t
While `include/sys/apparmor.h` makes use of `socklen_t`, it doesn't
include the `<sys/socket.h>` header to make its declaration available.
While this works on systems using glibc via transitive includes, it
breaks compilation on musl libc.

Fix the issue by including the header.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit 47263a3a74)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-03 13:21:32 -07:00
Patrick Steinhardt
351014c3f6 libapparmor: add _aa_asprintf to private symbols
While `_aa_asprintf` is supposed to be of private visibility, it's used
by apparmor_parser and thus required to be visible when linking. This
commit thus adds it to the list of private symbols to make it available
for linking in apparmor_parser.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/643
Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit 9a8fee6bf1)
2020-10-03 12:24:40 -07:00
John Johansen
903e743b87 parser: Fix expansion of variables in unix rules addr= conditional
The parser is not treating unix addr as a path and filtering slashes
after variable expansion. This can lead to errors where

@{foo}=/a/
unix bind addr=@{foo}/bar,

will always fail because addr is being matched as /a//bar instead of
/a/bar.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Fixes: https://bugs.launchpad.net/apparmor/+bug/1856738
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 6af05006d9)
2020-09-29 12:00:40 -07:00
John Johansen
7a7c7fb346 regression tests: Don't build syscall_sysctl if missing kernel headers
sys/sysctl.h is not guaranteed to exist anymore since
https://sourceware.org/pipermail/glibc-cvs/2020q2/069366.html

which is a follow on to the kernel commit
61a47c1ad3a4 sysctl: Remove the sysctl system call

While the syscall_sysctl currently checks if the kernel supports
sysctrs before running the tests. The tests can't even build if the
kernel headers don't have the sysctl defines.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/119
Fixes: https://bugs.launchpad.net/apparmor/+bug/1897288
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/637
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 2e5a266eb7)
2020-09-29 11:55:36 -07:00
John Johansen
58e4e8169c parser: Fix automatic adding of rule for change_hat interface
The parser is supposed to add a rule to profiles if they are a hat
or contain hats granting write access to the kernel interfaces
used to perform the change_hat operation.

Unfortunately the check is broken and currently won't add the
rule to hats (it does add it for the parent).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/625
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 5b850c154f)
2020-09-17 15:04:24 -07:00
John Johansen
4cab2dbc17 Merge [2.13] Refresh postfix profiles
Refresh the postfix profiles in the 2.13 branch with (mostly) all changes in master.

The most important changes are:

* support having the `postfix/*` binaries in `/usr/lib/postfix/bin/` (like for example openSUSE has now)
* add profile names
* rename the profile files to `postfix-*`
* several "smaller" changes (especially added permissions), see the individual commits for all details

Note that some changes were not backported to the 2.13 branch:

* adding abi rules
* changing `#include` to `include`
* removal of "superfluous" rules covered by abstractions (dd4903efc6)
* removal of `peer=/usr/lib/postfix/...` rules

20/20 Revert renaming usr.lib.postfix.* to postfix.* in 2.13 branch
19/20 postfix-master: allow access to postlog socket
18/20 Allow to read icu *.dat files in postfix-related profiles
17/20 postfix/master needs to execute postfix/error
16/20 Add several permissions to the postfix.* profiles
15/20 adjust postfix profiles for openSUSE path
14/20 profiles/postfix-smtpd: Include ssl_certs, ssl_keys
13/20 profiles/postdrop: Allow reading from pickup socket
12/20 profiles/postfix-pickup: Allow reading from cleanup socket
11/20 postfix.local: Minor adjustments to make it work
10/20 postfix.*: Adapt for new queue names, and extra locking and r/w communication
9/20 postfix.tlsmgr: Connect to urandom and prng exchange
8/20 postfix.master: Change path of child processes
7/20 profiles/postfix: add locking perm to pid files
6/20 profiles: add a postfix dnsblog profile
5/20 profiles: add a postfix postscreen profile
4/20 profiles/postfix-master: grant signal+unix communication with children
3/20 profiles/postfix: use named profiles
2/20 profiles/postfix-master: use profile name instead of match pattern
1/20 allow locking /etc/aliases.db

Note: Backport Exception Requested by OpenSuse, updated profiles needed, on a 2.13 release
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/621
Acked-by: John Johansen <john.johansen@canonical.com>
2020-09-09 20:14:01 +00:00
Christian Boltz
8501ed822e
Revert renaming usr.lib.postfix.* to postfix.* in 2.13 branch
... as discussed/proposed in !621

This means the postfix.* filenames stay master-only.
2020-09-09 21:30:22 +02:00
Christian Boltz
e54fdf8e2b
postfix-master: allow access to postlog socket
(cherry picked from commit d55ca8b624)
2020-09-09 21:28:20 +02:00
Christian Boltz
57f6315783
Allow to read icu *.dat files in postfix-related profiles
This is needed for postdrop, postmap, postqueue and sendmail

Seen on openSUSE Tumbleweed.

(cherry picked from commit b23aa00b81)
2020-09-08 21:23:18 +02:00
Christian Boltz
6fae03d142
postfix/master needs to execute postfix/error
(cherry picked from commit f250e94240)
2020-09-08 21:22:51 +02:00
Christian Boltz
bd401448fa
Add several permissions to the postfix.* profiles
... needed on openSUSE Leap 15.1

(cherry picked from commit 7016ac954b)
2020-09-08 21:22:37 +02:00
Christian Boltz
6e2de0806c
adjust postfix profiles for openSUSE path
On openSUSE Leap 15.1, the postfix binaries live in
/usr/lib/postfix/bin/ which was not covered in the postfix.* attachment
and mrix rules.

(cherry picked from commit f668f31bf0)
2020-09-08 21:20:56 +02:00
Julian Andres Klode
583fb1c0cd
profiles/postfix-smtpd: Include ssl_certs, ssl_keys
This is needed for serving TLS.

(cherry picked from commit 4c85a7ec9e)
2020-09-08 21:18:28 +02:00
Julian Andres Klode
54806dce22
profiles/postdrop: Allow reading from pickup socket
(cherry picked from commit b858428dd1)
2020-09-08 21:18:16 +02:00
Julian Andres Klode
25338e4691
profiles/postfix-pickup: Allow reading from cleanup socket
(cherry picked from commit d1ab0a021e)
2020-09-08 21:18:04 +02:00
Julian Andres Klode
9051288c3d
postfix.local: Minor adjustments to make it work
This connects queue manager to local.

(cherry picked from commit 60d203b622)
2020-09-08 21:17:52 +02:00
Julian Andres Klode
0107d57915
postfix.*: Adapt for new queue names, and extra locking and r/w communication
This gets us to the local process now, which comes next.

(cherry picked from commit 02528133d2)

Note: this cherry-pick doesn't include the removal of the path-based
signal and unix rules in postfix-master.
2020-09-08 21:16:46 +02:00
Julian Andres Klode
1909ca0dcb
postfix.tlsmgr: Connect to urandom and prng exchange
(cherry picked from commit e8841a0953)
2020-09-08 21:12:23 +02:00
Julian Andres Klode
d6ebf87d2b
postfix.master: Change path of child processes
(cherry picked from commit f4bfd78164)
2020-09-08 21:11:39 +02:00
Steve Beattie
43af5f9751
profiles/postfix: add locking perm to pid files
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 9943da2f52)
2020-09-08 21:11:06 +02:00
Steve Beattie
065546c312
profiles: add a postfix dnsblog profile
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 889503f623)
2020-09-08 21:08:19 +02:00
Steve Beattie
2060ccde22
profiles: add a postfix postscreen profile
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 1c9459825a)
2020-09-08 21:08:03 +02:00
Steve Beattie
df9cfced8c
profiles/postfix-master: grant signal+unix communication with children
Grant the ability to communicate with the postfix named child profiles
via signals and unix sockets. Include the path-based match names as
a fallback on upgrades.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 35d84895fe)
2020-09-08 21:07:42 +02:00
Steve Beattie
9a9c2f9793
profiles/postfix: use named profiles
Convert all the postfix subprocesses to using named profiles instead of
path match profiles, and adjust exec paths for newer debian/ubuntu
releses. Rename profiles to match profile names.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 39ca2adff6)
2020-09-08 21:07:29 +02:00
Steve Beattie
8b0e2bdc94
profiles/postfix-master: use profile name instead of match pattern
Convert postfix's master profile to use a named profile
(postfix-master) rather than the exec path match pattern. Adjust
postfix-common abstraction to take this into account. Rename profile
name in the profiles/apparmor/profiles/extras/ directory to match
the profile name.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 01648c6a61)
2020-09-08 21:02:35 +02:00
Christian Boltz
68316d265b
allow locking /etc/aliases.db
This is needed for "newaliases" on current openSUSE Tumbleweed / postfix 3.3.1

(cherry picked from commit f74edd5d5a)
2020-09-08 20:59:06 +02:00
Christian Boltz
e32cbfc0e6 Merge branch 'cboltz-2.13-dnsmasq' into 'apparmor-2.13'
[2.12+2.13] dnsmasq: Backport support for /usr/libexec/libvirt_leaseshelper path

References: https://build.opensuse.org/request/show/831960

See merge request apparmor/apparmor!618

Acked-by: John Johansen <john.johansen@canonical.com> for 2.12 and 2.13
2020-09-06 18:06:33 +00:00
Vladimir “Equidamoid” Shapranov @equidamoid
f2e09aa234
policy: invalid path to libvirt_leaseshelper in usr.sbin.dnsmasq
Another instance of using libvirt_leaseshelper without having
libexec access. As addressed in the previous patch.

issue: https://gitlab.com/apparmor/apparmor/-/issues/87
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit e731b8a335)
2020-09-06 12:24:29 +02:00
Vladimir “Equidamoid” Shapranov @equidamoid
af6bf82389
Invalid path to libvirt_leaseshelper in usr.sbin.dnsmasq
The error:

type=AVC msg=audit(1585403559.846:34317577): apparmor="DENIED" operation="exec" profile="/usr/sbin/dnsmasq" name="/usr/libexec/libvirt_leaseshelper" pid=7162 comm="sh" requested_mas
k="x" denied_mask="x" fsuid=0 ouid=0
type=AVC msg=audit(1585403559.846:34317578): apparmor="DENIED" operation="open" profile="/usr/sbin/dnsmasq" name="/usr/libexec/libvirt_leaseshelper" pid=7162 comm="sh" requested_mas
k="r" denied_mask="r" fsuid=0 ouid=0

Looks like the path to libvirt_leasehelper is incorrect usr.sbin.dnsmasq, at least in gentoo. Patching the file fixes the problem:

issue: https://gitlab.com/apparmor/apparmor/-/issues/87
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 28fce5f76d)
2020-09-06 12:23:59 +02:00
Christian Boltz
02dce59d29 postfix-common: allow reading icu *.dat
several postfix-* binaries on openSUSE Tumbleweed need to read
/usr/share/icu/[0-9]*.[0-9]*/*.dat.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/615
(cherry picked from commit 39ef7c508f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-09-05 02:45:21 -07:00
Vincas Dargis
dab520aae9 nvidia_modprobe: allow creating /dev/nvidia-modeset
On Debian Sid we get this denial:

```
type=AVC msg=audit(1599065006.981:527): apparmor="DENIED"
operation="mknod" profile="nvidia_modprobe" name="/dev/nvidia-modeset"
pid=12969 comm="nvidia-modprobe" requested_mask="c" denied_mask="c"
fsuid=0 ouid=0
```

Update nvidia_modprobe profile to allow creating device file.

(cherry picked from commit e6dbe3bfd3)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-09-03 11:04:15 -07:00
John Johansen
70d3183a23 Merge [2.13] add abstractions/hosts_access
This is a partial backport of eb8f9302aa (only adding the abstraction) to the 2.13 branch.

Note that the 2.13 version of the abstraction doesn't have

* the abi rule
* the `include if exists <abstractions/hosts_access.d>`

because both are new in master and would cause interesting\[tm\] problems with the 2.13 tools.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/612
Acked-by: John Johansen <john.johansen@canonical.com>
2020-09-02 20:48:32 +00:00
Christian Boltz
64dfc797dd
add abstractions/hosts_access
This is a partial backport of eb8f9302aa
(only adding the abstraction) to the 2.13 branch.

Note that the 2.13 version of the abstraction doesn't have
- the abi rule
- the `include if exists <abstractions/hosts_access.d>`
because both are new in master and would cause interesting[tm] problems
with the 2.13 tools.
2020-09-02 22:36:39 +02:00
Steve Beattie
ad45b80789 parser: add CAP_BPF/PERFMON; convert to pregenerated cap list
Add support for CAP BPF and PERFMON

Backport from !578 the subset of patches that convert the parser to a pregenerated list of capability names instead of a dynamically generated list.

The dynamically generated list is still created and compared to the pregenerated list and the build will fail if new capabilities are added to the dynamically generated list that are not in the pregenerated list.

This enables the parser to support new capabilities like CAP BPF and PERFMON that are might not be in the kernel that the parser is being built against.

This patch series adds support CAP BPF and PERFMON in the pregenerated list of capabilities

See merge request apparmor/apparmor!594
2020-09-01 04:40:02 +00:00
Christian Boltz
aca6adea2a Merge branch 'patch-1' into 'master'
Fix /usr/lib/postfix binary paths in postfix+dovecot profiles

See merge request apparmor/apparmor!602

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.12..master

(cherry picked from commit 6cf58457d7)

c4f90ec1 Fix smtpd path in sendmail profile
9fbe599c Fix /usr/lib/postfix binary paths in postfix+dovecot profiles
2020-08-30 18:57:22 +00:00
Christian Boltz
2a3752c4c4 Merge branch 'update-nvidia-modprobe' into 'master'
nvidia_modprobe: allow reading driver parameters

See merge request apparmor/apparmor!603

Acked-by: Christian Boltz <apparmor@cboltz.de> for master and 2.13

(cherry picked from commit 112e2bc9fb)

a98a4f73 nvidia_modprobe: allow reading driver parameters
2020-08-30 18:49:54 +00:00
Steve Beattie
a07de3f095 regression tests/prologue: adjust sed to not use ~ as regex separators
prologue.inc:settest() in same cases invokes a sed command that uses
'~' as a pattern separator, on things that can contain filesystem
paths. However, in the debian/ubuntu world, '~' can be used in version
strings, particularly for pre-release versions, and when this happens
and the version is embedded in the path, the sed command breaks
because of the extraneous separator. Fix this by using '#' as a
separator, which has the benefit of being considered a comment if
accidentally interpreted by a shell.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/599
(cherry picked from commit efc6590409)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-08-28 02:05:28 -07:00
John Johansen
60007d3fe4 parser: Add warning to capability_table about the need to update the Makefile
The autogenerated capabilities comparison needs to be updated if the
capability_table structure changes. Add a note by the structure to
make sure the Makefile will get updated if the structure is changed.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/597
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
(backported from commit 139fac6062)
2020-08-27 01:26:11 -07:00
John Johansen
ef8d514138 parser/Makefile: use LC_ALL=C when invoking sed
Acked-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/596
(backported from commit 33ff79a9e5)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-08-26 23:55:46 -07:00
John Johansen
4e194b2f3a parser: unify capability name handling
There are currently two capability name tables the one that is
autogenerated and an internal hardcoded name table.

Now that the autogenerated table has been converted to a base
static table we can drop the internal static table. This
removes the chance of getting the tables getting out of sync.

Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit fb9c5f9bcf)
2020-08-24 02:28:25 -07:00
John Johansen
ed61e482cb parser: cleanup capability_table generation by dropping cap sys_log
The static cap sys_log declaration is no longer needed as
base_cap_names.h contains it and ensures that it will always be
present.

Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit fdba3a571c)
2020-08-24 02:28:13 -07:00
John Johansen
efb6952e0c parser: Move to a pre-generated cap_names.h
The auto-generated cap_names.h has problems when the parser if the
parser is built against a kernel with a smaller capability list than
the kernel policy is being compiled for.

Moving to a pre-generated list lets us support all capabilities even
when we build against older kernels. However we don't want to only use
the pre-generated list as that would make it too easy to miss when a
new capability has been added.

Keep auto generating the caps list and compare it to the pre-generated
caps list so we can detect when new capabilities are added, and fail
the build so that the pre-generated list can be updated. We screen the
diff for only additions so that the parser can continue to build on
older kernels that don't have the full capability list without errors.

Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 270fb0a2b2)
2020-08-24 02:07:25 -07:00
Jonas Witschel
aecc9e1cb6
abstractions/gnome: allow /usr/share/gtk-3.0/settings.ini
GTK+ 3 has a global settings file that should be readable as well.

(cherry picked from commit af6fe026e1)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/592
2020-08-20 14:01:02 -07:00