2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 18:17:09 +00:00

8146 Commits

Author SHA1 Message Date
Ryan Lee
d9028aea4e profiles: give lsof CAP_DAC_READ_SEARCH and CAP_DAC_OVERRIDE
This is necessary for lsof run as root to be able to return results from
processes run by other users.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-02 15:00:23 -07:00
Ryan Lee
e278575799 profiles: give lsof access to its own binary for confined execution contexts
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-02 12:58:08 -07:00
Ryan Lee
70f2bfe306 profiles: switch lsof profile to abstractions/nameservice for DNS lookups
lsof will attempt (reverse?) DNS queries to resolve IP addresses in open
sockets to domain names, so the full nameservice abstraction is needed.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-02 12:58:07 -07:00
Nicolas Campuzano Jimenez
a65924c28a cleaner way to keep files open for lsof 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
5d8baf08b7 change recursive root read rule to only dirs, no files; uncomment file specific rules 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
c9cd3606b0 Updated profile + tests 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
5dba8b05b5 add '/ r,' rule 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
e69781ac73 add mqueue getattr rule; remove owner from /proc/PID/net; attach paths to aa_disconnected 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
d6e23dc80a add rule 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
b3cccb7c85 Remove libvirt-qemu abstraction; remove /dev/mqueue r, rule: 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
a8319dcf0c address reviews; further testing -> read mqueues + sys_ptrace 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
41a90d4177 address review; hopefully trigger CI run? 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
b50eb2d18e more granularity for process's child threads 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
115ff87df7 Address MR reviews; remove comments 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
05ec9ee0f4 Initial lsof profile (+ comments) 2025-05-02 12:57:18 -07:00
Allen Huang
0e28172ca6
Exclude hidden locations in home directories
Signed-off-by: Allen Huang <allen.huang@canonical.com>
2025-05-02 14:16:53 +01:00
Nadzeya H
88c81906de
profiles: add a profile for hwctl 2025-05-02 12:28:22 +02:00
Allen Huang
ca8619313a
Limit access to common formats, allow more paths
- common file formats that qpdf works with: .pdf, .json and .qdf
- .in and .out are also allowed in user's home directories as they
  are sometimes used
- other paths are added, including mounts and system locations

Signed-off-by: Allen Huang <allen.huang@canonical.com>
2025-05-02 10:53:20 +01:00
Ryan Lee
b698daaf62 regression: add an allow_all test that checks pix+ix transitions
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-01 11:26:43 -07:00
Allen Huang
d7ffb13e4e
Add profile for qpdf
Signed-off-by: Allen Huang <allen.huang@canonical.com>
2025-05-01 09:49:49 +01:00
John Johansen
9b43c479a8 Merge parser: Dump more partition debug information
We need to be able to dump the initial partition assignments, and then
the partitions after minimization but before remapping to be able to
check on what is being done by minimization.

Add these as part of -D dfa-minimize-partitions                                 

Ideally we would rework the code so that the existing mininimization
dump could share the dump routine but, its interwined with computation
state and information is thrown away before reaching the end.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1651
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-30 10:09:25 +00:00
John Johansen
0d9e8312b8 Merge aa-status: improve failure messages
Improve the failure messages around getting policy information to
be less ambiguous about what went wrong.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1653
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-30 08:22:48 +00:00
John Johansen
fcd814bc51 parser: Dump more partition debug information
We need to be able to dump the initial partition assignments, and then
the partitions after minimization but before remapping to be able to
check on what is being done by minimization.

Add these as part of -D dfa-minimize-partitions

Ideally we would rework the code so that the existing mininimization
dump could share the dump routine but, its interwined with computation
state and information is thrown away before reaching the end.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-30 01:19:13 -07:00
John Johansen
26cd35b8b7 Merge regression: pass through args like -r to the overlayfs_common.inc helper
Without this, arguments like -r would not work.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1659
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-30 08:05:21 +00:00
Ryan Lee
2518f525de regression: pass through args like -r to the overlayfs_common.inc helper
Without this, arguments like -r would not work.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-29 12:57:56 -07:00
John Johansen
d4a76c456d Merge profiles: force read permission to their attachment path
Unconfined delegates access to open file descriptors. Therefore when running a confined binary from unconfined, it will work even when the attachment path is not read-allowed.

