2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

553 Commits

Author SHA1 Message Date
Ryan Lee
bef673f3c6 regression: disconnected_mount_complain dangling fds and alloc fail handling
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-08-12 15:00:20 -07:00
Ryan Lee
73bcf488b2 regression: fix usage statement for linkat_tmpfile
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-07-30 16:35:21 -07:00
Ryan Lee
d3a49ff566 regression: add linkat_tmpfile test to task.yaml
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-07-24 08:45:16 -07:00
Ryan Lee
3e7ddc1ce5 regression: add test for making O_TMPFILE followed by linkat
The unnamed nature of an O_TMPFILE, combined with the delayed linkage of
linkat(2), creates a potential for a filesystem mediation bypass. Thus,
add a test to verify whether or not such a bypass occurs.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-07-24 08:45:16 -07:00
Maxime Bélair
83e9be1035 Merge Add free profile
Basic AppArmor profile for the free binary, tested on Ubuntu 24.04.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1629
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-06-23 14:11:07 +00:00
Octavio Galland
37a4b6cb81 Add curl profile 2025-06-23 13:49:23 +00:00
Zygmunt Krynicki
ddba3bb5b5 tests: match printed output from lsusb
This is a small improvement that makes sure lsusb is able to read some
properties of the virtual USB devices provisioned for the test.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-06-10 08:14:53 +02:00
Federico Quattrin
ec2c363125 added basic integration test 2025-06-06 13:56:39 -07:00
Ryan Lee
6e16efe703 Add additional mount regression tests for options= options in combo
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-27 14:40:26 -04:00
Maxime Bélair
c8dc701666 Merge Add netcat-openbsd profile
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1327
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-13 07:22:31 +00:00
Maxime Bélair
672bfcb72b Merge ProFTPD Profile
Creates an AA profile for ProFTPD. The profile has been tested on Oracular with version `1.3.8.b+dfsg-2ubuntu1`, using the source integration/unit tests and via FTP commands. As an FTP package any directory can be used for manipulating files. I've included read/write permissions to several usual locations located at the end of the profile. However these are too loose, any suggestions for how they could be tightened is much appreciated. Thanks!

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1524
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-12 14:27:28 +00:00
bruce-canonical
e892093c06 ProFTPD Profile 2025-05-12 14:27:27 +00:00
Maxime Bélair
16fd1dab67 Merge profiles: add a who profile
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1634
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-12 14:19:51 +00:00
Maxime Bélair
2a7b84cd73 Merge Initial lsof profile (+ comments)
Initial profile for review + extra descriptions to summarize why each rule / chunk is there.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1486
Approved-by: John Johansen <john@jjmx.net>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-12 14:19:20 +00:00
Ryan Lee
4094bc1a05 profiles: add a smoke test for the who profile
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-12 15:42:24 +02:00
John Johansen
d94ff137ef Merge parser: enable create perm when label is defined
Due to how labeling is implemented, during the creation it is not yet
defined, so we need to grant create permissions without attaching the
label yet. Also, adjust tests to pass when label support is
implemented in the kernel.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1623
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-12 08:00:11 +00:00
Georgia Garcia
2c1ed72cbb spread: add allow_all to list of spread regression tests
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-08 10:52:42 -03:00
John Johansen
90048417bb Merge regression: exercise options in (list) feature of mount rules
This includes testing for options in (list) by itself, along with a rudimentary test for the combination of options=(list) and options in (list).

In particular, the test for the combination confirms that the `apparmor.d` man page was wrong about what happens when these options are combined.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1672
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 08:51:50 +00:00
John Johansen
726cb2e1f1 Merge regression: add an allow_all test that checks pix+ix transitions
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1663
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 05:46:20 +00:00
Ryan Lee
3b012c3a24 profiles: fix lsof profile test
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-07 16:49:14 -07:00
Georgia Garcia
89e2aa76eb spread: remove disconnected_mount_complain from xfail tests
disconnected_mount_complain only contains xpass tests, which should
not be included in the spread XFAIL tests.

Fixes: 1aca4a1d ("tests: regression: mark disconnected-complain-mode tests as xpass")
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-07 14:55:02 -03:00
Ryan Lee
52c969c980 regression: exercise the combination of option= and option in for mounts
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-06 12:30:13 -07:00
Ryan Lee
a7babf2391 regression: also exercise options in (list) feature of mount rules
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-06 12:30:13 -07:00
Eisuke Kawashima
b50f516a78
chore: fix vim modelines
- set filetype, instead of syntax, in vim modelines
- replace filetype of subdomain with apparmor
- move modelines in the first or last five lines of each file so that
  vim can recognize them
