2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 13:58:22 +00:00

7952 Commits

Author SHA1 Message Date
Christian Boltz
c1dcc44201 Merge utils: fix cleanprof regression on header generation
Commit c9d41a3ebb introduced a regression on profile header
generation.

This commit removes the name parameter from the get_header function
since the ProfileStorage should already contain all the information
required to generate the header for profiles and hats. The tests
needed to be updated as well to make sure the ProfileStorage object
contained the information needed by the get_header method.

Fixes: c9d41a3ebb ("utils: fix profile and hat header generation")
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1602
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-03-31 20:42:43 +00:00
Christian Boltz
4c3954f13d test-cleanprof: add tests for external child profiles 2025-03-31 15:50:15 -03:00
Georgia Garcia
699d7b5c83 utils: fix cleanprof regression on header generation
Commit c9d41a3ebb introduced a regression on profile header
generation.

This commit removes the name parameter from the get_header function
since the ProfileStorage should already contain all the information
required to generate the header for profiles and hats. The tests
needed to be updated as well to make sure the ProfileStorage object
contained the information needed by the get_header method.

Fixes: c9d41a3ebb ("utils: fix profile and hat header generation")
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-31 15:50:15 -03:00
Christian Boltz
fda4f8140f Merge Fix attach_disconnected typo in docs
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1599
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-03-28 12:28:48 +00:00
Tim McCormack
b398ec61c9 Fix attach_disconnected typo in docs 2025-03-27 19:30:25 -04:00
Ryan Lee
372dcc8250 logprof: add /usr prefixed kernel module path to config for /usr merge
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-27 09:50:11 -07:00
Georgia Garcia
eaec0aa9d2 Merge utils: fix profile header generation
Profile header was being generated incorrectly in 2 cases:
When the profile contained the parent profile in its name, as in

profile firefox//dash {

and in the unit tests, the child profile was being named as the parent
profile. This was not caught by the general case because the code has
not yet been fully adapted to handle multiple nested child profiles.

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

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

Closes #493
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1592
Approved-by: Ryan Lee <rlee287@yahoo.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-26 14:28:36 -03:00
Georgia Garcia
3516dcaa30 Merge ci: upgrade all packages in CI
We are seeing some test failures caused by the fact that a fixed kernel,
while available, is not installed the CI image. Since cloud-init does
not itself offer a way to express precise dependency on a package
version we may use a crude replacement of upgrading all the packages at
image construction time.

The next time this happens all we need is to touch the .image-garden.mk
file, so that it is more recent than the image kept in CI cache for the
re-generation to occur.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1595
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-26 10:20:17 -03:00
Zygmunt Krynicki
f43221d945 ci: upgrade all packages in CI
We are seeing some test failures caused by the fact that a fixed kernel,
while available, is not installed the CI image. Since cloud-init does
not itself offer a way to express precise dependency on a package
version we may use a crude replacement of upgrading all the packages at
image construction time.

The next time this happens all we need is to touch the .image-garden.mk
file, so that it is more recent than the image kept in CI cache for the
re-generation to occur.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-03-26 14:00:33 +01:00
Georgia Garcia
c9d41a3ebb utils: fix profile and hat header generation
The header was being generated incorrectly in 2 cases:
When the profile/hat contained the parent profile in its name, as in

profile firefox//dash {
hat ^firefox//dash {

and in the unit tests, the child profile or hat was being named as the
parent profile. This was not caught by the general case because the
code has not yet been fully adapted to handle multiple nested child
profiles.

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

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-26 09:53:08 -03:00
Georgia Garcia
ef2f6aa565 Merge profiles: allow fusermount3 to (u)mount nested subdirs of @{run}/user/@{uid}
This is needed to fix the gnome-remote-desktop daemon, which mounts in a
directory like /run/user/119/gnome-remote-desktop/cliprdr-ABm0Gd/.

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

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1591
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-24 17:04:32 -03: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
klo
23c6e17f7f profiles: allow fusermount3 to (u)mount nested subdirs of @{run}/user/@{uid}
This is needed to fix the gnome-remote-desktop daemon, which mounts in a
directory like /run/user/119/gnome-remote-desktop/cliprdr-ABm0Gd/.

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

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-24 12:22:19 -07:00
John Johansen
07eef2823f Merge regression: fix test suite runs on older Ubuntu releases
This involves replacing `command -v` with `which` (again), since the `command` shell builtin isn't recognized by older versions of Make, as well as skipping tests that require the `linux/mount.h` header on older systems that lack it.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1578
Approved-by: Zygmunt Krynicki <me@zygoon.pl>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-22 01:06:48 +00:00
Zygmunt Krynicki
bd500e2391 Add support for running image-garden as a snap
The new image-garden snap offers a one-stop-shop for integration
testing, bundling qemu, spread and image-garden build recipes.

