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

8146 Commits

Author SHA1 Message Date
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
Georgia Garcia
c07b0093d8 spread: improve error message when regression test is missing
Due to how the debug information shows up when something fails in
spread the information is hard to figure out.

See this example when the allow_all test was missing
https://gitlab.com/apparmor/apparmor/-/jobs/9958642493

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-08 10:52:24 -03:00
John Johansen
eda0461d58 Merge profiles: expand set of flags allowed for fusermount3
fuse_overlayfs requires noatime, but we should also allow more flags than
just that to preempt future breakage from flags not included in the rules.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1673
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-08 11:04:06 +00:00
John Johansen
763c0d9d61 Merge profiles: replace the unconfined ipa_verify profile with a proper one
ipa_verify is a simple libcamera tool that does not use the portion of
libcamera that creates user namespaces. This simple profile should be
enough to replace the previous unconfined profile.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1624
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 11:02:32 +00: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
e6bedaac1d Merge parser: fix handling of norelatime mount rule flag
Specifying norelatime should set the corresponding MS_RELATIME flag clear
bit. Instead, it ORed in MS_NORELATIME, which expands to 0. Properly set
the clear bit by using MS_RELATIME.

Fixes: c9e31b7f "Add mount rules"

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1679
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 08:50:39 +00:00
John Johansen
e8d5401a18 Merge profiles: fix more wpa_supplicant denials
In particular, the dbus rules were completely rebuilt based on reading through wpa_supplicant's dbus source code.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1630
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 08:47:05 +00:00
John Johansen
717e019928 Merge abstractions/gnome: include abstractions/gtk
... and drop rules that are part of abstractions/gtk

Note that abstractions/gtk contains more than the rules dropped here,
which means it effectively extends the permissions granted by
abstractions/gnome.

Idea by darix.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1678
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 06:15:56 +00:00
John Johansen
3f37b671c3 Merge abstractions/mesa: more radv_builtin_shaders files
reported by darix

The initial radv_builtin_shaders rule was added in 4.1, therefore I propose this patch for at least 4.1 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1677
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 06:14:57 +00:00
John Johansen
b1097077f5 Merge abstractions/wutmp: allow access to lastlog2.db
Reported by darix, seen with comm="sshd-session"

