5690 Commits

Author SHA1 Message Date
Miguel Pires
4cd82ec45e i/b/shared-memory: handle "private" plug attribute in shared-memory interface correctly (#13107)
* i/b/shared-memory: error on invalid plug attribute

The isPrivate() method assumes that a plug has been sanitised by
BeforePreparePlug and panics if there's no "private" attribute.
There's been a customer report of this happening and even though the
it's unclear how the attribute is missing/wrong, we should handle it
as gracefully as we can instead of panicking.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* i/b/shared-memory: split else/if

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* interfaces: deal with missing shared-mem `private` attr correctly

The private attribute in the shared-memory interface may be
not in the `isPrivate()` call. This can even happen if
"SanitizePlugsSlots()" is called (which in turn calls
BeforePreparePlug() which will set `private`).

The code-path in which this happens is an upgrade from snapd
2.54.4 where shared-memory did not have the "private" attribute
yet. Then the ConnectedPlug data is written into the
interface repo without this attribute and on regeneration
of security profiles the connectedPlug is loaded from the
interface repository in the state and not from the
snap.yaml so this attribute is missing.

The correct behavior is that `private` is set to false which
is the default when it's not set in snap.yaml as it can only
end up in this state if it was unset.

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-08-25 18:34:16 +02:00
Philip Meulengracht
3e22bb4acd i/apparmor: support for home.d tunables from /etc/ (#13118)
* i/apparmor: support for home.d tunables from /etc/

* tests: update snapd-homedirs-vendored to run on all ubuntu versions

* i/apparmor: add additional unit test

Only enable the spread test for ubuntu 20 and newer as any distro before don't support the neccessary features

---------

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-08-25 17:46:53 +02:00
Mehdi Bendriss
2260c94360 i/builtin: allow directories in private /dev/shm (#12925)
* Allow directories in private /dev/shm

* Fixed unit test
2023-08-04 12:06:52 +02:00
Mehdi Bendriss
721eb95ad3 i/builtin: add read access to /proc/task/schedstat in system-observe (#12927)
Allow read access to @{PROC}/*/{,task/*/}schedstat which is a file needed by OpenSearch's performance analyzer.
2023-08-04 12:06:17 +02:00
Aristo Chen
54fd3e5f84 interfaces/opengl: add support for ARM Mali
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
2023-07-12 10:09:00 +02:00
Dennis Loose
a45679bb24 interfaces: fix typo in network_manager_observe 2023-07-03 14:07:58 +02:00
Alex Murray
2d78693a5b sandbox/apparmor: don't let vendored apparmor conflict with system (#12909)
* sandbox/apparmor: don't let vendored apparmor conflict with system

Don't enable the vendored apparmor if the system installed apparmor will try and
load policy that would be generated by the vendored apparmor and hence may
conflict with that by using newer features not supported by the system installed
apparmor (LP: 2024637)

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

* apparmor: add unit testing for SystemAppArmorLoadsSnapPolicy()

* tests: add test that checks regression in lp-2024637

* apparmor: only log non ENOENT errors in systemAppArmorLoadsSnapPolicy

* tests: fix snapd-snap test on 14.04-18.04

This commit will skip apparmor vendor testing if /lib/apparmor/functions
still references /var/lib/snapd/apparmor/.

See LP:2024637

* tests: fix typo in snapd-snap test

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

* i/apparmor: allow read of /lib/apparmor/functions in snap-update-ns

Snapd at startup will inspect this file now to ensure that the
vendored apparmor can be used. So the snap-update-ns profile
also needs to get updated as this happens during an early init().

---------

Signed-off-by: Alex Murray <alex.murray@canonical.com>
Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-07-03 14:07:33 +02:00
Alex Murray
47ccab3269 many: move SnapConfineAppArmorDir from dirs to sandbox/apparmor (#12906)
* many: move SnapConfineAppArmorDir from dirs to sandbox/apparmor

Then when using the internal vendored AppArmor, use a different location for
SnapConfineAppArmorDir so that we don't interfere with the system installed
AppArmor.

In Ubuntu, the snapd deb includes an AppArmor profile for
/usr/lib/snapd/snap-confine that includes any profile snippets from the
hard-coded directory of /var/lib/snapd/apparmor/snap-confine. When we use the
snapd snap with the vendored AppArmor, this may contain newer features and so
would create snippets under /var/lib/snapd/apparmor/snap-confine that then may
not be supported by the system installed AppArmor. When the system installed
apparmor.service would run on boot, it would try and load the snap-confine
AppArmor profile shipped in the snapd deb, which would then try and include
these snippets generated by the newer vendored AppArmor and could fail to load
them as they would use new features not supported by the system AppArmor.

So instead, when using the vendored AppArmor, have snapd use a different
directory for the snap-confine profile snippets and then have the
snapd-generated AppArmor profiles for snap-confine reference this location
instead. This should allow to support both use-cases simultaneously.

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

* apparmor: add unit test that ensures that snap-confine include snippet is rewriten

* sandbox/apparmor: add unit test around setupConfCacheDirs()

* tests: add check check in snapd-snap for /v/l/snapd/apparmor/snap-confine.internal path usage

* tests: fix spread test to look at the right profiles

* i/apparmor: allow read of /usr/lib/snapd/info in snap-update-ns profile

---------

Signed-off-by: Alex Murray <alex.murray@canonical.com>
Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-06-29 16:59:27 +02:00
Valentin David
4f2d107db1 interfaces/udev: do not tag modules
Module loading generates event for devpath /module/<nameofmodule>.
Some modules and devices have the same KERNEL name. For example
rfkill. We need to ignore module insertions. Otherwise we get
error message when trying to run snap-device-helper.
2023-06-15 15:21:15 +02:00
Sergio Costas
cc7fab59a2 account_control: allow local user account management (#12626)
* account_control: allow local user account management

This MR adds support for adding, removing and modifying the users.
It is required for Core Desktop.

* Remove peer entries

* Add peer=(label=unconfined)

It works the same.

* Add extra peer=(label=unconfined)
2023-06-15 10:16:56 +02:00
Michael Vogt
d7d0d6570a interfaces: fix network-control rule for apparmor 3.1.4
It looks like some changes in apparmor 3.1.4 cause issues with
the existing network-control rules. It appears the rules are
stricter now.

Thie commit updates the rules to match the new behavior, see
also https://bugs.launchpad.net/apparmor/+bug/2023025
2023-06-13 12:48:15 +02:00
Tim Smeets
b44704463a Add flipper zero to u2f devices under existing STMicro based products 2023-06-12 09:00:49 +02:00
Oliver Calder
42bcf1097d interfaces/builtin: added zfs mount options to mount-control
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
2023-06-08 08:50:22 +02:00
Sergio Costas
a860e357c6 interfaces/audio: remove write permissions in pulse folder (#12864)
Currently, any application that connects to the audio-playback or
the pulseaudio insterfaces, have write permissions to the pulse/
folder. This means that a snapped malicious application would be
able to delete the socket and put its own, being able to read the
audio of any other snapped application.

This patch removes those permissions.

* Remove unneeded rules

The "owner /run/pulse/native/ rwk" rule is already managed by a
similar previous one. Also, there is no need to allow to link the
pulse folder.

Tested both in Firefox and Telegram, and everything still works
fine.
2023-06-07 15:37:03 +02:00
Michael Vogt
35f7c14edb interface: allow /sys/devices/platform based gpio paths (#12816)
We have a bugreport where even with an active gpio-control interface
the gpio devices cannot be accessed. The path in question is:
```
/sys/devices/platform/INT33FC:02/gpio/gpio346/direction
```

Hower we only allow:
```
/sys/class/gpio/gpio[0-9]*/{active_low,direction,value,edge} rw,
```
in our gpio-control policy.

To fix that issue this commit allows gpio prefixes that start
with /sys/devices/platform instead.

* interfaces: add comment about /sys/devices/platform/*/gpio/gpio[0-9]*/ in gpio-control
2023-06-07 15:35:22 +02:00
Michał Sawicz
f91f68ef90 opengl: allow libdrm data files (#12694)
* opengl: allow libdrm data files

* opengl: be explicit about amdgpu.ids

---------

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-06-07 15:33:24 +02:00
Michał Sawicz (Saviq)
68a3c941e0 wayland: add support for eglstream on Core 2023-06-07 15:31:53 +02:00
James Henstridge
92cf5ea5b3 Merge pull request #12853 from kenvandine/add_bluez_agent
interfaces: add support for Bluez OBEX agent D-Bus API to bluez interface
2023-06-01 12:04:52 +08:00
Alexandre Lissy
bfce6e9bdf interfaces/seccomp/template: Adding kcmp to allow Mesa usecases
For fixing https://bugs.launchpad.net/snapd/+bug/1998980 implement the
suggested fix of allowing kcmp in the base template.
2023-05-29 11:22:42 +02:00
Michael Vogt
d7b49dd6f5 many: add a bunch of TODO/FIXME for a followup :) 2023-05-26 18:32:26 +02:00
Alex Murray
453f9e8395 interfaces/seccomp: explicitly disallow the use of ioctl + TIOCLINUX
Fixes CVE-2023-1523

Signed-off-by: Alex Murray <alex.murray@canonical.com>
2023-05-26 18:32:26 +02:00
Ken VanDine
de3cfbb4f4 Support bluez agent
This allows bind for org.bluez.obex.* which is necessary for the
agents that are created as well as the send for the
org.bluez.AgentManager1 interface.
2023-05-25 22:54:29 -04:00
Oliver Calder
a91821c304 interfaces/builtin: updated mount-control unit tests to reflect alphabetization
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
2023-05-25 12:33:24 +02:00
Oliver Calder
866ac41ac9 interfaces/builtin: alphabetized kernel mount options
This change alphabetizes the supported kernel mount options, as well as
moves `zfs` after `xfs` in the list of default filesystems.

Filesystem-specific mount options are not alphabetized, and are instead
left in the order they are defined in their documentation or source
code in order to ease visual verification of their correctness.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
2023-05-25 12:33:24 +02:00
Oliver Calder
12ca6af3a0 interfaces/builtin: fix custom-device default udev kernel rules (#12833)
* interfaces/builtin: fix custom-device default udev kernel rules

The KERNEL value in udev rules must be the basename of the device path.
For devices for which there is not a matching kernel value specified in
the custom-device `udev-tagging` section, a default udev kernel rule is
generated.  Previously, https://github.com/snapcore/snapd/pull/12734
(and prior) generated these default rules by using the complete device
path relative to `/dev/`.  However, for device paths which are in
subdirectories of `/dev/`, this means that the kernel values were not
basenames, which violates the udev spec.

This commit changes this behavior to instead generate udev kernel rules
using the basename of each specified device.

Since ambiguity would arise if multiple devices had the same basename,
this change introduces a check to ensure that all the specified devices
have unique basenames.

Additionally, this commit introduces a check to ensure that all
specified kernel values in the `udev-tagging` section are basenames.

It is still the case that each specified kernel value must match one of
the specified devices.

There are currently problems with `vet` where it is claimed that several
of the `[]string` variables in `validateUDevDevicesUniqueBasenames()`
are unused.  These variables are used in a several ways, so further
investigation is required as to why this is the case.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* prompting/storage: fixed missing variable assignment from append()

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* prompting/storage: fixed custom device duplicate basename error message

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* interfaces/builtin: fixed custom-device unit tests introduced by commas in filepaths PR

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* interfaces/builtin: adjusted custom-device comment for kernel not matching any devices

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* interfaces/builtin: fixed unit test for when custom-device kernel does not match any device

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

* interfaces/builtin: moved custom-device unique basename check

This change moves the check for whether all specified devices have
unique basenames out of `validateUDevTaggingRule()` (which is called
once for each udev rule) into `BeforePrepareSlot()`, immediately after
the list of device paths is assembled and each path validated.  Thus, it
is only called once, before any rule validation begins.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

---------

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
2023-05-24 10:32:57 -05:00