2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 05:17:59 +00:00

7811 Commits

Author SHA1 Message Date
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
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
Christian Boltz
df5060c3d7 Merge UnixRule: allow comma as separator in peer=
... and add some tests for it

I propose this fix for master and 4.1.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1580
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-03-13 17:18:44 +00:00
Christian Boltz
1ff9306c93
UnixRule: allow comma as separator in peer=
... and add some tests for it
2025-03-13 17:22:24 +01:00
John Johansen
819802cdb3 Merge utils: don't skip disabled profiles for aa-enforce
When running aa-disable and then aa-enforce passing the binary path as
the argument, aa-enforce fails to enforce the profile with the error:

$ sudo aa-disable /home/foo/test
skipping disabled profile test
Profile for /home/foo/test not found, skipping

According to the man page for aa-enforce, it should work for disabled
profiles.

Note that this does not happen when passing the profile directly to
the tools, so there's a workaround for this issue:

$ sudo /aa-enforce /etc/apparmor.d/test
Setting /etc/apparmor.d/test to enforce mode.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1579
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-03-13 14:35:00 +00:00
Georgia Garcia
b0b45b01c0 utils: don't skip disabled profiles for aa-enforce
When running aa-disable and then aa-enforce passing the binary path as
the argument, aa-enforce fails to enforce the profile with the error:

$ sudo aa-disable /home/foo/test
skipping disabled profile test
Profile for /home/foo/test not found, skipping

According to the man page for aa-enforce, it should work for disabled
profiles.

Note that this does not happen when passing the profile directly to
the tools, so there's a workaround for this issue:

$ sudo /aa-enforce /etc/apparmor.d/test
Setting /etc/apparmor.d/test to enforce mode.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-03-13 10:58:30 -03:00
Christian Boltz
ae20b62c31
Allow empty source and any word only in mount source 2025-03-11 21:51:42 +01:00
Christian Boltz
537fec8b36
Move [\w-]+ into inner match group
... by removing/moving the ')' after the empty source.

Also prepare source_fileglob_pattern and dest_fileglob_pattern to be
customizable by moving adding the closing ')))' into each of them.
2025-03-11 21:50:43 +01:00
Christian Boltz
2843c0f155
Make glob_pattern more readable
- replace filename and variable regex parts with RE_PROFILE_PATH_OR_VAR
- split to multiline string
2025-03-11 21:50:43 +01:00
Christian Boltz
d06260859b
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 ;-)
2025-03-11 21:07:14 +01:00
Christian Boltz
2afdf1b214 Merge utils: Fix mount rule handling for revokefs-fuse
First expand nested `(...)` in glob_pattern. This duplicates a few bytes, but makes the regex easier to read.

With that done, allow `-` in glob_pattern.

One of the possible matches in glob_pattern was `\w+` which matched for example `none`.

However, it doesn't match `revokefs-fuse` because of the `-`. Therefore change `\w+` to [\w-]+.

While on it, add two more tests - one for `none` with some options, and one with `revokefs-fuse`.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1565
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-03-10 20:35:57 +00:00
Zygmunt Krynicki
2fe23fef17 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>
2025-03-10 13:16:48 +01:00
John Johansen
e64bd1ccdf 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>
2025-03-10 00:47:20 -07:00
John Johansen
6faa8950ed Merge Increase timeout for test_allow_all
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1567
Approved-by: intrigeri <intrigeri@riseup.net>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: John Johansen <john@jjmx.net>
2025-03-04 22:16:31 +00:00
Bo YU
ca0afa1afb Increase timeout for test_allow_all 2025-03-04 08:36:54 +00:00
Christian Boltz
ce87b44bae
glob_pattern: allow -
One of the possible matches in glob_pattern was `\w+` which matched for
example `none`.

However, it doesn't match `revokefs-fuse` because of the `-`. Therefore
change `\w+` to [\w-]+.

While on it, add two more tests - one for `none` with some options, and
one with `revokefs-fuse`.
2025-02-28 23:47:05 +01:00
Christian Boltz
c1712c882c
Expand nested (...) in glob_pattern
This duplicates a few bytes, but makes the regex easier to read.
2025-02-28 23:20:46 +01:00
Georgia Garcia
bf2054d963 Merge utils: tests: cleanups and allow profile skipping in test-logprof and test-minitools
The utils cannot parse some profile constructs yet, so allow some profiles to be ignored in those tests.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1563
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-27 21:35:59 +00:00
Ryan Lee
df0358062d utils: test: expand mechanism for ignoring profiles in tests
The utils cannot parse some of the newer profile constructs yet, so
generalize a pre-existing mechanism for skipping profiles to use that mechanism in the other tests that need it

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 13:05:00 -08:00
John Johansen
0e8377cde9 Merge test-translations: include "ignore" in exec prompts + make debugging hotkey conflicts easier
This is a follow-up of adding the "ignore" option to exec prompts in
https://gitlab.com/apparmor/apparmor/-/merge_requests/1543

To make future handling of hotkey conflicts easier,
- display all hotkey conflicts at once instead of erroring out at the first conflict.
- display all options involved in a hotkey conflict to make fixing it easier.

