Commit graph

6935 commits

Author SHA1 Message Date
John Johansen
3c24bc68b6 Merge fix regression test failures for when /tmp is mounted as tmpfs
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1283
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 1fc944bb67)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-08-05 09:15:36 -07:00
John Johansen
0193009b8b Merge libapparmor: fix undefined reference to aa_split_overlay_str
The linkage of aa-load with the dynamic libapparmor fails with:
aa_load.c:273: undefined reference to `aa_split_overlay_str'

That is because when aa_split_overlay_str was added to libapparmor,
the function was not added to the library map.

Fixes: 50054ff0 ("add aa_split_overlay_str")
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1288
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit ed3bc55d35)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-08-05 09:11:29 -07:00
John Johansen
84a6bc1b6d Prepare for AppArmor 4.0.1 release
- update version file
- update library version. addition of saddr/... parsing extends the
  record struct which is an interface addition.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-23 16:02:50 -07:00
John Johansen
9f849247b9 Merge [4.0] MqueueRule: allow / as mqueue name
... and not only `/something`

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/413#note_2008929033

This is the 4.0 version of https://gitlab.com/apparmor/apparmor/-/merge_requests/1278

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1279
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2024-07-22 01:48:12 +00:00
Christian Boltz
3fe2d323fc
MqueueRule: allow / as mqueue name
... and not only `/something`

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/413#note_2008929033
(cherry picked from commit 02edb649fa)
2024-07-21 19:13:50 +02:00
Christian Boltz
f0f7420f6c
test-mqueue: table-format MessageQueueTestParse
(cherry picked from commit 93870323a0,
 adjusted to 4.0 branch)
2024-07-21 19:13:29 +02:00
Georgia Garcia
efef7d1b28 Merge Add fcitx5 dbus interface to fcitx abstraction
Similar reference in snapd https://github.com/snapcore/snapd/pull/12924

Reference upstream implementation:

https://github.com/fcitx/fcitx/blob/master/src/frontend/ipcportal/ipcportal.h
https://github.com/fcitx/fcitx5/blob/master/src/frontend/dbusfrontend/dbusfrontend.cpp

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1222
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit e1de0bb5d5)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-21 01:56:21 -07:00
John Johansen
d61109d47e Merge profiles: Add userns stub for Chromium and variants
This gets `chromium` and `ungoogled-chromium` working again on Ubuntu 24.04; see discussion [here](#394).

Bug: https://gitlab.com/apparmor/apparmor/-/issues/394
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1238
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit ca03f69e64)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-21 01:53:55 -07:00
John Johansen
113ce2cfcd Merge parser: make lead # in assignment value indicate a comment
technically a # leading a value in an assignment expression is allowed,
however people are also using it to a comment at the end of a line.
ie.

```
  @{var1}=value1    # comment about this value or for a given system
```

this unsurprisingly leads to odd/unexpected behavior when the variable
is used.

```
  allow rw /@{var1},