2025-05-04 23:01:43 +09:00
Nicolas Campuzano Jimenez
a65924c28a cleaner way to keep files open for lsof 2025-05-02 12:57:18 -07:00
Nicolas Campuzano Jimenez
c9cd3606b0 Updated profile + tests 2025-05-02 12:57:18 -07: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
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
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
Georgia Garcia
c25f2d3407 tests: detect if label is supported in the kernel
When label is detected in the kernel, the tests pass.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-04-14 09:48:15 -03:00
Federico Quattrin
0d992be695 added smoke tests for free profile 2025-04-10 15:54:50 -03: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
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
John Johansen
ff2bd885e3 Merge profiles: remove the toybox profile
toybox is similar to busybox but is developed with Android development in
mind. Thus, it has the same issues as the busybox profile and should be
removed.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1620
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-04-08 09:32:18 +00:00
John Johansen
7ce768244d tests: regression: fix regression test for upstream kernels
The attach_disconnected.sh and deleted.sh tests added expanded their
testing by using unix sockets. This however ever needs support of
unix socket mediation.

Provide a minimal fix by setting bailouts for the the tests if the
requirement is not present. Long term it would be better if the
expected/needed permissions sets could be tweaked to take into
account the permissions required by the use of unix sockets.

The fix f47d5c70a fix af_unix tests for v8 networking, was never
correct, though it worked and was closer before support for fine
grained inet mediation landed. Before finegrained inet mediation
landed unix rules would allow specifying the permission but inet would
not only allowing coarse socket mediation rules. While the backend
supported finegrained permissions in v8 socket mediation the parser
did not.

If af_unix mediation was not supported by the kernel the af_unix
mediation rule would be downgrade to a network rule. All network
socket rules allowed full permission because the parser didn't
support permissions on socket rules. So the "unix create," rule
was being downgraded to a "unix," rule. Thus the "unix create",
rule was enough permissions, in the downgrade even though it
actually wasn't enough permissions.

With support for fine grained inet permissions, support for permissions
on socket rules also landed. When this happend "unix create," was not
enough permissions any more because it was not downgraded to "unix,",
this resulted in failed mediation.

Fixes: cb4a397b1 ("tests: add attach_disconnected tests")
Fixes: f47d5c70a ("fix af_unix tests for v8 networking")

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-07 16:49:14 -07:00
Ryan Lee
aecb02a22e profiles: remove tests for the removed toybox profile
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-07 14:26:09 -07:00
Ryan Lee
d4f75cec2b regression: uncomment the detached keyword mount tests
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-04-05 00:19:09 -07:00
John Johansen
1aca4a1dcf tests: regression: mark disconnected-complain-mode tests as xpass
Without the kernel patches in
https://lists.ubuntu.com/archives/apparmor/2025-March/013533.html
these tests will fail. This means spread ci for the majority of
kernels will fail.

Indeed disconnected paths failing in complain mode was always expected
behavior until the above kernel patches were posted.

Instead mark these patches as xpass, so spread CI can pass. These
tests will need to be updated to make them detect if the kernel
supports complain mode with disconnected paths.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-04-04 23:42:41 -07:00
Ryan Lee
04ff259668 regression: remove unneeded headers from move_mount.c
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:58:00 -07:00
Ryan Lee
40e07b4561 regression: move new mount syscall defs to shared header and test for necessity
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:58:00 -07:00
Ryan Lee
1f08b5125d regression: add disconnected_mount_complain to spread test yaml
The test is added as XFAIL for all images because the kernel patches
required for them to pass have not yet been upstreamed into any published
kernel.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:57:40 -07:00
Ryan Lee
d364e2498a regression tests: add fsmount to disconnected_mount_complain
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:57:40 -07:00
Ryan Lee
195a175b00 regression: test complain-mode operations on disconnected paths in mounts
Disconnected paths on lookups have caused actual permission denials, even
when the loaded profile is in complain mode. This is a test that causes
disconnections using mounts (both old and new API) and then verifies that
a complain mode profile doesn't prevent operations with disconnected fds.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:57:40 -07:00
Ryan Lee
5edca7f64f regression: skip move_mount tests when move_mount binary is unavailable
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 15:09:49 -07:00
Ryan Lee
52fc40a9cb regression: replace command -v with which in Makefile
The command shell builtin is not recognized by older versions of make, so
switch back to using the which binary instead.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 15:09:49 -07:00
Ryan Lee
765d5b87ef regression: skip move_mount test if linux/mount.h is not found
linux/mount.h is only used in the move_mount test, which exercises the
move_mount syscall that was introduced sometime in 2018 or later. Older
systems without the header also lack the syscall, so we can just skip the
test in those cases.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 15:09:49 -07:00
Alex Murray
db87670698
tests/profiles/tinyproxy: use local http server for functional test
Instead of relying on neverssl.com spin up a local http server and test
tinyproxy against that to ensure the test can run even if the wider internet is
not accessible.

Signed-off-by: Alex Murray <alex.murray@canonical.com>
2025-02-24 22:08:04 +10:30
John Johansen
8711c7754b Merge tests: provide better output on failures
When a test fails because of an unexpected success (XFAIL), do not display the empty error log as that may confuse the reader just as it had confused the author.

In addition, when something legitimately fails then display tail of trace log as that may show some useful information.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1548
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-18 15:06:33 +00:00
Zygmunt Krynicki
c56cbad5ea tests: remove XFAIL/mqeue, stale
There is no mqueue in Makefile TESTS anywhere. This is a red herring.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 17:32:08 +01:00