Commit graph

6316 commits

Author SHA1 Message Date
John Johansen
a6e7cea9ab Merge profiles: allow for the default dovecot libexecdir
Though many Linux distros choose to pass _/usr/lib_ as the libexecdir while configuring dovecot, such as [Debian](https://sources.debian.org/src/dovecot/1%3A2.3.20%2Bdfsg1-1/debian/rules/#L132) and [Arch](https://gitlab.archlinux.org/archlinux/packaging/packages/dovecot/-/blob/main/PKGBUILD#L76), others like Alpine Linux and Gentoo don't pass anything as libexecdir, allowing it to default to _/usr/libexec_.

Both appear to be valid. From [FHS 3.0, Chapter 4.7](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s07.html):
> Some previous versions of this document did not support _/usr/libexec_, despite it being standard practice in a number of environments. To accomodate this restriction, it became common practice to use _/usr/lib_ instead. Either practice is now acceptable, but each application must choose one way or the other to organize itself.

Allow for the default libexec subdir _/usr/libexec/dovecot_ as well as the more common
_/usr/lib/dovecot_.

Signed-off-by: Peter Levine <plevine457@gmail.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1080
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 941118c699)

37ffc6ea profiles: allow for the default dovecot libexecdir
2023-09-12 18:29:59 +00:00
John Johansen
990d50426d Merge Install systemd unit on fedora/redhat systems
... instead of trying the old rc.apparmor.redhat initscript, which we no
longer ship since 2019519e34.

Also remove a superfluous level of indirection (rhel4 -> redhat).

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/350

Closes #350
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1101
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 9ab72ffc7c)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-08-29 16:43:25 -07:00
John Johansen
75d1b3f2ee Merge [3.1] collapse_log(): Attach null-* events to correct target profile
ask_exec() and ask_addhat() set
hashlog[aamode][full_profile]['final_name'].

While this was used to get profile and hat split, it was not used as key
for log_dict. This resulted in entries like
log_dict['PERMITTING']['foo//null-/usr/bin/cat']
which are obviously wrong.

Use final_name as log_dict key so that we end up with (assuming child
exec was selected)
log_dict['PERMITTING']['foo///usr/bin/cat']

This fixes a regression introduced in 3.1.

This is the 3.1 version of https://gitlab.com/apparmor/apparmor/-/merge_requests/1091

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1092
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2023-08-24 01:16:45 +00:00
Christian Boltz
b41fb62cd4
collapse_log(): use final_name
Now that we have `final_name` as shortcut for
`hashlog[aamode][full_profile]['final_name']`, update the code that used
the long version to make it more readable.    collapse_log(): use final_name

Now that we have `final_name` as shortcut for
`hashlog[aamode][full_profile]['final_name']`, update the code that used
the long version to make it more readable.
2023-08-20 16:15:18 +02:00
Christian Boltz
8453735b63
collapse_log(): Attach null-* events to correct target profile
ask_exec() and ask_addhat() set
hashlog[aamode][full_profile]['final_name'].

While this was used to get profile and hat split, it was not used as key
for log_dict. This resulted in entries like
log_dict['PERMITTING']['foo//null-/usr/bin/cat']
which are obviously wrong.

Use final_name as log_dict key so that we end up with (assuming child
exec was selected)
log_dict['PERMITTING']['foo///usr/bin/cat']
2023-08-20 16:14:16 +02:00
Georgia Garcia
f180f515f0 Merge tests/regression/apparmor/capabilities.sh: fail iopl/ioperm with lockdown
In MR #1063 the tests/regression/apparmor/syscall.sh script was updated to
account for kernel lockdown, but the capabilities.sh script also exercises these
system calls so this also needs to be updated as well.

Also required to fix issue #226.

Signed-off-by: Alex Murray <alex.murray@canonical.com>

Closes #226
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1064
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit 3b832dd313)

eafae0dd tests/regression/apparmor/capabilities.sh: fail iopl/ioperm with lockdown
2023-07-10 13:10:40 +00:00
John Johansen
099fb8b6cb Merge tests/regression/apparmor/syscall.sh: fail iopl/ioperm with lockdown
When kernel lockdown is enabled the ioperm and iopl tests will fail regardless
since lockdown prevents these syscalls before AppArmor has a chance to mediate
them. So workaround this by detecting when lockdown is enabled and expect the
tests to fail in that case.

Fixes issue #226.

Signed-off-by: Alex Murray <alex.murray@canonical.com>