```

expands into

```
  allow rw /{value1,#,comment,about,this,value,or,for,a,given,system},
```

change a leading # of a value in an assignment expression to a comment.
If the # is really supposed to lead the value, require it to be escaped
or in quotes.
ie.

```
  @{var1}=value1 \#not_a_comment
```

Note: this could potentially break som policy if the # was used as the
      leading character for a value in an assignment expression, but
      is worth it to avoid the confusion.

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

Bug: https://gitlab.com/apparmor/apparmor/-/issues/407
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1255
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 642db8a37c)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-21 01:48:21 -07:00
John Johansen
af7a10b5d9 Merge parser: ensure mqueue obeys abi
The abi is not being respected by mqueue rules in many cases. If policy
does ot specify an mqueue rule the abi is correctly applied but if
an mqueue rule is specified explicitly or implicitly (eg. allow all).
without setting the mqueue type OR setting the mqueue type to sysv.
The abi will be ignored and mqueue will be enforced for policy regadless.

Known good mqueue rule that respects abi
  mqueue type=posix,

  # and all variations that keep type=posix

Known bad mqueue rules that do not respect abi

  mqueue,
  # and all variants that do not specify the type= option

  mqueue type=sysv,
  # and all variants that specify the type=sysv option

Issue: https://gitlab.com/apparmor/apparmor/-/issues/412
Fixes: d98c5c4cf ("parser: add parser support for message queue mediation")

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1277
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit d0d75abd02)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-21 01:42:32 -07:00
John Johansen
4bb134e4bb Merge parser: don't add mediation classes to unconfined profiles
Adding mediation classes in unconfined profiles caused nested profiles
to be mediated, inside a container for example.

Fixes: https://bugs.launchpad.net/apparmor/+bug/2067900

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1247
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 0d9d548694)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-18 05:58:11 -07:00
John Johansen
4569381ec3 Merge profiles: add mediate_deleted to bwrap
Some applications using the bwrap profile don't function properly due to "Failed name lookup - deleted entry". The following denials trying to start flatpak KeePassXC is an example showing that it happens for both bwrap and unpriv_bwrap profiles:

Jul 12 09:44:37 ubuntu2404 kernel: audit: type=1400 audit(1720741477.106:310): apparmor="DENIED" operation="link" class="file" info="Failed name lookup - deleted entry" error=-2 profile="bwrap" name="/home/\*\*\*\*/.var/app/org.keepassxc.KeePassXC/config/keepassxc/#317211" pid=4021 comm="keepassxc" requested_mask="l" denied_mask="l" fsuid=1000 ouid=1000

Jul 12 09:44:37 ubuntu2404 kernel: audit: type=1400 audit(1720741477.341:317): apparmor="DENIED" operation="link" class="file" profile="unpriv_bwrap" name="/home/**/.var/app/org.keepassxc.KeePassXC/config/keepassxc/keepassxc.ini" pid=4021 comm="keepassxc" requested_mask="l" denied_mask="l" fsuid=1000 ouid=1000 target="/home/**/.var/app/org.keepassxc.KeePassXC/config/keepassxc/#317214"

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

I propose this fix for master and apparmor-4.0

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1272
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 7f35adef41)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-18 05:47:10 -07:00
John Johansen
73a29ade16 Merge parser: fix unix for all rule
By specifying 0 in the unix type, all rules were allowing only the "none" type, when it wanted to allow all types, so replace it by 0xffffffff. Also, add this testcase to the unix regression tests.

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

I propose this fix for master and apparmor-4.0

Closes #410
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1273
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 5b44e33d25)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-18 05:44:22 -07:00
John Johansen
d8e17207e8 Merge firefox: allow /etc/writable/timezone and update UPower DBus access
Saw these couple of accesses fail recently on my Ubuntu 22.04 system:

`Jun  3 15:29:24 darkstar kernel: [5401883.070129] audit: type=1107 audit(1717442964.884:9223): pid=729 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/UPower" interface="org.freedesktop.DBus.Properties" member="GetAll" mask="send" name=":1.28" pid=2164500 label="firefox" peer_pid=2502 peer_label="unconfined"`

`Jun  3 15:29:24 darkstar kernel: [5401883.070588] audit: type=1107 audit(1717442964.884:9224): pid=729 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/UPower" interface="org.freedesktop.UPower" member="EnumerateDevices" mask="send" name=":1.28" pid=2164500 label="firefox" peer_pid=2502 peer_label="unconfined"`

Also, I noticed that the `firefox` profile in the Ubuntu 24.04 package has a rule for `/etc/writable/timezone` that is not present in Git. Figured that should be in here.

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

Closes #409
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1253
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 09d8f886ca)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-17 01:39:42 -07:00
John Johansen
0f51513a11 Merge samba-dcerpcd: allow to execute rpcd_witness
... and extend the samba-rpcd profile to also include rpcd_witness.

Patch by Noel Power <nopower@suse.com>

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1225811

I propose this patch for 3.x, 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1256
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 899c0b3942)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-17 01:31:26 -07:00
John Johansen
a07a8e69e0 Merge utils: Ignore/skip disabled profiles
This is needed to avoid a "Conflicting profiles" error if there are two
profiles for an application, with one of them disabled.

This is not a theoretical usecase - for example, apparmor.d ships some
profiles that replace our "userns+unconfined" profiles. These profiles
use a different filename, and apparmor.d also creates a disable symlink
for the "userns+unconfined" profile it replaces.

I propose this patch for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1264
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 834c28b5fe)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-17 01:25:26 -07:00
Christian Boltz
24a0ebb5ef Merge aa-notify: fix translation of an error message
... which so far was not translatable because it was formatted before
being translated.

I propose this fix for master, 4.0 and 3.x

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1271
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 67021bf911)

c85958da aa-notify: fix translation of an error message

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-07-15 19:27:29 +00:00
Christian Boltz
0310a122d4 Merge abstractions/wutmp: allow writing wtmpdb
/var/lib/wtmpdb/ contains the Y2038-safe version of wtmpdb.