Extend the documentation, the run-spread.sh helper script as well as
spread.yaml to support this new method.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-03-21 18:33:13 +01: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
af936812ee spread: add which to openSUSE Tumbleweek image-garden package list
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
Ryan Lee
64b920607b parser: add abi <default> to the apparmor.d man page
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 11:03:28 -07:00
Ryan Lee
94ed11edff parser: add abi <kernel> to the ABI grammar of apparmor.d.pod man page
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 10:49:17 -07:00
Ryan Lee
4473a42af7 parser: add abi <default> as a simple test
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 10:31:25 -07:00
Ryan Lee
ad3ecbd60a parser: add abi <kernel> as a simple test
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-20 10:31:17 -07:00
Ryan Lee
eb5a4f8628 Merge small fix for lsblk profile
Fixes [launchpad bug #2103524](https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2103524)

lsblk on some virtualized systems require access to directory
`/sys/devices/LNXSYSTM:*/LNXSYBUS:*/**` since block devices can be exposed
in this directory.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1584
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Ryan Lee <rlee287@yahoo.com>
2025-03-20 09:23:17 -07:00
Scarlett Moore
7f12ccf695 Add qt6 abstractions for qt6 to fix KDE application crashes. 2025-03-20 09:09:54 -07:00
Valentin Volkl
616833d57d also umount? 2025-03-20 10:13:39 +00:00
Valentin Volkl
ce5e5a15fb fusermount3: allow ro mounts on /cvmfs 2025-03-20 10:03:14 +00:00
Maxime Bélair
b527256c0d small fix for lsblk profile
Fixes bug #2103524

lsblk on some virtualized systems require access to directory
/sys/devices/LNXSYSTM:*/LNXSYBUS:*/** since block devices can be exposed
in this directory.
2025-03-20 09:07:14 +01:00
John Johansen
6076d8c49a Merge libapparmor: constify aa_features pointer args where possible
Making a previously non-const pointer arg const is not an ABI break, and
having const expresses the intent of the interface better.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1586
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-20 01:15:46 +00:00
Ryan Lee
5554dd3b5b libapparmor: constify aa_features pointer args where possible
Making a previously non-const pointer arg const is not an ABI break, and
having const expresses the intent of the interface better

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-19 17:32:54 -07:00
Ryan Lee
c9c29f02b1 parser: add an abi <default> that is equivalent to not specifying an abi
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-19 17:24:34 -07:00
Hector Cao
4476eb8288 Add abstract profile for libnuma
For executables dynamically linked to libnuma, the runtimer linker
invokes libnuma functions (num_init) that try to access
/sys/devices/system/node/ and if the application's apparmor
profile does not allow this access, this access will be denied
by apparmor with following error message:

  apparmor="DENIED" operation="open" class="file"
  name="/sys/devices/system/node/" comm="qemu-bridge-hel"
  requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

Here is the simplified call trace:

  0 ... in ?? () from /lib/x86_64-linux-gnu/libnuma.so.1
  1 ... in call_init (...) at ./elf/dl-init.c:74
  2 ... in call_init (...) at ./elf/dl-init.c:120
  3 _dl_init (...) at ./elf/dl-init.c:121
  4 ... in _dl_start_user () from /lib64/ld-linux-x86-64.so.2

This commit adds an abstract profile that applications that are
linked to libnuma can include in their apparmor profile.

MR: mailing list patch
Signed-off-by: Hector Cao <hector.cao@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-03-19 09:19:21 -07:00
John Johansen
e030ff7ea9 Merge utils/test/test-aa-notify.py: update last cmd for lxd VMs
When doing testing via LXD VMs and in particular when using "lxc exec" to run
commands in the VM, there is no controlling tty and so the output of last is
missing this column of data. Instead try even harder to parse the timestamp from
the output of "last".

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1582
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-19 06:17:34 +00:00
John Johansen
f11c2032da Merge Use the $(AWK) variable for the awk binary in the Makefiles
Followup that replaces !1576.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1581
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: John Johansen <john@jjmx.net>
2025-03-19 05:18:45 +00:00
John Johansen
a3d3a96ec5 Merge Fix typo in aa-exec manpage
Follow-up of https://gitlab.com/apparmor/apparmor/-/merge_requests/1570, which was merged without fixing this.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1583
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-18 21:51:29 +00:00
Christian Boltz
8c12d358b0
Fix typo in aa-exec manpage 2025-03-18 22:06:57 +01:00
Ryan Lee
8beac326a5 Use the $(AWK) variable for the awk binary in the Makefiles
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-03-18 09:28:52 -07:00
John Johansen
791935b9f8 Merge profiles: allow sanitized_helper to run snap applications
This allows evince to share the document to a program running as a snap,
e.g. mail via firefox. Given that /usr/bin/snap itself is not confined
I chose to use ux, rather than pux.

Tested locally on Ubuntu 24.04 by sharing a document from evince to
firefox.

Fixes: https://bugs.launchpad.net/apparmor/+bug/2095872
Jira: https://bugs.launchpad.net/apparmor/+bug/2095872

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1572
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-18 16:17:04 +00:00
Alex Murray
b6654416b0
utils/test/test-aa-notify.py: update last cmd for lxd VMs
When doing testing via LXD VMs and in particular when using "lxc exec" to run
commands in the VM, there is no controlling tty and so the output of last is
missing this column of data. Instead try even harder to parse the timestamp from
the output of "last".

Signed-off-by: Alex Murray <alex.murray@canonical.com>
2025-03-18 17:45:00 +10:30
John Johansen
8ed0bddcc9 Merge binutils: aa-exec: add basic documentation on stacking and namespaces
The aa-exec man page makes reference to aa-stack(8) and aa-namespace(8)
manpages that don't exist. For now just remove those references and
add a short blurb on using aa-exec with stacking and namespaces.

Proper full manpages for stacking and namespaces need to be added
but that is beyound the scope of this fix.

Bug: https://gitlab.com/apparmor/apparmor/-/issues/496
Signed-off-by: John Johansen <john.johansen@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1570
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-18 04:57:03 +00:00
John Johansen
2fb0fa9964 Merge add support for writing quoted mount source and mountpoints
Add quotes if a mount source or mountpoint includes whitespace.
Also explicitely handle empty mount source (known from
1f33fc9b29c174698fdf0116a4a9f50680ec4fdb)

As usual, some tests can't hurt ;-)

I propose this fix for 4.0..master

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1573
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-18 04:56:22 +00:00
John Johansen
e065dfb35a Merge utils: Improve regex for mount source and target
* Make glob_pattern more readable
    - replace filename and variable regex parts with RE_PROFILE_PATH_OR_VAR
    - split to multiline string

* Move `[\w-]+` into inner match group by removing/moving the ')' after the empty source.

* Prepare source_fileglob_pattern and dest_fileglob_pattern to be customizable by moving adding the closing ')))' into each of them.

* Allow empty source and any word only in mount source

See the individual commits for details.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1574
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-18 04:55:21 +00:00
Ryan Lee
a82b16f059 Merge Add ncurses abstraction with terminfo paths
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1550
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Ryan Lee <rlee287@yahoo.com>
2025-03-17 09:16:14 -07:00
John Johansen
e38db72fea Merge parser: add support for attach_disconnected.ipc flag
The attach_disconnected.ipc flag allows the use of disconnected paths
on posix mqueues. This flag is a subset of attach_disconnected, and it
does not allow disconnected paths for all files.

Corresponding kernel patch needed to test in https://gitlab.com/georgiag/apparmor-kernel/-/tree/mqueue-ext
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1577
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-13 18:56:30 +00:00
Georgia Garcia
541d3f4489 parser: add attach_disconnected.ipc parser tests
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-13 14:51:18 -03:00
Georgia Garcia
d9b3603f48 parser: add support for attach_disconnected.ipc flag
The attach_disconnected.ipc flag allows the use of disconnected paths
on posix mqueues. This flag is a subset of attach_disconnected, and it
does not allow disconnected paths for all files.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-13 14:51:18 -03:00