5476 Commits

Author SHA1 Message Date
Michael Vogt
71206e030a Merge pull request #11794 from jhenstridge/removable-media-exec
interfaces: allow map and execute permissions for files on removable media
2022-05-18 14:41:05 +02:00
Alberto Mardegan
8267fc510d Merge pull request #11704 from mardy/apparmor-sandbox-profile-mocking
tests: Apparmor sandbox profile mocking
2022-05-18 10:56:23 +03:00
Michael Vogt
56ce525eef Merge pull request #11705 from Meulengracht/feature/interface-extra-layout
interfaces,overlord: add support for adding extra mount layouts
2022-05-18 09:36:45 +02:00
James Henstridge
d5e8e041cf interfaces: allow map and execute permissions for files on removable media 2022-05-18 12:51:34 +08:00
Michael Vogt
39c968886f Merge pull request #11720 from Saviq/patch-1
interfaces: fix opengl interface on RISC-V
2022-05-17 12:57:45 +02:00
Michael Vogt
63aae2f30e Merge pull request #11713 from bugraaydogar/baydogar-crytosetup
interfaces: allow access to the file locking for cryptosetup in the dm-crypt interface
2022-05-17 12:57:15 +02:00
Michael Vogt
e382e2ccf5 Merge pull request #11734 from IsaacJT/network-manager-bridge
interfaces: network-manager: add AppArmor rule for configuring bridges
2022-05-17 12:37:12 +02:00
Michael Vogt
f0ecac51b4 Merge pull request #11777 from alfonsosanchezbeato/add-thermal
i/b/hardware-observe.go: add access to the thermal sysfs
2022-05-17 12:37:01 +02:00
Michael Vogt
186d770d58 Merge pull request #11789 from IsaacJT/opengl-add-imx-gpu
interfaces: opengl: add rules for NXP i.MX GPU drivers
2022-05-17 12:36:51 +02:00
Maciej Borzecki
55986868cb Merge remote-tracking branch 'upstream/master' into apparmor-sandbox-profile-mocking 2022-05-17 12:28:13 +02:00
Maciej Borzecki
669e7e86c8 Merge pull request #11774 from mardy/mount-interface-fixes
i/b/mount_control: add an optional "/" to the mount target rule
2022-05-17 11:55:33 +02:00
Isaac True
4bfab6e04b interfaces: opengl: add reference to the NXP GPU drivers
Signed-off-by: Isaac True <isaac.true@canonical.com>
2022-05-16 15:12:56 +01:00
Buğra Aydoğar
f3966b24b3 interfaces: allow access to the file locking mechanism for cryptosetup 2022-05-16 16:36:58 +03:00
Philip Meulengracht
feb872cd92 interfaces/apparmor: review feedback 2022-05-16 09:01:57 +02:00
Michael Vogt
737258a94d Merge pull request #11762 from mvo5/interface-posix-mq-small-tweaks
interfaces: tweak getPath() slightly and add some more tests
2022-05-13 17:17:30 +02:00
Isaac True
491cf158b9 interfaces: opengl: add rules for NXP i.MX GPU drivers
This adds the appropriate AppArmor and UDEV rules and accompanying tests
for using the GPU on NXP i.MX platforms that use the Vivante GPU
driver.

Signed-off-by: Isaac True <isaac.true@canonical.com>
2022-05-13 13:18:40 +01:00
Miguel Pires
40009e30bb Merge pull request #11759 from stgraber/master
interfaces: Allow locking in block-devices
2022-05-11 12:16:30 +01:00
Alfonso Sánchez-Beato
223539666d i/b/hardware-observe.go: add access to the thermal sysfs
Allow read access to the thermal sysfs from the hardware-observe
interface. See Documentation/driver-api/thermal/sysfs-api.rst in the
kernel for reference.
2022-05-11 11:11:41 +02:00
Alberto Mardegan
a10ecaaaaf i/b/mount_control: add an optional "/" to the mount target rule
AppArmor is very strict when it comes to specifying the target of a
mount rule: when the mount refers to a directory, the target *must* end
with a "/", or AppArmor will block the operation. We did not catch this
in our tests because we have always been ending our "where" attributes
with a "**", that also matches slashes.

So, we update the rule to allow for an optional "/" at the end of the
mount target specification; note that our regular expression for the
validation of the mount target attribute is written in such a way that
an ending slash is not allowed. For the time being this seems proper,
because we don't want to expose this subtlety to the developer.
2022-05-11 09:40:49 +03:00
Michael Vogt
d6d8b66ab0 interfaces: use buildin attrs.Attr() helper instead of manual error checking (thanks Alberto) 2022-05-06 13:52:32 +02:00
Michael Vogt
7129752a80 interfaces: tweak getPath() slightly and add some more tests
This is a small followup for PR#11590 - it makes the code in
getPath() a bit more linear and adds some more tests for (uncommon)
error conditions. A small typo in `validatePath()` was found and
fixed this way too.
2022-05-06 08:10:57 +02:00
Isaac True
15e53b3712 interfaces: posix-mq: add new interface
* interfaces: posix-mq: add new interface

- Add support for a new posix-mq interface, including AppArmor and seccomp
  rules. This allows creating, sending, and receiving IPC messages over POSIX
  message queues between snaps.
- Remove commented out seccomp rules for POSIX message queues in template.go

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: updated static information