Proposed by darix.

I propose this patch for master, 4.0 and 3.x.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1267
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 728e0ab1b7)

da9a3bd3 abstractions/wutmp: allow writing wtmpdb

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-07-11 12:04:34 +00:00
Christian Boltz
6cad7b889e Merge ask_exec: ignore events for missing profiles
... and not only for events in missing hats.

This fixes a crash if the log contains exec events for a hat where not
even the parent profile exists.

I propose this patch for master, 4.0 and 3.1.

(In 3.0, `aa` is still a `hasher` which avoids the crash, therefore it doesn't really need this patch.)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1265
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 3ea19d5f32)

7928c416 ask_exec: ignore events for missing profiles

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-07-11 12:03:36 +00:00
John Johansen
e2aff72f53 Merge test-logprof: increase timeout
... so that slow test environments don't fail.

Fixes: https://bugs.launchpad.net/ubuntu-kernel-tests/+bug/2062138

I propose this fix for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1268
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 0785006b41)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-07-07 05:40:17 -07:00
Christian Boltz
046fe9c1bd Merge [4.0] MountRule: add support for quoted paths and empty source
* MountRule: add support for quoted paths

While on it, make the output for failing tests more verbose for easier debugging.

* MountRule: Add support for empty ("") source

This needs adding of an empty_ok flag in \_aare_or_all().

Also add a few tests from boo#1226031 to utils and parser tests.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1226031

This is the 4.0 version of https://gitlab.com/apparmor/apparmor/-/merge_requests/1258 (test-mount.py had a few merge conflicts)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1259
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2024-06-20 20:46:35 +00:00
John Johansen
e4e60f1a4f Merge parser: fix Normalizatin infinite loop
Expression simplification can get into an infinite loop due to eps
pairs hiding behind and alternation that can't be caught by
normalize_eps() (which exists in the first place to stop a similar
loop).

The loop in question happens in AltNode::normalize when a subtree has
the following structure.

1. elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                   alt
                   /\
                  /  \
                 /    \
               eps    alt
                      /\
                     /  \
                    /    \
                  alt    eps
                  /\
                 /  \
                /    \
               eps   eps

2. if (normalize_eps(dir)) results in

                   alt
                   /\
                  /  \
                 /    \
               alt    eps
               /\
              /  \
             /    \
           alt    eps
           /\
          /  \
         /    \
       eps   eps

3. elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                   alt
                   /\
                  /  \
                 /    \
               alt    alt
              /\        /\
             /  \      /  \
            /    \    /    \
          eps    eps eps   eps

4. elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                   alt
                   /\
                  /  \
                 /    \
               eps    alt
                      /\
                     /  \
                    /    \
                  eps    alt
                         /\
                        /  \
                       /    \
                     eps   eps

5. if (normalize_eps(dir)) results in

                  alt
                   /\
                  /  \
                 /    \
                alt   eps
                /\
               /  \
              /    \
            eps    alt
                    /\
                   /  \
                  /    \
                 eps   eps

6. elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                  alt
                   /\
                  /  \
                 /    \
                eps   alt
                       /\
                      /  \
                     /    \
                    alt  eps
                    /\
                   /  \
                  /    \
                eps   eps

back to beginning of cycle

Fix this by detecting the creation of an eps_pair in rotate_node(),
that pair can be immediately eliminated by simplifying the tree in that
step.

In the above cycle the pair creation is caught at step 3 resulting
in

3. elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                   alt
                   /\
                  /  \
                 /    \
               alt    eps
               /\
              /  \
             /    \
           eps    eps

4.  elseif (child[dir]->is_type(ALT_NODE)) rotate_node too

                   alt
                   /\
                  /  \
                 /    \
               eps   alt
                      /\
                     /  \
                    /    \
                  eps    eps

which gets reduced to

                   alt
                   /\
                  /  \
                 /    \
               eps   eps

breaking the normalization loop. The degenerate alt node will be caught
in turn when its parent is dealt with.

This needs to be backported to all releases

Closes: https://gitlab.com/apparmor/apparmor/-/issues/398
Fixes: 846cee506 ("Split out parsing and expression trees from regexp.y")
Reported-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>

Closes #398
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1252
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit a6691ca53e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-06-14 12:41:26 -07:00
Christian Boltz
ae01582798 Merge abstractions/X: add another xauth path
This time it's   /tmp/xauth_?????? r,   which gets used by latest sddm.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1223900