I propose this for master and 4.x (optionally also 3.x even if it's less likely that systems using these branches already use lastlog2)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1676
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-05-08 06:14:26 +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
John Johansen
95036df4a1 Merge profiles: give iotop-c additional accesses
- iotop-c fails with permission errors in nl_init without network netlink
  raw.
- iotop-c also needs access to the iotop config directory instead of just
  the iotoprc file within.
- iotop-c uses CAP_SYS_NICE to set ionice values. For some reason, no
  audit log is generated without the capability present, but include it
  anyways in case this allowance is due to a parser or kernel bug that
  needs to be squashed later.


Fixes: https://bugs.launchpad.net/bugs/2107727

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1675
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 23:13:22 +00:00
John Johansen
4808e34257 Merge 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>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1681
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 23:08:00 +00:00
John Johansen
89c4ab100d Merge Improve compliance with C++ best practic and fix missing virtual dtor
Remove virtual from non-base class fns, as this can hide/make it hard to discover some bugs.
Add override to virtual fns that should be overriding, which helps catch certain class of bugs at compile time

fix(non-virtual-dtor): add missed virtual destructor

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1669
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 23:05:28 +00:00
John Johansen
330d202586 Merge branch 'master' into 'override'
# Conflicts:
#   parser/libapparmor_re/expr-tree.h
2025-05-07 23:04:59 +00:00
John Johansen
ec2549be2a Merge refactor(bison): replace deprecated name-prefix with %define api.prefix
%name-prefix is deprecated in Bison 2.6.  
<https://savannah.gnu.org/news/?id=7269>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1668
Approved-by: Ryan Lee <rlee287@yahoo.com>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 22:54:06 +00:00
John Johansen
b50ec6ca36 Merge fix: avoid using namespace std; in header files
using directive in a header file is a bad practice because it may lead
to unexpected results.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-using-directive

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1664
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 22:53:26 +00:00
John Johansen
e56751cec0 Merge binutils: Fix missing include limits.h
For NAME_MAX

Fixes 322a98c8 ("Fix incorrect strnlen length in aa_load.c load_policy_dir")

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1666
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 22:44:12 +00: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
09218c3d2f profiles: give iotop-c additional accesses
- iotop-c fails with permission errors in nl_init without network netlink
raw.
- iotop-c also needs access to the iotop config directory instead of just
  the iotoprc file within.
- iotop-c uses CAP_SYS_NICE to set ionice values. For some reason, no
  audit log is generated without the capability present, but include it
  anyways in case this allowance is due to a parser or kernel bug that
  needs to be squashed later.

Fixes: https://bugs.launchpad.net/bugs/2107727

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-07 10:21:58 -07:00
John Johansen
648336489e Merge parser: fix failure to properly apply deny clearing in perms accumulation
The internal permission accumulation is currently broken in that
the ordering of rules matter to whether deny is clearing accumulated
perms.

If a deny node comes before an allow node the deny bits will get set
but the following allow bits won't get cleared by the deny node.

This isn't currently an actual issue for mediation as the deny
bit will be applied at one of
  1. apply_and_clear_deny
  2. permission remapping
  3. run time mediation

but it does result in the internal state having sometimes having both
allow and deny bits set, dependent on order of computation, resulting
in state machines with different sizes because minimization
partitioning is based on the internal permissions.

This means that dfa minimization may not result in a truly minimal
state machine, and even worse can cause inconsistenty and failure in
tests that rely on internal state like the equality and minimization
test, as seen in https://gitlab.com/apparmor/apparmor/-/issues/513

The failure was due to musl stl sets implementation producing a
different ordering of the nodes than glibc. So when the permissions
where accumulated the internal set of permissions were different.

Fix this by giving the different node classes their own internal priority.
This will ensure the bits are properly cleared for that priority before
accumulating.

Note: other ways of fixing.

1. Fixup internal accumulation to use accumulating perms of "higher"
   priority as part of the mask (deny and allow mask prompt).
2. Do a hard masking apply at the end after all bits have been accumulated
   (ie, in accept_perms after the for loop).

the priority route was chosen because it is a little smaller and
scales better if we get new Node types we have to deal with
(eg. planned complain node).

BugLink: https://gitlab.com/apparmor/apparmor/-/issues/513
Fixes: 1ebd99115 ("parser: change priority so that it accumulates based on permissions")
Signed-off-by: John Johansen <john.johansen@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1655
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-07 08:42:52 +00:00
John Johansen
06e349345e parser: fix failure to properly apply deny clearing in perms accumulation
The internal permission accumulation is currently broken in that
the ordering of rules matter to whether deny is clearing accumulated
perms.

If a deny node comes before an allow node the deny bits will get set
but the following allow bits won't get cleared by the deny node.

This isn't currently an actual issue for mediation as the deny
bit will be applied at one of
  1. apply_and_clear_deny
  2. permission remapping
  3. run time mediation

but it does result in the internal state having sometimes having both
allow and deny bits set, dependent on order of computation, resulting
in state machines with different sizes because minimization
partitioning is based on the internal permissions.

This means that dfa minimization may not result in a truly minimal
state machine, and even worse can cause inconsistenty and failure in
tests that rely on internal state like the equality and minimization
test, as seen in https://gitlab.com/apparmor/apparmor/-/issues/513

The failure was due to musl stl sets implementation producing a
different ordering of the nodes than glibc. So when the permissions
where accumulated the internal set of permissions were different.

Fix this by giving the different node classes their own internal priority.
This will ensure the bits are properly cleared for that priority before
accumulating.

Note: other ways of fixing.

1. Fixup internal accumulation to use accumulating perms of "higher"
   priority as part of the mask (deny and allow mask prompt).
2. Do a hard masking apply at the end after all bits have been accumulated
   (ie, in accept_perms after the for loop).

the priority route was chosen because it is a little smaller and
scales better if we get new Node types we have to deal with
(eg. planned complain node).

BugLink: https://gitlab.com/apparmor/apparmor/-/issues/513
Fixes: 1ebd99115 ("parser: change priority so that it accumulates based on permissions")
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-05-07 01:41:59 -07:00
Ryan Lee
711bbac5eb parser: fix handling of norelatime mount rule flag
Specifying norelatime should set the corresponding MS_RELATIME flag clear
bit. Instead, it ORed in MS_NORELATIME, which expands to 0. Properly set
the clear bit by using MS_RELATIME.

Fixes: c9e31b7f "Add mount rules"

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-06 16:01:53 -07:00
Christian Boltz
89c1aac5af
abstractions/gnome: include abstractions/gtk
... and drop rules that are part of abstractions/gtk

Note that abstractions/gtk contains more than the rules dropped here,
which means it effectively extends the permissions granted by
abstractions/gnome.

Idea by darix.
2025-05-07 00:08:15 +02:00
Christian Boltz
521a81ebfb
abstractions/mesa: more radv_builtin_shaders files
reported by darix
2025-05-06 23:36:38 +02:00
Christian Boltz
f8532f2d20
abstractions/wutmp: allow access to lastlog2.db
Reported by darix, seen with comm="sshd-session"
2025-05-06 23:28:17 +02: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
Christian Boltz
e72ef56789 Merge profiles/apparmor.d: add ssh-keyscan profile
Add AA profile for ssh-keyscan. This profile has been tested on the latest plucky `ssh-agent` version `1:9.9p1-3ubuntu3`. In particular, this has been tested using the tests upstream and the archive in:

* `openssh-tests`

This is linked to the discussion in https://gitlab.com/apparmor/apparmor/-/merge_requests/1502, to add the profile deps of ssh-agent in as well.

Signed-off-by: Evan Caville <evan.caville@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1597
Approved-by: Ryan Lee <rlee287@yahoo.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-06 19:00:18 +00:00
Ryan Lee
1d7a9c6765 profiles: expand set of flags allowed for fusermount3
fuse_overlayfs requires noatime, but we should also allow more flags than
just that to preempt future breakage from flags not included in the rules.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-06 11:58:17 -07:00
Ryan Lee
7d33bde1ea Merge Split priority rules with unsafe keyword to separate tests
This helps to limit the amount of rules skipped in the utils tests
(because the utils don't support the `unsafe` keyword)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1671
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Ryan Lee <rlee287@yahoo.com>
2025-05-06 08:40:32 -07:00
John Johansen
62c3cf913a Merge fix incorrect mount flag documentation in apparmor.d man page
The documentation was wrong about how options=(list) and options in (list) are combined

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1674
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-06 02:24:17 +00:00
Ryan Lee
3b1819db37 fix incorrect mount flag documentation in apparmor.d man page
The documentation was wrong about how options=(list) and options in (list) are combined

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-05 17:16:06 -07:00
Evan Caville
004dc61959 profiles/apparmor.d: remove file access
Signed-off-by: Evan Caville <evan.caville@canonical.com>
2025-05-06 08:57:57 +10:00
Evan Caville
260ef98a95 profiles/apparmor.d: add ssh-keyscan profile
Signed-off-by: Evan Caville <evan.caville@canonical.com>
2025-05-06 08:57:57 +10:00
Christian Boltz
bd46a02e47 Merge parser: fix if condition at the bottom of equality.sh
The lack of a space after $testtype is a syntax error and was causing the
equality tests on Ubuntu Xenial to be silently skipped and marked PASS.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1670
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-05 19:03:34 +00:00
Christian Boltz
94c5cf047f
Split priority rules with unsafe keyword to separate tests
This helps to limit the amount of rules skipped in the utils tests
(because the utils don't support the `unsafe` keyword)
2025-05-05 20:53:53 +02:00
Christian Boltz
71ea87966a Merge utils: add support for priority rule prefix
Add basic support for the priority rules prefix. This patch does not\
allow the utils to set or suggest priorities. It allows parsing and\
retaining of the priority prefix if it already exists on rules and\
checking if it's in the supported range.

Note that this MR is supposed to replace WIP MR https://gitlab.com/apparmor/apparmor/-/merge_requests/1531

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1636
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-05 18:44:39 +00:00
John Johansen
c0fcd1698b utils: add support for priority rule prefix
Add basic support for the priority rules prefix. This patch does not
allow the utils to set or suggest priorities. It allows parsing and
retaining of the priority prefix if it already exists on rules and
checking if it's in the supported range.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-05-05 14:54:22 -03:00
Georgia Garcia
3389230437 utils: add allow keyword to list of unsupported modifiers
Some classes don't support modifiers like audit and deny. Only rlimit
has been checking for the allow keyword, but the others shouldn't
support it as well. Since they all do the same check, refactor them
into a method from BaseRule in case more modifiers are added.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-05 14:54:22 -03:00
Ryan Lee
17ee87ad6b parser: fix if condition at the bottom of equality.sh
The lack of a space after $testtype is a syntax error and was causing the
equality tests on Ubuntu Xenial to be silently skipped and marked PASS.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-05 10:12:29 -07:00
Eisuke Kawashima
5526138483
fix(inconsistent-missing-override): add missed override specifiers 2025-05-05 17:52:52 +09:00
Eisuke Kawashima
18c0d003ef
fix(non-virtual-dtor): add missed virtual destructor 2025-05-05 17:52:48 +09:00
Eisuke Kawashima
9c6ae3cf5c
refactor(bison): replace deprecated name-prefix with %define api.prefix
%name-prefix is deprecated in Bison 2.6.
https://savannah.gnu.org/news/?id=7269
2025-05-05 17:47:29 +09:00
Christian Boltz
87e5a34252 Merge chore: fix vim modelines
A modeline must appear in the first and last five (by default) lines of a file

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1661
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-04 21:42:34 +00:00
Eisuke Kawashima
7d5a021023
fix: avoid using namespace std; in header files
using directive in a header file is a bad practice because it may lead
to unexpected results.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-using-directive
2025-05-04 23:14:36 +09: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
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