- Added a declaration for plugs to allow snaps from the same publisher to automatically connect
- Added slot declaration to static information
- Changed slot to disallow auto connections by default
- Allow slot installation for all snap types
- Remove implicit interfaces

Signed-off-by: Isaac True <isaac.true@canonical.com>

* apparmor: add feature detection for POSIX message queues

Check if the AppArmor implementation supports the "mqueue" keyword.

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: extend validation and testing

- Permissions are now also validated in the BeforePrepare* functions
- Check if the AppArmor system supports the mqueue feature
- Extend unit tests to also check that unwanted permissions are not included
- Additionally change mq_notify syscall to be included when the read permission is used

Signed-off-by: Isaac True <isaac.true@canonical.com>

* apparmor: update unit tests to include mqueue feature detection

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: extend MQ path validation

- Ensure the given path is not an AppArmor regex and is a clean path
- Surround the path with quotes in the AppArmor rule
- Update unit tests to with the new validation

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: remove unneeded aliases

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: mark slot as super-privileged

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: update path handling

- If the path does not begin with '/', add a '/'
- Use the name of the slot as the path if no path has been given

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: remove get/setattr

These permissions are not supported by AppArmor

* interfaces: posix-mq: remove redundant connected slot rule

Additionally added indenting the AppArmor rules

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: add open permission

* interfaces: posix-mq: update AppArmor snippet generation

- The permanent slot snippet is now generated from the complete list of
  available permissions, rather than hard-coded specific permissions.
- Append open to the connected plug permissions array rather than directly
  entering it into the snippet.
- Update unit tests to reflect new changes.

Signed-off-by: Isaac True <isaac.true@canonical.com>

* tests: add posix-mq to interfaces-many-snap-provided

* interfaces: posix-mq: replace function with strutil.ListContains

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: mock AppArmor feature in unit tests

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: add posix-mq test cases to base declaration tests

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: change test variable names to reflect test cases

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: improve comments and error messages

- Remove slot name from error messages
- Standardise comment format
- Additionally remove permission validation from BeforePreparePlug as the permissions are configured in the slot

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: add additional unit tests and rework permission parsing

- Test to ensure that the path attribute is a string
- Test that the permissions attribute only contains valid permissions
- Add functionality and unit test to ensure that the permissions attribute is a list of strings

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: rename path attribute to "posix-mq"

This change brings the interface in line with other interfaces which
also use paths.

Signed-off-by: Isaac True <isaac.true@canonical.com>

* Revert "interfaces: posix-mq: rename path attribute to "posix-mq""

This reverts commit 47b9e5f72a84b085784c6e21eeadf4adb26978b5.

* interfaces: posix-mq: add "posix-mq" label attribute

This adds an additional attribute called "posix-mq" which can be used to
help identify which plugs should connect to which slots, similar to the
`shared-memory` interface.

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: validate posix-mq attribute in BeforePreparePlug

Additionally add more unit tests to validate posix-mq label handling.

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: improve unit tests by checking for explicit errors

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: various code cleanups to improve readability

Signed-off-by: Isaac True <isaac.true@canonical.com>

* interfaces: posix-mq: fix unit test not being run

- Additionally check for an explicit error

Signed-off-by: Isaac True <isaac.true@canonical.com>

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2022-05-06 08:07:22 +02:00
Stephane Graber
4601a4221e interfaces: Allow locking in block-devices
This is needed for microceph as ceph-osd requires locking the block
device it's using. As that's a pretty common pattern for software
writing to block devices, it's reasonable to just extend the existing
interface to allow it.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-05-05 10:54:18 +02:00
Maciej Borzecki
7b3c762b13 interfaces/apparmor: allow executing /usr/bin/numfmt in the base template
Numfmt is a tool for formatting numbers. It should be allowed by the base
template.

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

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-05-04 08:39:41 +02:00
James Henstridge
eaad8a23df interfaces: add a steam-support interface (#11708)
This interface is intended to provide some additional permissions needed by the steam snap.

At present, this is primarily AppArmor and seccomp rules to allow Steam to launch pressure-vessel containers, which it uses to provide a consistent runtime environment to some games (at the moment mainly Windows games it runs under Proton/Wine). PV is based on Bubblewrap, as used by Flatpak and various other process sandboxes on GNOME systems.

Related to getting Steam games to run, I've added the futex_waitv syscall to the base template. Although the Ubuntu kernels don't yet support this syscall, we want to let Proton try to call it so it will fall back to the old futex API. As this has essentially the same security concerns as the existing futex syscalls, it seemed sensible to add it to the base template rather than the steam-support interface.

snap-seccomp knows about this syscall as of 15th April, when PR #11674 was merged.

* interfaces: add a steam-support interface with permissions needed to set up pressure-vessel containers

* interfaces/seccomp: add futex_waitv to the base template

This is a new syscall used to wait on multiple futexes at once, and
Wine/Proton will attempt to use it if the kernel supports it. Blocking
access prevents it from falling back to the other futex related
syscalls.

* tests: add steam-support to policy snap

* interfaces: limit proc access to same owner in steam interface

* interfaces: lock down the remount AppArmor rules for steam-support

* interfaces: allow pressure-vessel to mount tmpfs to mask certain directories

* interfaces/policy: add base declaration tests for steam-support
2022-04-29 20:29:10 +02:00