I propose this fix for 4.0 and master, optionally also for 3.x.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1249
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 121dbec671)

0c6e031c abstractions/X: add another xauth path

Co-authored-by: John Johansen <john@jjmx.net>
2024-06-11 11:37:47 +00:00
Christian Boltz
98a0a2fee9
MountRule: Add support for empty ("") source
This needs adding of an empty_ok flag in _aare_or_all().

Also add a few tests from boo#1226031 to utils and parser tests.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1226031

(cherry picked from commit 1f33fc9b29,
test-mount.py changes adjusted for 4.0 branch)
2024-06-11 13:36:24 +02:00
Christian Boltz
aada708bc1
MountRule: add support for quoted paths
While on it, make the output for failing tests more verbose for easier
debugging.

(cherry picked from commit 900f233101,
test-mount.py adjusted for 4.0 branch)
2024-06-11 13:36:21 +02:00
John Johansen
dca6ac3b73 Merge Partial revert of "libapparmor: add log parser support for saddr, daddr, src and dest"
This partially reverts commit d1311cc93f.

During the cherry-pick, I incorrectly assumed the patches for fine
grained support of network rules from MR
https://gitlab.com/apparmor/apparmor/-/merge_requests/1216 were part
of apparmor-4.0, therefore the test cases added in commit d1311cc93f
fail.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1250
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2024-06-11 06:26:36 +00:00
Christian Boltz
9d1388fdb6 Merge aa-teardown: print out which profile removal failed
This is a follow-up of https://gitlab.com/apparmor/apparmor/-/merge_requests/1242
to make it easier to identify failures.

I propose this patch for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1257
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 5ab0d205af)

bc4ddd5f aa-teardown: print out which profile removal failed

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-06-10 21:48:50 +00:00
Christian Boltz
a8637a5aa1 Merge Honor global CFLAGS when building Python library
Similarly to https://gitlab.com/apparmor/apparmor/-/merge_requests/689, use the
global CFLAGS when building Python library, so we honor extra flags set by
distributions, such
as -fstack-protector-strong -fstack-clash-protection -Werror=format-security -fcf-protection.

Spotted by blhc on Debian.

Gbp-Pq: Name Honor-global-CFLAGS-when-building-Python-library.patch

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1254
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 1ec42d8bec)

b7d75638 Honor global CFLAGS when building Python library

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-06-07 21:55:12 +00:00
Christian Boltz
a866d77e72 Merge profiles: installation of php-fpm needs w @{run}/systemd/notify
Installation of php-fpm fails on Ubuntu because the profile does not allow writing to /run/systemd/notify.

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

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

I propose this fix for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1251
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 70ddb0ca5b)

49aa7ae3 profiles: installation of php-fpm needs w @{run}/systemd/notify

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-06-05 16:56:48 +00:00
Georgia Garcia
527205bda9 Partial revert of "libapparmor: add log parser support for saddr, daddr, src and dest"
This partially reverts commit d1311cc93f.

During the cherry-pick, I incorrectly assumed the patches for fine
grained support of network rules from MR
https://gitlab.com/apparmor/apparmor/-/merge_requests/1216 were part
of apparmor-4.0, therefore the test cases added in commit d1311cc93f
fail.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-06-04 18:36:14 -03:00
Georgia Garcia
e3be2e52ea Merge profiles: fix location for wike profile and add unconfined profile for balena-etcher
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1221
Approved-by: John Johansen <john@jjmx.net>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit d605463b66)

a5a1ecfe profiles: fix wike profile location to apparmor.d
70125895 profiles: add unconfined balena-etcher profile

Co-authored-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-06-04 20:54:53 +00:00
Georgia Garcia
d1311cc93f libapparmor: add log parser support for saddr, daddr, src and dest
saddr, daddr, src and dest are used in network logs

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit 6774654424)
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/397
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-06-04 17:42:21 -03:00
Christian Boltz
2a3cf471ab apparmor.vim: add support for userns and the unconfined flag
(cherry picked from commit 4cd39e70a0)
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/396
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-06-04 17:41:29 -03:00
Christian Boltz
c31da2ec55 Merge utils: fix removing unknown profiles that contain spaces
aa-remove-unknown doesn't deal properly with profiles that contain
spaces in their names.

Using profile "MongoDB Compass" as an example, awk's sub returns the
number of matches - either 1 or 0 and replaces the actual string ($0)
with the substitution.  By accessing the return of sub with $, awk
would be accessing $1 which would return only "MongoDB".
Fix this by using $0 instead of $str.

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

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