Closes #226
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1063
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 7393aaac21)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-07-03 23:55:31 -07:00
John Johansen
3ea11e4989 Merge abstractions/fonts: allow writing to fontconfig user cache files
Apologies for the second push; this change is made with the understanding that the abstraction is not intended to be solely read-only.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1059
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 5b7e637872)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-30 18:10:41 -07:00
John Johansen
d56cdfc624 Merge abstractions/fonts: allow locking fontconfig user cache files
Got this after allowing `rw` access to `~/.cache/fontconfig/**`:

`Jun 20 00:41:26 testvm kernel: [3280307.358614] audit: type=1400 audit(1687236086.210:127519): apparmor="DENIED" operation="file_lock" profile="firefox" name="/home/username/.cache/fontconfig/a41116dafaf8b233ac2c61cb73f2ea5f-le64.cache-7" pid=1758224 comm="firefox" requested_mask="k" denied_mask="k" fsuid=1002 ouid=1002`

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1057
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 162aa447d2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-30 10:52:37 -07:00
John Johansen
24f29f2e5b Merge abstactions/kde: allow reading global Debian KDE settings
New denials detected on Debian Sid:

```
type=AVC msg=audit(1687372581.246:738): apparmor="DENIED" operation="open" class="file" profile="qtox" name="/usr/share/desktop-base/kf5-settings/kdeglobals" pid=17988 comm="qtox" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0FSUID="vincas" OUID="root"
```

Debian package `desktop-base` contains some global KDE settings files:

```
$ dpkg -L desktop-base | fgrep kf5
/usr/share/desktop-base/kf5-settings
/usr/share/desktop-base/kf5-settings/baloofilerc
/usr/share/desktop-base/kf5-settings/kdeglobals
/usr/share/desktop-base/kf5-settings/kscreenlockerrc
```

Add file rules to allow reading global KDE settings.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1056
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 1ff74fed4b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-30 00:04:46 -07:00
John Johansen
f9e9954f12 Prepare for AppArmor 3.1.6 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-21 14:13:41 -07:00
John Johansen
3ec3fc47a1 Merge fix mount regression in 3.1.5
Mount has regressed in two ways. That are affecting snapd confinement, since landing the mount fixes for CVE-2016-1585 in 3.1.4 and the fix for the mount change type regression in 3.1.5

Bug Reports:

https://bugs.launchpad.net/apparmor/+bug/2023814

https://bugzilla.opensuse.org/show_bug.cgi?id=1211989

Issue 1:
Denial of Mount
```
[ 808.531909] audit: type=1400 audit(1686759578.010:158): apparmor="DENIED" operation="mount" class="mount" info="failed mntpnt match" error=-13 profile="snap-update-ns.test-snapd-lp-1803535" name="/tmp/.snap/etc/" pid=14529 comm="5" srcname="/etc/" flags="rw, rbind"
```

when the profile contains a rule that should match
```
mount options=(rw, rbind) "/etc/" -> "/tmp/.snap/etc/",
```

Issue 2: change_type failure.
Denial of Mount in log
```
type=AVC msg=audit(1686977968.399:763): apparmor="DENIED" operation="mount" class="mount" info="failed flags match" error=-13 profile="snap-update-ns.authy" name="/var/cache/fontconfig/" pid=26702 comm="5" srcname="/var/lib/snapd/hostfs/var/cache/fontconfig/" flags="rw, bind"
...
```

snapd error
```
- Run configure hook of "chromium" snap if present (run hook "configure": 
-----
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/doc /usr/share/doc none bind,ro 0 0): permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/fonts /usr/share/fonts none bind,ro 0 0): permission denied
update.go:85: cannot change mount namespace according to change mount (/var/snap/cups/common/run /var/cups none bind,rw 0 0): permission denied
cannot update snap namespace: cannot create writable mimic over "/snap/chromium/2475": permission denied
snap-update-ns failed with code 1
```