However, as soon as these confined binaries are run from another confined process, this delegation is not permitted anymore and the program breaks.

This has been the cause of several bugs such as https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2107455 or https://github.com/canonical/snapd/pull/15181 .

This MR makes sure every confining AppArmor profiles explicitly allow (at least) read access to their attachment path.

This Merge request:
 - Introduce `test_profile.sh`, a helper script that ensures confining AppArmor profiles explicitly allow (at least) read access to their attachment path.
 - Modifies a lot of profiles so that all profiles have r/mr access to their attachment path
 - Extends `make check` to automatically ensure all AppArmor profile grant explicit read access to their attachment path, preventing future omissions.
 - Modifies apparmor_parser to show attachment in --debug output

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1637
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-28 12:02:18 +00:00
John Johansen
bcf1f7017e Revert "make check: verify attachment-path read permission in profiles"
This reverts commit 75959225b35cc3cd76e684f2db62e27ee4e81288.

Do not enable the verify attachment-path script as part of the CI.

1. The script itself has several bashisms, that need to be fixed before
we land it as part of the regular integration test.
2. The script is going to need to be extended to support the new
parser variables, before it can be turned on as part of the CI.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-28 04:40:34 -07:00
Giampaolo Fresi Roglia
1d9e2c170a
locale: add mmap perms to the compressors as well. 2025-04-28 11:39:20 +02:00
Giampaolo Fresi Roglia
366c13f7dc
locale: add suggestion from @rlee287 2025-04-28 11:36:12 +02:00
John Johansen
96d327d28a aa-status: improve failure messages
Improve the failure messages around getting policy information to
be less ambiguous about what went wrong.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-26 11:13:35 -07:00
Giampaolo Fresi Roglia
af1a39653e
locale: added suggestion from @emixam16 2025-04-25 16:26:49 +02:00
John Johansen
6f480cb819 Merge binutils/aa-status: don't exit if no profiles are loaded
Downstream report: https://github.com/NixOS/nixpkgs/issues/347490

Output of `aa-status` is nondescriptive if no profiles are loaded.

Worse yet, the json output isn't even valid json.
It would make sense to just return a json object with no entries,
instead of returning a non-json `eprint` to stderr.

**Ideally** output of non-json would be more descriptive.

Currently:
```
apparmor module is loaded.
Failed to get profiles: 2....
```


What i would prefer:
```
apparmor module is loaded.
Failed to get profiles: No policies loaded
```

However, i am unfamiliar with how the translation framework works,
and thus not confident to do this change blindly.
I am happy to add a commit doing so if i know where to change all that.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1652
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-24 10:48:38 +00:00
Grimmauld
59d0708818
binutils/aa-status: don't exit if no profiles are loaded
Downstream report: https://github.com/NixOS/nixpkgs/issues/347490

Output of `aa-status` is nondescriptive if no profiles are loaded.

Worse yet, the json output isn't even valid json.
It would make sense to just return a json object with no entries,
instead of returning a non-json `eprint` to stderr.
2025-04-24 10:45:42 +02:00
Steve Beattie
887ff42043 Merge parser: fix rlimit ofile when built on musl libc
glibc defines bsd's rlimit ofile as nofile, however musl does not define
rlimit ofile at all.

Instead of just dropping ofile which would be bad for policy portability
make sure it is defined to be nofile.

This is a partial fie for
https://gitlab.com/apparmor/apparmor/-/issues/513

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1648
Approved-by: Steve Beattie <steve+gitlab@nxnw.org>
Merged-by: Steve Beattie <steve+gitlab@nxnw.org>
2025-04-22 23:49:57 -07:00
John Johansen
e3840b0dad parser: fix rlimit ofile when built on musl libc
glibc defines bsd's rlimit ofile as nofile, however musl.

Instead of just dropping ofile which would be bad for policy portability
make sure it is defined to be nofile.