Closes #395
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1243
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 920120ffea)

7ef7704f utils: fix removing unknown profiles that contain spaces

Co-authored-by: John Johansen <john@jjmx.net>
2024-06-04 20:36:10 +00:00
Christian Boltz
e8b2597676 Merge Fix aa-teardown for unconfined profiles
Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1225457

I propose this patch for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1242
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 81a08ab1ee)

f497afbe Fix aa-teardown for `unconfined` profiles

Co-authored-by: John Johansen <john@jjmx.net>
2024-06-04 20:35:41 +00:00
Christian Boltz
6dee9d0a6a Merge Add openSUSE path to plasmashell profile
While on it,
- add some comments explaining what the profile does
- adjust the rule with the Debian/Ubuntu path to work with Qt6

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1225961

I propose this fix for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1248
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit a6a121144b)

64469afa Add openSUSE path to plasmashell profile

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-06-04 19:38:07 +00:00
Christian Boltz
aa74b9b12d Merge abstractions/nameservice: allow reading @{PROC}/@{pid}/net/ipv6_route
This file contains the same kind of information as @{PROC}/@{pid}/net/route
and both files are world readable:

```
$ ls -l /proc/self/net/*route
-r--r--r-- 1 root root 0 Jun  3 15:33 /proc/self/net/ipv6_route
-r--r--r-- 1 root root 0 Jun  3 15:33 /proc/self/net/route
```

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1246
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 5adeb86bbe)

7770cd71 abstractions/nameservice: allow reading @{PROC}/@{pid}/net/ipv6_route

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-06-03 20:06:34 +00:00
Georgia Garcia
9ec5134322 Merge Fix aa-remove-unknown for 'unconfined' profiles
Without this patch, aa-remove-unknown uses 'profile_name (unconfined)'
when trying to unload unconfined profiles, which fails for obvious
reasons with (picking a random example)

    Removing 'busybox (unconfined)'
    /sbin/aa-remove-unknown: line 112: echo: write error: No such file or directory

I propose this patch for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1240
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit cf5be7d356)

cabd88a9 Fix aa-remove-unknown for 'unconfined' profiles

Co-authored-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-05-28 19:17:53 +00:00
Georgia Garcia
fcd02fb69b Merge Cherry-pick: MountRule: Aligning behavior with apparmor_parser
Mount Rules with options in { remount, [make-] { [r]unbindable, [r]shared, [r]private, and [r]slave }} do not support specifying a source. This commit aligns utils implementation to apparmor_parser's, which prohibits having a both source and a destination simultaneously, instad of just prohibiting source.

Therefore, both `mount options=(unbindable) /a,` and `mount options=(unbindable) -> /a,` are now supported (and equivalent for apparmor_parser). However, `mount options=(unbindable) /a -> /b,` is invalid.

For the same reason, specifying a fstype in these cases is also prohibited.

Similarly, we prohibit to specify a fstype for bind mount rules.

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

(cherry picked from commit 60acc4a405)

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1237
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-05-22 12:34:01 +00:00
Maxime Bélair
1f4bba0448 Cherry-pick: MountRule: Aligning behavior with apparmor_parser
Mount Rules with options in { remount, [make-] { [r]unbindable, [r]shared, [r]private, and [r]slave }} do not support specifying a source. This commit aligns utils implementation to apparmor_parser's, which prohibits having a both source and a destination simultaneously, instad of just prohibiting source.

Therefore, both `mount options=(unbindable) /a,` and `mount options=(unbindable) -> /a,` are now supported (and equivalent for apparmor_parser). However, `mount options=(unbindable) /a -> /b,` is invalid.

For the same reason, specifying a fstype in these cases is also prohibited.

Similarly, we prohibit to specify a fstype for bind mount rules.

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

(cherry picked from commit 60acc4a405)

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2024-05-22 08:31:27 +02:00
Christian Boltz
af88a13712 Merge Include abi/4.0 when creating a new profile
... with aa-genprof or aa-autodep

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

I propose this patch for 4.0 and master.

Closes #392
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1231
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 74316fe152)

6c8ef381 Include abi/4.0 when creating a new profile

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-05-14 19:11:24 +00:00
Georgia Garcia
8e74855531 Merge Handle mount events/log entries without class
audit.log entries for mount events don't always include `class=mount`,
but can still be the base for mount rules.

Change logparser.py to also consider `operation=mount` as a mount event.

