2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

7952 Commits

Author SHA1 Message Date
fossdd
02b7e41ef3
binutils: Fix missing include limits.h
For NAME_MAX

Fixes 322a98c8 ("Fix incorrect strnlen length in aa_load.c load_policy_dir")
2025-05-03 16:48:24 +02:00
John Johansen
e510dfd0e7 Merge profiles: add a profile for hwctl
I'm working on a Rust library project that collects hardware and OS information from the local system and queries the Ubuntu Hardware Certification service to determine if the device model has been certified.

I'd like to add an AppArmor profile to ensure the `hwctl` program has access to the resources it needs.

Project source code: https://github.com/canonical/hardware-api/

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1658
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-02 22:22:25 +00:00
Nadzeya H
88c81906de
profiles: add a profile for hwctl 2025-05-02 12:28:22 +02: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
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
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
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
Christian Boltz
c5642f9d43 Merge utils: fix unix qualifier clean rule generation
The wrong clean rule is generated when unix rules contain qualifiers,
with the order inverted with the rule name.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/511
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

Closes #511
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1639
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-04-18 19:11:39 +00:00
Georg Pfuetzenreuter
675a99ac7b
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>
2025-04-18 17:15:02 +02:00
Maxime Bélair
d4e795fe6d utils: Fix test-logprof.py for bin.ping profile
Update expected output to match the modifications on bin.ping profile.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-18 12:41:56 +02:00
Maxime Bélair
75959225b3 make check: verify attachment-path read permission in profiles
Extend `make check` to automatically ensure every AppArmor profile grants
explicit read access to its attachment path, preventing future omissions.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-18 12:41:56 +02:00
Maxime Bélair
072d17a237 profiles: Give all profiles read access to their attachment path
Grant explicit read permission on each profile’s attachment path. This
avoid issues when running them from a confined environment and makes
test_profile.sh pass.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-18 12:41:56 +02:00
Maxime Bélair
68c0dddf23 Add a script to verify attachment-path permissions
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 .

Introduce `test_profile.sh`, a helper script that ensures confining
AppArmor profiles explicitly allow (at least) read access to their
attachment path.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-18 12:41:54 +02:00
Maxime Bélair
5d7fe96fd0 apparmor_parser: show attachment in --debug output
When showing the content of profiles with `apparmor_parser --debug`, the
attachment path is now displayed within the 'Debugging built structures'
section.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-18 10:26:20 +02:00
Georgia Garcia
8c84b36b32 utils: fix unix qualifier clean rule generation
The wrong clean rule is generated when unix rules contain qualifiers,
with the order inverted with the rule name.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/511
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-04-17 20:39:58 -03:00
Maxime Bélair
cda9153772 Merge lsblk profile: Minor fixes
Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2107402

Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2107455

Allow `/usr/bin/lsblk mr` to make this profile work from confined
profiles. Also, allow css devices to work properly with lsblk.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1632
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-17 18:59:33 +00:00
carlosdem
d8ddd665fc fix typo 2025-04-17 00:10:00 +00:00
Maxime Bélair
7b8232fe29 lsblk profile: Minor fixes
Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2107402
Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2107455

Allow `/usr/bin/lsblk mr` to make this profile work from confined
profiles. Also, allow css devices to work properly with lsblk.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-16 14:32:45 +02:00
carlosdem
393444b7ba add path for plasmashell with qt6 based QtWebEngineProcess in debian derivatives 2025-04-16 11:34:13 +00:00
John Johansen
ccf1b25d3d Merge fusermount3: allow ro mounts on /cvmfs
CVMFS ( the [CernVM File System](cernvm.cern.ch)) is a read-only fs used to distribute software that is widely used in scientific computing (at CERN and beyond, for example by the [EESSI project](eessi.io)).

CVMFS historically uses the mountpoint /cvmfs, but the new fusermount3 profile doesn't allow that. It's not really possibly to move the mountpoint to /mnt/cvmfs, because the software installed on CVMFS often uses the absolute path /cvmfs/... for linking.

We've added a /etc/apparmor.d/local/fusermount3 to our packages, but it'd be much appreciated if this could be fixed upstream!

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1587
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-04-13 07:26:38 +00:00
John Johansen
f34a7d0b28 Merge parser: add an abi <default> that is equivalent to not specifying an abi
I am unsure how to test this equivalency due to how abi declarations interact with feature file command line arguments, so advice on that would be welcome.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1585
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-12 10:30:28 +00:00
John Johansen
491def4385 parser: make abi=<kenrel> respect the command line specied kernel features
Currently abi=<kernel> always grabs the kernels actual features but
it should respect --kernel-features=. This is causing the simple
tests to fail when abi=<kernel> is specified.

