5808 Commits

Author SHA1 Message Date
Peter Sabaini
179572ca55 interfaces/builtin: allow ZFS vols as a block-device (#13067)
* interfaces: allow ZFS vols as a block-device

ZFS is a versatile tool in managing block storage. Allowing ZFS vols
as block-devices would enable additional scenarios for snaps (like
MicroCeph) that need to deal with block storage. Specifically for
MicroCeph it could be useful for testing and development scenarios
where OSD block devices are expected without requiring actual physical
disks.

Adding the /dev/zfs ioctrl device would enable snaps to automatically
manage these volumes.

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>

* Address review comments

Remove zfs partitions from block devs interface until we have more
clarity around bug https://bugs.launchpad.net/snapd/+bug/2033883

---------

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
2024-03-15 11:41:51 +01:00
nteodosio
5a8ab2dc77 interfaces/builtin: allow access to /usr/share/javascript/{sphinxdoc,jquery} and /usr/share/sphinx_rtd_theme (#13130)
* interfaces/system-packages-doc: Allow access to /usr/share/javascript/{sphinxdoc,jquery} and /usr/share/sphinx_rtd_theme.

https://launchpad.net/bugs/2032992
https://forum.snapcraft.io/t/documentation-packages-attempt-to-access-usr-share-javascript-but-fail

* interfaces/system-packages-doc: Add tests for sphinx and jquery.

* interfaces/builtin: added mount spec tests for system_packages_doc

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

---------

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Co-authored-by: Oliver Calder <oliver.calder@canonical.com>
2024-03-14 19:22:18 +01:00
Peter Sabaini
35655acbc1 i/b/microceph-support: add microceph-support interface (#13352)
* i/b/microceph-support: add microceph-support interface

Add separate microceph-support interface in order to allow more types
of block devices to be added as an OSD (bcache, indiv. partitions,
device mapper)

Also allow access to the rbd sysfs controls for managing rbd-backed block devices (cf.
https://docs.kernel.org/admin-guide/abi-testing.html#abi-file-testing-sysfs-bus-rbd)

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>

* i/b/microceph-support: define slot policy

Address review feedback: define a slot policy

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>

* Rebase and fixup unit test

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>

---------

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
2024-03-14 19:19:38 +01:00
Sebastian Pöhn
d9ce5ec453 interfaces/builtin: add TrustKey G310H 2024-03-14 19:19:08 +01:00
Aristo Chen
fe5d037a79 interfaces/serial-port: add serial devices (ttyLPX) to allowed list (#13695)
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
2024-03-14 16:13:25 +02:00
J. Brock
2e9a6a7904 many: add nfs-mount interface (#12799)
* interfaces: add nfs-mount interface

Signed-off-by: Joseph Brock <joseph.brock@canonical.com>

* i/builtin: adapt nfs-mount to new specs

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* i/builtin: bump copyright

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

---------

Signed-off-by: Joseph Brock <joseph.brock@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Co-authored-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-03-14 08:40:31 +01:00
chkhanu
a63262a178 Update u2f_devices.go
Adds new JaCarta U2F token
2024-03-14 08:39:34 +01:00
Zeyad Gouda
aa191f9771 interfaces/builtin/home: add apparmor rule
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2024-03-13 09:27:09 +01:00
Maciej Borzecki
ab28d46dd1 interfaces/udev: do not call udev when in preseed mode
The udev backend was not preseed aware and would always call udev reload, even
before introducing #13642 and the errors were masked. Check if the backend is
running in preseed mode and do not call udev at all.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-03-12 13:32:44 +01:00
ashuntu
81d3d515f0 steam_support: add comment regarding need for /usr/share driver info 2024-03-11 13:31:12 +01:00
ashuntu
9dfe8cf278 steam_support: combine /snap rules 2024-03-11 13:31:12 +01:00
ashuntu
466aa7638f steam_support: allow reading of hostfs /usr/share/nvidia files 2024-03-11 13:31:12 +01:00
ashuntu
05d2d5b294 steam_support: allow mounting of snap and hostfs directories 2024-03-11 13:31:12 +01:00
Zygmunt Krynicki
a406349529 i/builtin: system-packages-doc bare snap workaround
The bare snap has few mount points, making the use of mimics, a workaround for
creating mount points on an otherwise read-only squashfs, using a tmpfs and a
farm of directories and files for bind-mounting, is required. In the particular
case of system-packages-doc plug on a snap using the bare base snap, we need to
create and re-create /usr.

The snap-update-ns program which is responsible for the bulk of mount
manipulation, is invoked in one of two very different scenarios.  Most often,
it is invoked from the "snap run" -> "snap-confine" -> "snap-update-ns", just
before the "snap-exec" hop. In this scenario it is confined with a special,
per-snap apparmor profile. This profile has so far had insufficient permissions
to perform this manipulation. A user may work around the problem by
disconnecting and re-connecting the system-packages-doc interface manually.
When this happens, the mount namespace is adjusted and kept in kernel memory
until the system re-boots. In this case snapd invokes snap-update-ns itself,
and crucially, without the apparmor sandbox.

The rationale for this behavior is that snap-update-ns is invoked by an
unprivileged user, using a setuid-root helper (snap-confine), so extra care is
warranted and snap-update-ns should have all the power it needs, but no more.

One could argue that this is highly inconsistent and they would be right. For
the moment the most conservative change is to detect this specific case and
adjust the sandbox. A more general case for a different method of setting up
the mount namespace, without the need to use mimics, or dropping the sandbox
entirely would allow us to retain precise permissions.

Fixes: https://bugs.launchpad.net/snapd/+bug/2044335

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-03-09 20:40:45 +01:00
Buğra Aydoğar
c0059170df interfaces/builtin: add interface for remoteproc 2024-03-09 20:39:56 +01:00
Maciej Borzecki
69528a936a interfaces/udev, cmd/snap-confine: support for snaps managing own device cgroups (#13642)
* dirs: add directory location for storing cgroup policy related flags

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: introduce cgroup policy flag for self managed device cgroup

Some snaps, due to their interfaces, are allowed to self manage the device
cgroup. In this case, the assumption was to not emit any rules at all, and
instead rely on the implicit behavior that no rules means no matching devices
and hence no device cgroup filtering. However, with introduction of a device
cgroup by default for all snaps on core24 onward, regardless of any assigned
devices, we need a separate source of information to indicate that a snap can do
self management.

The patch introduces a policy flags under /var/lib/snapd/cgroup, named
snap.<name>.device, eg.
/var/lib/snapd/cgroup/snap.docker.device, which provides a hints for
snap-confine to not set up a device cgroup filtering for apps.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: support snaps which self-manage device cgroup

Support for snaps for which policy explicitly states that the device cgroup is
self-managed. The typical use case is container like technologies. In such
scenario, there will be a device cgroup configuration file at a known location
which got generated by snapd whenever the relevant interface state changed.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* tests/main/security-device-cgroups-self-manage: spread test

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: drop base from bases exempt from mandatory device cgroup

We have confirmed that there are no snaps which (ab)use system files and use
bare base to obtain access to devices. As such, the bare base can be dropped
form the list of bases exempt from mandatory device cgroup.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: remove snap devices file when removing the snap

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: consistent use of fs.ErrNotExist

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: leave comments

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: tweak return path

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: improve managed device cgroup unit tests, verify calls to udevadm

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* NEWS: leave a note about mandatory device cgroup

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* tests/main/security-device-cgroups-self-manage: tweak comments

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: always write the device file

Always write the device file which serves as a synchronization point between
snap-confine and the snapd udev backend.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/libsnap-confine-private: add helper for waiting for a file to show up

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: make cgroup device file mandatory

Make the per-snap /var/lib/snapd/cgroup/snap.*.device file mandatory, such that
it can be used as a synchronization point between snapd calling Setup() of
relevant security backends and the execution path in snap-confine.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-mgmt: do cleanup of /var/lib/snapd/cgroup

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* packaging: declare /var/lib/snapd/cgroup

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: use the file wait helper

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* packaging: create cgroup directory

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* tests/main/security-device-cgroups-self-manage: update file check

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* tests/main/security-device-cgroups-required-or-optional: update test to verify device file

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* interfaces/udev: refactor reloading

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* cmd/snap-confine: move device cgroup mode selection to a helper

Extract device cgroup mode selection into a helper function.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

---------

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-03-07 13:23:58 +01:00
Buğra Aydoğar
db27649340 interfaces/builtin: add interface for kernel-firmware-control 2024-03-07 10:13:42 +01:00
Ash
65206a409c steam_support: generalize pressure-vessel root paths (#13489)
* steam_support: generalize pressure-vessel root paths

* steam_support: convert all pressure-vessel paths to /newroot/**

Pressure Vessel is likely to change at any point, so /newroot/** allows Steam the flexibility
to do what it needs to for games to run. See discussion here: https://github.com/snapcore/snapd/pull/13489#discussion_r1454056639

* steam_support: convert LD pressure-vessel paths to /newroot/**

* steam_support: remove redundant tmpfs mount paths
2024-03-05 12:29:28 +01:00
Zeyad Gouda
eba5f39bb4 many: add snap-refresh-observe interface
Snaps with snap-refresh-observe plug connected will have
    read-access to:
    - /v2/notices: to read change-update and refresh-inhibit notices
    - /v2/changes{,/<id>}: to read refresh related changes
    - /v2/snaps: to read snaps whose refresh is inhibited

* many: address review comments (thanks @pedronis)

* daemon: explicitly check for SnapdSocket (thanks @alexmurray)

* daemon: refactor notice api helpers

* daemon: address review comments (thanks @pedronis)

* daemon: give snap-refresh-observe access to refresh-inhibit notices

* Merge branch 'master' of github.com:snapcore/snapd into add-snap-refresh-inhibit-observe-interface

* daemon: filter notice types based on snap interfaces

* daemon: attach snap interfaces to RemoteAddr

* daemon: move single notice checks into noticeReadAccess (thanks @pedronis)

* many: add access check for /v2/notices/{id} (thanks @alexmurray)

* many: address review comments

* many: rename snap-refresh-inhibit-observe interface to snap-refresh-observe (thanks @bboozzoo)

* daemon: rename notice helpers to be more explicit

* daemon: explicitly define access checker for each notice type

* tests/main: add test for snap-refresh-inhibit-observe interface

* daemon: allow snaps with snap-refresh-inhibit-observe plug API read-access

* daemon: add noticeReadAccess checker

* interfaces/builtin: add snap-refresh-inhibit-observe interface

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2024-03-04 09:19:43 +01:00
Maciej Borzecki
4c981d7587 interfaces/builtin/network_setup_observe: allow busctl to bind
Extend the network-setup-observe AppArmor snippets with the same tweak for
busctl as was added in network-setup-control.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-29 14:01:52 +01:00
Maciej Borzecki
89c456e5de interfaces/builtin/network_setup_control: allow busctl to bind
Starting from systemd 254, busctl will attempt to bind the socket to a known
path to facilitate debugging. The change was introduced in
a0cb335816
and the path is composed of `@<hex-encoded-u64>/bus/<command>/<description>`.

Actual denial:

Feb 29 08:22:04 localhost kernel: audit: type=1400 audit(1709194924.547:213):
apparmor="DENIED" operation="bind" class="net" profile="snap.console-conf.console-conf"
pid=4504 comm="busctl" family="unix" sock_type="stream" protocol=0
requested_mask="bind" denied_mask="bind" addr="@f46ecfc1c63ae80f/bus/busctl/busctl"

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-29 14:01:52 +01:00
Jorge Sancho Larraz
b9606c845e interfaces/builtin/libvirt: add read permissions to /var/lib/snapd/ho… (#13645)
* interfaces/builtin/libvirt: add read permissions to /var/lib/snapd/hostfs/var/lib/libvirt/dnsmasq{,**}

* interfaces/builtin/libvirt: fix path /var/lib/snapd/hostfs/var/lib/libvirt/dnsmasq/{,**}
2024-02-29 13:11:43 +01:00
James Henstridge
2c8be76d8c interfaces: make steam-support implicit on core (#13189)
This is a commit we've had in the Core Desktop snapd tree for a while that had not been proposed upstream.

We would like to be able to run the Steam snap on Core Desktop. We've got everything else working, so providing an implicit steam-support slot on core (specifically Core Desktop) was the last piece of the puzzle. Everything else is similar enough not to be a problem.

* interfaces: make steam-support implicit on core

* interfaces: only make steam-support implicit on desktop variants of Ubuntu Core

* interfaces: test the StaticInfo for steam-support

---------

Co-authored-by: Ken VanDine <ken.vandine@canonical.com>
2024-02-29 09:32:37 +01:00
Maciej Borzecki
cc8b783d2b interfaces/backend: update sandbox features to account for cgroup v2 device filtering
Add device-cgroup-v2 sandbox feature flag which was forgotten when we landed
cgroup v2 device filtering support.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-28 11:04:35 +02:00
Andrew Phelps
069b7f684e many: use interfaces.SnapAppSet in security backends (#13587) 2024-02-27 14:52:02 -05:00