Actually we already had such a log and profile in our collection
(testcase_mount_01), but since it existed years before MountRule was
implemented, it was excluded in test-libapparmor-test_multi.py.
Therefore we didn't notice that it failed to produce a profile rule when
MountRule was introduced.

Remove testcase_mount_01 from the list of known failures so that it gets
tested - and fix the syntax error in the hand-written
testcase_mount_01.profile.

Also add testcase_mount_02 which is a mount event without fstype,
srcname and class.

I propose this fix for 4.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1229
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit 48a936e985)

b475ed0d Handle mount events/log entries without class

Co-authored-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-05-10 12:31:41 +00:00
John Johansen
951ea5b2fb Merge Cherry-pick: MountRule: Relaxing constraints on fstype and completing AARE support
- Before this commit, fstype had to match a known fs. However, having and maintaining the exhaustive list of fstypes proved challenging (see !1195 and !1176). Therefore, we add support for any filesystem name.
 - Completing AARE support for fstype (brace expressions like ext{3,4} are now supported).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1198
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit baa8b67248)

dad5ee28 MountRule: Relaxing constraints on fstype and completing AARE support

Co-authored-by: Christian Boltz <apparmor@cboltz.de>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1228
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2024-05-08 13:23:15 +00:00
Georgia Garcia
eee50538da Merge MountRule: Relaxing constraints on fstype and completing AARE support
- Before this commit, fstype had to match a known fs. However, having and maintaining the exhaustive list of fstypes proved challenging (see !1195 and !1176). Therefore, we add support for any filesystem name.
 - Completing AARE support for fstype (brace expressions like ext{3,4} are now supported).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1198
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit baa8b67248)

dad5ee28 MountRule: Relaxing constraints on fstype and completing AARE support

Co-authored-by: Christian Boltz <apparmor@cboltz.de>
2024-05-08 12:58:42 +00:00
Christian Boltz
86be5d35f3
util/test/: Don't rely on argparse saying "options:"
Some argparse versions (for example on openSUSE Leap 15.5) instead say
"optional arguments:"

Don't rely on the "options:" line to allow both wordings.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1226
Approved-by: Steve Beattie <steve+gitlab@nxnw.org>
Cherrypicked-by: Steve Beattie <steve+gitlab@nxnw.org>
2024-05-06 12:24:32 +02:00
Georgia Garcia
b7f9b66cba Merge gitlab-ci.yml: fix pipeline for ubuntu:latest (noble)
Since we are using ubuntu:latest, and noble was released, some tests
are failing.

shellcheck needs python3 to run, which was possibly installed by
default in previous ubuntu images and is no longer the case.

Ignore dist-packages python files during our coverage tests.

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

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

Closes #388
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1223
Merged-by: Steve Beattie <steve+gitlab@nxnw.org>


(cherry picked from commit 8c9ac7a84e)

731880de gitlab-ci.yml: fix pipeline for ubuntu:latest (noble)
aaad725a apparmor.systemd: fix shellcheck false positive

Co-authored-by: Steve Beattie <steve+gitlab@nxnw.org>
2024-05-02 13:37:53 +00:00
John Johansen
6d1e5dbbe6 Merge profiles: add fixes for samba from issue #386
Signed-off-by: Alex Murray <alex.murray@canonical.com>

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/386
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1219
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 1457eada8b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-04-23 07:36:08 -07:00
John Johansen
f1173379ff Merge Fix redefinition of _
... which unsurprisingly broke using the translations.

This was a regression introduced in 4f51c93f9d

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

This fix is needed in 4.0 and master. (3.x branches are not affected.)

Closes #387
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1218
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit 79226675fd)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-04-22 16:42:13 -07:00
John Johansen
b0eb95457b Prepare for AppArmor 4.0.1 release
AppArmor 4.0.1 will be the official release superseding the 4.0.0 tag
the only change being it adds a regression test for CVE-2016-1585

- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-04-11 20:59:30 -07:00
John Johansen
5ad4efec50 Merge regression tests: add mount test for CVE-2016-1585
Add infrastructure for calling the mount test binary with an fstype
instead of using the default hardcoded ext2 type, and then use that in a
test that exercises CVE-2016-1585, ensuring that mounting a procfs
filesystem isn't permitted when the only mount rule is

  mount options=(rw,make-slave) -> **,

to try to ensure that the generated and enforced policy is restricted to
what is intended.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Bug: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1597017

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1211
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 93c4c6fb9f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-04-11 20:58:31 -07:00