This is a partial fie for
https://gitlab.com/apparmor/apparmor/-/issues/513

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-22 23:26:54 -07:00
Ryan Lee
446d6c51ce profiles: completely rework wpa_supplicant dbus rules based on source code
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-22 14:41:08 -07:00
Ryan Lee
3aa71afd73 profiles: add network packet dgram rule to wpa_supplicant
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-22 12:46:30 -07:00
Ryan Lee
fa2d082741 profiles: add a systemd-detect-virt profile
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-22 10:34:36 -07:00
Giampaolo Fresi Roglia
c1ecdb4f26
apparmor.d: add locale profile 2025-04-22 16:45:09 +02:00
john-breton
2e88bcf9f3
Deny CAP_SYS_ADMIN and cleanup profile
Signed-off-by: john-breton <john.breton@canonical.com>
2025-04-22 07:19:13 -04:00
John Johansen
a041f2beb8 Revert "Merge profiles: fix QtWebEngineProcess multiarch path in plasmashell"
This reverts commit 27f5b623f726a84f8430825e2e2641043965af94, reversing
changes made to ee08bfbc905102380bfcaf64d5d84bced98c9360.

This causes the plasmashell profile to have a conflicting x modifiers
error. This breaks CI and compile/load of the plasmashell profile.

Revert until it can be fixed. Using priority.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-21 12:11:21 -07:00
John Johansen
27f5b623f7 Merge profiles: fix QtWebEngineProcess multiarch path in plasmashell
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1645
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-21 18:35:59 +00:00
John Johansen
ee08bfbc90 Merge add path for plasmashell with qt6 based QtWebEngineProcess in debian derivatives
we are using this path in a local profile shipped with plasma-workspace in KDE neon

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1633
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-04-21 18:34:09 +00:00
Ryan Lee
2678d0ca35 profiles: fix QtWebEngineProcess multiarch path in plasmashell
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-21 11:26:51 -07:00
John Johansen
663e5bf90b Merge fusermount3: Include full nameservice rules for SSSD users
```
audit: type=1400 audit(1744218886.059:4484): apparmor="DENIED" operation="open" class="file" profile="fusermount3" name="/var/lib/sss/mc/passwd" pid=19539 comm="fusermount3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
audit: type=1400 audit(1744218886.059:4485): apparmor="DENIED" operation="open" class="file" profile="fusermount3" name="/var/lib/sss/mc/passwd" pid=19539 comm="fusermount3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
audit: type=1400 audit(1744218886.059:4486): apparmor="DENIED" operation="connect" class="file" profile="fusermount3" name="/var/lib/sss/pipes/nss" pid=19539 comm="fusermount3" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
```

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1625
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-04-21 18:17:53 +00:00
John Johansen
8504cda668 Merge abstractions/nameservice: allow kanidm-unixd
If kanidm is configured in nsswitch.conf(5), access to the kanidm-unixd
configuration is needed for applications to resolve entries.

For example:

```
type=AVC apparmor="DENIED" operation="open" class="file" profile="php-fpm"
name="/etc/kanidm/unixd" comm="php-fpm" requested_mask="r" denied_mask="r"
```

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1638
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: John Johansen <john@jjmx.net>
2025-04-21 08:18:03 +00:00
John Johansen
7702b40359 Merge make AMD GPUs work better
Proposed by darix

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1642
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-21 08:15:46 +00:00
John Johansen
99c5837195 Merge regression: add xpass tests that demonstrate that access(2) isn't mediated
There is an unfortunate long kernel dev history as to why this currently
isn't the case, so we're stuck with documenting the facts for now.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1641
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-20 21:48:52 +00:00
Christian Boltz
5d71e19753
make AMD GPUs work better
Proposed by darix
2025-04-20 22:19:01 +02:00
Ryan Lee
3347685898 regression: add xpass tests that demonstrate that access(2) isn't mediated
There is an unfortunate long kernel dev history as to why this currently
isn't the case, so we're stuck with documenting the facts for now.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-18 15:40:39 -07:00