Since 1543 was picked into 4.1, I propose the same for this MR.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1557
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-25 02:47:20 +00:00
Ryan Lee
dbe13a0b9d Merge Avoid blhc "CPPFLAGS missing" false positive
Similarly to apparmor/apparmor!403, we don't really need to pass these flags
here, but if we don't, blhc raises a false positive, and I don't want to get
used to ignoring blhc failures on Debian's GitLab CI.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1558
Approved-by: Alex Murray <alex.murray@canonical.com>
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Ryan Lee <rlee287@yahoo.com>
2025-02-24 17:02:27 +00:00
Christian Boltz
db7e3109cc
test-translations: include "ignore" in exec prompts
This is a follow-up of adding the "ignore" option to exec prompts in
https://gitlab.com/apparmor/apparmor/-/merge_requests/1543
2025-02-24 13:35:08 +01:00
Christian Boltz
3e7e9bf01f
test-translations: display all hotkey conflicts at once
... instead of erroring out at the first conflict.

Also display all options involved in a hotkey conflict to make fixing it
easier.
2025-02-24 13:35:05 +01:00
Christian Boltz
d52b301ee8 Merge Import translations from launchpad
This imports translations from launchpad up to commit

revno: 2523
committer: Launchpad Translations on behalf of apparmor-dev
branch nick: apparmor
timestamp: Fri 2025-02-21 09:32:26 +0000
message:
  Launchpad automatic translations update.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1559
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-02-24 12:32:43 +00:00
John Johansen
2a87a92136 Import translations from launchpad
This imports translations from launchpad up to commit

revno: 2523
committer: Launchpad Translations on behalf of apparmor-dev
branch nick: apparmor
timestamp: Fri 2025-02-21 09:32:26 +0000
message:
  Launchpad automatic translations update.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-24 01:28:04 -08:00
intrigeri
187c244056 Avoid blhc "CPPFLAGS missing" false positive
Similarly to apparmor/apparmor!403, we don't really need to pass these flags
here, but if we don't, blhc raises a false positive, and I don't want to get
used to ignoring blhc failures on Debian's GitLab CI.
2025-02-20 22:35:37 +00:00
Georgia Garcia
45a945acd3 Merge profiles: allow ro mounts in fusermount3 profile
These are needed by e.g. AppImages

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1556
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-20 18:07:58 +00:00
Georgia Garcia
472181ae75 Merge profiles: fix sbuild to work with the unprivileged_unshare profile
sbuild is an unconfined profile allowing it to bypass the unprivlieged
user namespace restriction.

unconfined profiles use a pix transition which means that when the
unprivileged_unshare profile is enabled, the binaries in an unconfined
profile calling unshare will cause a transition to the unprivileged_unshare
profile.

This will break sbuild because it needs capabilities within the
user namespace.

However we cannot just add a x transition rule to unconfined profiles, as
the transitions won't be respected. Instead, we have to make the profile
a default allow profile and add a transition that will override
the default pix transition of allow all.

We have to add the attached_disconnected and mediated_deleted flags
because sbuild is manipulating mounts.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1555
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-20 17:56:47 +00:00
Ryan Lee
a20409cf1e profiles: allow ro mounts in fusermount3 profile
These are needed by e.g. AppImages

Closes: https://bugs.launchpad.net/bugs/2098993
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-20 09:49:27 -08:00
Ryan Lee
1b87b7be5e Replace terminfo lines in profiles with the terminfo abstraction
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-19 17:14:28 -08:00
Ryan Lee
c45ce5502e Add terminfo abstraction with terminfo paths searched by ncurses
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-19 16:48:19 -08:00
John Johansen
7abfc1baf7 profiles: fix sbuild to work with the unprivileged_unshare profile
sbuild is an unconfined profile allowing it to by-pass the unprivlieged
user namespace restritction.

unconfined profiles us a pix transition which means when the
unprivileged_unshare profile is enabled, the binaries in an unconfined
profile calls unshare it will transition to the unprivileged_unshare
profile.

This will break sbuild because it needs capabilities within the
user namespace.

However we can not just add a x transition rule to unconfined profiles,
the transitions won't be respected. Instead we have to make the profile
a default allow profile, and add a transition that will override
the default pix transition of allow all.

We have to add the attached_disconnected and mediated_deleted flags
because sbuild is manipulating mounts.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-19 16:05:57 -08:00
John Johansen
125ef7a8cb utils: genprof/logprof - fix missing newline nit in MR1543
This is a trivial fix for
  MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1543

instead of waiting longer for the auther to fix, the MR was merged
and this manual fixup done.

Fixes: dfe9d713f ("aa-logprof/aa-genprof: allow ignoring executions")
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-19 10:53:47 -08:00
John Johansen
71282550bb Merge aa-logprof/aa-genprof: allow ignoring executions
fixes https://gitlab.com/apparmor/apparmor/-/issues/302

Closes #302
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1543
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-19 18:48:50 +00:00
John Johansen
a5df123056 Merge profiles: add missing fowner capability to the tar profile
This manifested with chmod calls failing in autopkgtests of dbus and snapd.

Given the magnitude of regressions that might be caused by bugs in this profile, @alex_murray has suggested disabling the profile by default (i.e. moving it into `extras/`).

Reported-by: Alex Murray <alex.murray@canonical.com>
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1553
Approved-by: Alex Murray <alex.murray@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-02-19 18:18:41 +00:00