and NO mount rules in the profiles.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1054
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2023-06-21 02:54:53 +00:00
John Johansen
86d193e183 parser: fix rule flag generation change_mount type rules
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1048
made it so rules like

  mount slave /snap/bin/** -> /**,

  mount /snap/bin/** -> /**,

would get passed into change_mount_type rule generation when they
shouldn't have been. This would result in two different errors.

1. If kernel mount flags were present on the rule. The error would
   be caught causing an error to be returned, causing profile compilation
   to fail.

2. If the rule did not contain explicit flags then rule would generate
   change_mount_type permissions based on souly the mount point. And
   the implied set of flags. However this is incorrect as it should
   not generate change_mount permissions for this type of rule. Not
   only does it ignore the source/device type condition but it
   generates permissions that were never intended.

   When used in combination with a deny prefix this overly broad
   rule can result in almost all mount rules being denied, as the
   denial takes priority over the allow mount rules.

Fixes: https://bugs.launchpad.net/apparmor/+bug/2023814
Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1211989
Fixes: 9d3f8c6cc ("parser: fix parsing of source as mount point for propagation type flags")
Fixes: MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1048

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-20 09:02:06 -07:00
John Johansen
ca7f79174e parser: Deprecation warning should not have been backported
Outputing the deprecation warning is a change in behavior that is not
a bug fix.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-17 14:00:41 -07:00
John Johansen
515d93ab1a Merge abstractions/base: Add transparent hugepage support
Found in testing a slimmed-down `usr.sbin.sshd` profile:
```
Jun  8 21:09:38 testvm kernel: [   54.847014] audit: type=1400 audit(1686272978.009:68): apparmor="DENIED" operation="open" profile="/usr/sbin/sshd" name="/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" pid=1035 comm="sshd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
```
Not sure what glibc/system call uses this, but it seems pretty broadly applicable, and read access is presumably harmless. [THP reference](https://www.kernel.org/doc/html/latest/admin-guide/mm/transhuge.html)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1050
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit ad3750058d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-09 01:48:05 -07:00
John Johansen
ad6833bb34 Merge abstractions/authentication: Add GSSAPI mechanism modules config
Found in testing a slimmed-down `usr.sbin.sshd` profile:
```
Jun  8 21:09:37 testvm kernel: [   54.770501] audit: type=1400 audit(1686272977.933:67): apparmor="DENIED" operation="open" profile="/usr/sbin/sshd" name="/etc/gss/mech.d/" pid=1036 comm="sshd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
```
([Reference](https://web.mit.edu/kerberos/krb5-1.21/doc/admin/host_config.html#gssapi-mechanism-modules) for  GSSAPI mechanism modules)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1049
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit b41fcdce16)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-09 01:47:40 -07:00
John Johansen
3c5d40e84a Prepare for AppArmor 3.1.5 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-08 23:48:36 -07:00
John Johansen
eac7202808 Merge profiles: allow reading of /etc/ld-musl-*.path
/etc/ld-musl-*.path is required to perform dynamic linking on musl libc.
The wildcard is to match all CPU architectures, like x86_64.

type=AVC msg=audit(1686087677.497:67): apparmor="DENIED" operation="open" class="file" profile="syslog-ng" name="/etc/ld-musl-x86_64.path" pid=25866 comm="syslog-ng" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

Closes #333

Signed-off-by: Nikita Romaniuk <kelvium@yahoo.com>

Closes #333
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1047
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 6e0d776f65)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-08 19:00:38 -07:00
John Johansen
3b61d42f79 Merge parser: fix parsing of source as mount point for propagation type flags
Before 300889c3a, mount rules would compile policy when using source
as mount point for rules that contain propagation type flags, such as
unbindable, runbindable, private, rprivate, slave, rslave, shared, and
rshared. Even though it compiled, the rule generated would not work as
expected.

This commit fixes both issues. It allows the usage of source as mount
point for the specified flags, albeit with a deprecation warning, and
it correctly generates the mount rule.

The policy fails to load when both source and mount point are
specified, keeping the original behavior (reference
parser/tst/simple_tests/mount/bad_opt_10.sd for example).

Fixes: https://bugs.launchpad.net/bugs/1648245
Fixes: https://bugs.launchpad.net/bugs/2023025

It should be backported to versions 2.13, 3.0, 3.1.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1048
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 1e0d7bcbb7)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-06-08 18:54:04 -07:00
John Johansen
f34d60b1e8 Merge [3.0, 3.1] Fix invalid aa-status --json
The previous patch changed the final  }}  to  }  - which is correct in
master, but breaks the code in the 3.x branches.

I propose this patch for 3.0 and 3.1.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1046
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2023-06-06 21:42:28 +00:00
Christian Boltz
29b21b09d4
Fix invalid aa-status --json
The previous patch changed the final  }}  to  }  - which is correct in
master, but breaks the code in the 3.x branches.
2023-06-06 23:29:14 +02:00
Georgia Garcia
96395d9b82 Merge profiles: add lock file permission to snap browsers
When opening snap browsers with evince using the snap_browsers
abstraction, we get the following AppArmor denials which prevent the
browsers from opening

audit: type=1400 audit(1685996894.479:225): apparmor="DENIED" operation="open" class="file" profile="/usr/bin/evince//snap_browsers" name="/var/lib/snapd/inhibit/firefox.lock" pid=13282 comm="snap" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

audit: type=1400 audit(1685997517.142:259): apparmor="DENIED" operation="file_lock" class="file" profile="/usr/bin/evince//snap_browsers" name="/var/lib/snapd/inhibit/firefox.lock" pid=14200 comm="snap" requested_mask="k" denied_mask="k" fsuid=1000 ouid=0

This MR should be cherry-picked into 2.13, 3.0, 3.1

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1045
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit a00ece5b6e)

daec4bc8 profiles: add lock file permission to snap browsers
2023-06-06 11:15:48 +00:00
John Johansen
9980ae76d8 Merge Fix use-after-free of 'name' in parser_regex.c
'name' gets used in the error message. Make sure it only gets freed
afterwards.

This bug was introduced in be0d2fa947 /
https://gitlab.com/apparmor/apparmor/-/merge_requests/727

Fixes coverity CID 254465:  Memory - illegal accesses  (USE_AFTER_FREE)

I propose this fix for 3.0..master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1040
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 8d6358fa6d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-29 15:38:58 -07:00
John Johansen
dd136f4dd9 Merge Fix order of if conditions to avoid unreachable code
If `else if (preprocess_only)` is true, the more strict condition
`else if (!include_file && preprocess_only)` won't be reached if it gets
checked after the shorter condition.

Exchange the two sections so that both code paths can be reached.

Fixes coverity CID 312499:  Control flow issues  (DEADCODE)

This was probably introduced in 7dcf013bca / https://gitlab.com/apparmor/apparmor/-/merge_requests/743 which means we'll need to backport this fix to 3.0 and 3.1.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1039
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit dc8cbebdef)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-29 15:30:26 -07:00
John Johansen
e5a3c03357 Prepare for AppArmor 3.1.4 release
- update version file
- update library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-23 17:10:26 -07:00
John Johansen
6831a8f440 Merge extend test profiles for mount
- in bad_?.sd, explain why the profile is bad (conflicting options)
- add a good profile with two space-separated options

This is a follow-up for https://gitlab.com/apparmor/apparmor/-/merge_requests/1029

If we backport !1029, we should also backport these test changes.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1035
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit d700f87d3e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-23 14:41:58 -07:00
John Johansen
ea5b52d3b2 Merge aa-status: Fix malformed json output
In some cases (if profiles in complain _and_ enforce mode are loaded), the `i` loop runs more
than once, which also means `j == 0` is true in the middle of the json.
This causes invalid json.

This patch fixes this.

This is a regression related to 22aa9b6161
/ https://gitlab.com/apparmor/apparmor/-/merge_requests/964 /
https://gitlab.com/apparmor/apparmor/-/issues/295
which fixed another case of invalid json if a process was unconfined
while having a profile defined.

Note: I also tested this patch for the "unconfined, but has a profile
defined" case to ensure it doesn't break what
22aa9b6161 fixed.

This fix is needed in all branches that also got !964 (which means 3.1 and 3.0).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1036
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/295
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
backported-from: 88d2bf45a Merge aa-status: Fix malformed json output
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-19 16:31:41 -07:00
Christian Boltz
3cdeb140a1 Merge nscd: add permission to allow supporting unscd
`unscd` is a drop-in replacement for `nscd` that uses the same binary location (`/usr/sbin/nscd`) and config file (`/etc/nscd.conf`). The `usr.sbin.nscd` profile only needs one additional permission to support it.

```
May 9 18:07:42 darkstar kernel: [ 2706.138823] audit: type=1400
audit(1683670062.580:839): apparmor="DENIED" operation="sendmsg"
profile="nscd" name="/run/systemd/notify" pid=4343 comm="nscd"
requested_mask="w" denied_mask="w" fsuid=125 ouid=0
```

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1031
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit dec3815f07)

bd0d401b nscd: add permission to allow supporting unscd
2023-05-10 10:54:34 +00:00
Jon Tourville
8c49449e46 Merge Merge Issue 312: added missing kernel mount options
This patch adds the following mount options: 'nostrictatime',
'lazytime', and 'nolazytime'.

The MS_STRICTATIME mount flag already existed, and 'nostrictatime' was
listed along with 'strictatime' in the comments of parser/mount.cc, so
this patch adds a mapping for 'nostrictatime' to clear MS_STRICTATIME.

Additionally, the Linux kernel includes the 'lazytime' option with
MS_LAZYTIME mapping to (1<<25), so this patch adds MS_LAZYTIME to
parser/mount.h and the corresponding mappings in parser/mount.cc for
'lazytime' and 'nolazytime'.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1005
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit c37be61d17)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1026
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-04 12:00:20 +00:00
Christian Boltz
a3685436eb Merge [3.1] CI: check extra profiles for local/ includes
Picked from MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1012
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 46c8dbe886)

3ddb1677 CI: check extra profiles for local/ includes

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1027
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2023-05-04 10:33:57 +00:00
John Johansen
2610fe4e80 Merge CI: check extra profiles for local/ includes
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1012
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 46c8dbe886)

3ddb1677 CI: check extra profiles for local/ includes
2023-05-03 18:15:19 +00:00
John Johansen
c7f761b710 Merge Issue 312: added missing kernel mount options
This patch adds the following mount options: 'nostrictatime',
'lazytime', and 'nolazytime'.

The MS_STRICTATIME mount flag already existed, and 'nostrictatime' was
listed along with 'strictatime' in the comments of parser/mount.cc, so
this patch adds a mapping for 'nostrictatime' to clear MS_STRICTATIME.

Additionally, the Linux kernel includes the 'lazytime' option with
MS_LAZYTIME mapping to (1<<25), so this patch adds MS_LAZYTIME to
parser/mount.h and the corresponding mappings in parser/mount.cc for
'lazytime' and 'nolazytime'.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1005
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit c37be61d17)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-03 17:00:15 +02:00
Jon Tourville
f00f296201 Merge Merge expand mount tests
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1006
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit e6e5e7981f)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1022
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-03 14:54:32 +00:00
Jon Tourville
83772acf00 Check for newer mount options in regression test
The mount options MS_LAZYTIME and MS_NOSYMFOLLOW were added in
kernels 4.0 and 5.10, respectively. Update the mount test script
and helper to skip testing those options if they are not available.

Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
(cherry picked from commit 9a760def8d)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-03 13:48:02 +02:00
John Johansen
1d35eedef8 Merge Support rule qualifiers in regression tests
This allows regression tests to generate profiles that use rule qualifiers,
such as allow, deny, and audit. Qualifiers can be specified for a rule by
prepending 'qual=', followed by a comma-separated list of rule qualifiers,
then a ':', then the rule itself.

Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
(cherry picked from commit f6bfd141bd)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1018
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2023-05-02 12:00:13 +00:00
John Johansen
a597a612a7 Merge expand mount tests
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1006
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit e6e5e7981f)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-02 11:01:12 +02:00
Jon Tourville
64463c8686 Support rule qualifiers in regression tests
This allows regression tests to generate profiles that use rule qualifiers,
such as allow, deny, and audit. Qualifiers can be specified for a rule by
prepending 'qual=', followed by a comma-separated list of rule qualifiers,
then a ':', then the rule itself.

Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
(cherry picked from commit f6bfd141bd)
Signed-off-by: Jon Tourville <jon.tourville@canonical.com>
2023-05-02 10:12:23 +02:00
John Johansen
7bd1c4d8ef Merge fix af_unix tests for v8 networking.
The unix network tests are not being run on a v8 network capable kernel. Under v8 there needs to be some adjustments to the tests because unix rules get downgraded to the socket rule ```network unix,``` which does not have the same set of conditionals or fine grained permissions, meaning some tests that would fail under af_unix (like missing permission tests) will pass under v8 network rules.

Signed-off-by: John Johansen <john.johansen@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/893
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 59b4109a8b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-05-01 05:17:20 -07:00
John Johansen
c7bd872071 Merge abstractions/freedesktop.org: allow custom cursors
... by allowing to read all files below ~/.icons instead of only the
directory listing.

I propose this patch for all branches.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1008
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit fa86a7f1d9)

954b11fc abstractions/freedesktop.org: allow custom cursors
2023-04-25 19:44:27 +00:00
John Johansen
3d33fd440b Merge Fix error when choosing named exec with plane profile names
When a user choooses to execute to a named profile (not: named child),
make sure to get the profile filename in the correct way to avoid a crash.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/314

I propose this patch for 2.13..master. (Note: I verified that the bug already exists in 2.13, and that this patch fixes it.)

Closes #314
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1013
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 30dd1cec42)

103be8e1 Fix error when choosing named exec with plane profile names
2023-04-25 19:42:26 +00:00
Christian Boltz
e37cbd43c9 Merge Sync apparmor-3.1 profiles with master
This MR is similar to !1009, only it targets the `apparmor-3.1` branch.

There are also three commits here, but the first one only updates comments, and the last one is much smaller. After merging, `git diff apparmor-3.1 master -- profiles` will likewise produce no output.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1010
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2023-04-19 20:21:58 +00:00
Daniel Richard G
f91f33f2c6 profiles: sync with master
(Don't remove rules from the usr.sbin.{dnsmasq,nmbd,winbindd} profiles,
however, as these have been transferred to abstractions which might not
be correctly updated on a user system)
2023-04-18 20:24:32 -04:00
Daniel Richard G
51751aa687 profiles/Makefile: sync with master 2023-04-12 20:48:57 -04:00
Daniel Richard G
89f1a84dfe profiles: partial sync with master
This commit only updates comments.
2023-04-12 20:48:57 -04:00
Christian Boltz
d984b3edb6 Merge abstractions/base: allow reading tzdata ICU zoneinfo DB
This is used by various applications including libreoffice etc so it may as well
be added to the base abstraction along with the existing zoneinfo DB access.

AVC apparmor="DENIED" operation="open" class="file" profile="snap.libreoffice.calc" name="/usr/share/zoneinfo-icu/44/le/zoneinfo64.res" pid=44742 comm="soffice.bin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

Signed-off-by: Alex Murray <alex.murray@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1007
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 8d9985ac0b)

c691b11d abstractions/base: allow reading tzdata ICU zoneinfo DB
2023-04-11 19:21:29 +00:00
John Johansen
2a7ddbc773 Merge Ignore 'x' in mixed file mode log events
Probably thanks to O_MAYEXEC, denials for file access can now contain a
mix of x (exec) and other file permissions.

The actual exec should appear in a separate "exec" log event, therefore
ignore 'x' in file events for now if it's mixed with other permissions.

Note that file events ("open", "link" etc.) that contain denied_mask="x"
without another permission will still cause an error. (So far, this
hasn't been seen in the wild.)

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/303

Also add the log line from the bugreport and the (for now) expected
result as test_multi testcase.

I propose this patch for all branches.

Closes #303
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1001
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit cf6539b217)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 20:14:17 -07:00
John Johansen
54bb7dccf0 Merge syslogd: allow reading /dev/kmsg
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/307

I propose this patch for master and 3.x (the profile in 2.13 is very different which makes automatic merging impossible)

Closes #307
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1003
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 6f65faa164)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 20:08:12 -07:00
John Johansen
aff29ef0ee Merge Fix mount rules encoding
This is a partial fix for CVE-2016-1585, it address the frontend rule encoding problems particularly
- Permissions being given that shouldn't happen
- Multiple option conditionals in a single rule resulting in wider permission instead of multiple rules
- optional flags not being handled correctly
- multiple backend rules being created out of one frontend rule when they shouldn't be

it does not address the backend issue of short cut permissions not being correctly updated when deny rules carve out permissions on an allow rule that has a short cut permission in the encoding.

Thanks to the additional work by Alexander Mikhalitsyn for beating this MR into shape so we can land it

Alexander Changelog:
- rebased to an actual tree
- addressed review comments from @wbumiller and @setharnold
- fixed compiler warnings about class_mount_hdr is uninitialized
- infinite loop fix
- MS_MAKE_CMDS bitmask value fixed
- fixed condition in `gen_flag_rules` to cover cases like `mount options in (bind) /d -> /4,` when flags are empty and only opt_flags are present
- marked some tests as a FAIL case behavior was changed after `parser: add conflicting flags check for options= conditionals` commit

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/333
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit c1a1a3a923)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-29 10:41:47 -07:00
John Johansen
26e85c17bd Merge parser: fix definitely and possibly lost memory leaks
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/992
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 05595eccda)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-28 20:21:09 -07:00
Georgia Garcia
bdcd76a8ea Merge tests: force dbus-daemon to generate an abstract socket
dbus 1.14.4 changed the behavior of unix:tmpdir to be equivalent to
unix:dir, which cases dbus-daemon to generate path based sockets,
instead of the previous abstract sockets. [1]
In this change we force dbus-daemon to generate an abstract socket by
specifying the abstract socket address in the command.

[1] https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-1.14/NEWS#L64

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/999
Approved-by: John Johansen <john@jjmx.net>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit 904b733948)

53d4e341 tests: force dbus-daemon to generate an abstract socket
2023-03-28 14:23:13 +00:00