Fix it so abi=<kernel> respects the kernel abi specified in the configs
or on the command line.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-12 03:07:53 -07:00
John Johansen
8138bc60d1 Merge unprivileged_userns profile: Allow full file system access
Fixes https://gitlab.com/apparmor/apparmor/-/issues/505

The profile previously permitted access to `/**`, which excludes the root
directory (`/`). This commit also gives `/` access, aligning with the
intended behavior.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>

Closes #505
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1626
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-04-12 09:19:25 +00:00
Christian Boltz
59d9d001a1 Merge Move the "unsafe" rules of front_perms_ok simple tests to separate test file
This enables us to exercise the front perms parse logic in the utils rule parsing through the simple tests as well

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1627
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-04-11 16:37:07 +00:00
Maxime Bélair
182db98c2a unprivileged_userns profile: Allow full file system access
Fixes https://gitlab.com/apparmor/apparmor/-/issues/505

The profile previously permitted access to `/**`, which excludes the root
directory (`/`). This commit also gives `/` access, aligning with the
intended behavior.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-04-11 09:02:49 +02:00
Ryan Lee
fe9c305ccd Move the "unsafe" rules of front_perms_ok simple tests to separate test file
This enables us to exercise the front perms parse logic in the utils rule parsing through the simple tests as well

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-10 11:19:05 -07:00
Alessandro Astone
c09501ad59 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

Fixes: http://bugs.launchpad.net/bugs/2106311
2025-04-10 17:26:39 +02:00
John Johansen
4e1a8feb03 lib: version sync
Sync version of library to match that of 4.1 release.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-10 02:15:53 -07:00
John Johansen
08a67f3e20 Merge tests/profiles/tinyproxy: add some functional tests for tinyproxy
Check that when using a HTTP client via tinyproxy that the expected Via header
is present and that the tinyproxy stats page works as expected.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1537
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-09 18:20:07 +00:00
John Johansen
d9ecaf60bc Merge tests: regressions: fix unix_socket_pathname.sh for upstream kernels
FS based unix sockets have a complicatd interaction with socket
mediation some of the mediation happens in file hooks while other
parts happen in network hooks.

When the kernel doesn't have the unix socket mediation patches the
interactions become largely mediated through the network hooks, as
unix rules get downgraded to socket rules. However some filesystem
operations are needed, and some hooks like bind may be called
differently based on the unix socket type, and not just the address.
Without the kernel patches these variations are not taken into
account.

Changes in the parser networking permission mappings have also
affected the downgrade path, as the parser now supports permissions on
socket rules, downgrades can use permissions and be more faithful to
the original rule but this can also break tests that didn't add all
the permissions needed for the downgrade case.

update unix_socket_pathname.sh to detect whether rule downgrades are
being used, and adjust permissions and expectations based on this.

Fixes: 7ce768244 ("tests: regression: fix regression test for upstream kernels")

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1622
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
v4.1.0-cherry-pick-point
2025-04-08 15:48:57 +00:00
John Johansen
2c784709b2 tests: regression: increase unix socket test timeout
The tests on slower systems are occassionally timing out leading to
inconsistent pass/fail runs. The time out failure depending on which
test it occurs in can result in false passes, or failres.

Double the timeout, which hopefully will be enough to avoid the
timeout issue without making the tests wait too long.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-08 06:42:17 -07:00
John Johansen
08f9466d1c tests: regressions: fix unix_socket_pathname.sh for upstream kernels
FS based unix sockets have a complicatd interaction with socket
mediation some of the mediation happens in file hooks while other
parts happen in network hooks.

When the kernel doesn't have the unix socket mediation patches the
interactions become largely mediated through the network hooks, as
unix rules get downgraded to socket rules. However some filesystem
operations are needed, and some hooks like bind may be called
differently based on the unix socket type, and not just the address.
Without the kernel patches these variations are not taken into
account.

Changes in the parser networking permission mappings have also
affected the downgrade path, as the parser now supports permissions on
socket rules, downgrades can use permissions and be more faithful to
the original rule but this can also break tests that didn't add all
the permissions needed for the downgrade case.

update unix_socket_pathname.sh to detect whether rule downgrades are
being used, and adjust permissions and expectations based on this.

Fixes: 7ce768244 ("tests: regression: fix regression test for upstream kernels")
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-08 06:42:11 -07:00