7915 Commits

Author SHA1 Message Date
Alex Murray
7eb7ffae0c snap: update vendored apparmor to 3.0.8 with userns and mqueue support (#12836)
* snap: update vendored apparmor to 3.0.8 with userns and mqueue support

Update the snap build to use the latest upstream AppArmor 3.0.8 release and also
add local patches to add support for userns and POSIX mqueue mediation support.

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

* build-aux/snap: fetch patches during build rather than vendor them

By fetching them during the build *and* using the source of the Ubuntu apparmor
package in lunar (23.04) this allows us to keep these patches in sync with what
is used in Ubuntu and to show their provenance at the same time.

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

---------

Signed-off-by: Alex Murray <alex.murray@canonical.com>
Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-06-15 16:44:46 +02:00
Valentin David
c91f0ae069 cmd/snap-bootstrap: make a unit test work on other architectures 2023-06-14 21:42:45 +02:00
Valentin David
6b57ec4736 snap-boostrap: install in initrd 2023-06-14 21:42:45 +02:00
Valentin David
2d2d077fc0 cmd/snap/cmd_auto_import.go: read modeenv instead of kcmdline 2023-06-14 21:42:45 +02:00
Alex Lewontin
93a5c07502 cmd/snap: add '--chain' flag for sign command (#12507)
* cmd/snap: break out 'snap known --remote' fallback logic into helper

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/snap: introduce '--chain' flag for sign command

This flag causes 'snap sign' to append the account-key and account
assertions that correspond to the specified signing key to the signed
output of the command. This is often critical for creating working
system-user assertions, especially in air-gapped or offline situations.

The '--chain' flag takes one of three optional arguments, 'remote',
'direct', and 'local' which correspond to where it should look for the
assertion. The default is 'remote'.

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/snap: use assert.Encoder for sign --chain

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/sign: rework sign chain remote/direct specification, drop local

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/snap: rework --direct without --chain behavior

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/sign: fix tests

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/sign: change --direct error message

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/sign: fix tests

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* Revert "cmd/snap: break out 'snap known --remote' fallback logic into helper"

This reverts commit 39c8ce6234cf5bf07985af17fde72a1192b259ea.

* cmd/snap: simplify --chain to only retrieve assertions directly

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

* cmd/sign: error handling order tweak

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>

---------

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>
2023-06-07 15:30:08 +02:00
Michael Vogt
385d206348 snap-confine: add tmpfs mount rule to apparmor profile (#12845)
There is a bugfix to make the mount rules more strict/explicit in apparmor 3.0.10, see https://gitlab.com/apparmor/apparmor/-/wikis/Release_Notes_3.0.10 - this affects snapd as it's current profile relies on the implicit behavior. With this commit the missing mount rule is added explicitly.
2023-06-05 16:18:47 +02: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
3ddd3f73b3 cmd/snap-seccomp: Group similar variables together
Signed-off-by: Alex Murray <alex.murray@canonical.com>
2023-05-26 18:32:26 +02:00
Alex Murray
ac51f801a2 snap-seccomp-blacklist: also 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
Alex Murray
c0208fd07f snap-seccomp: support explicitly blocking of syscalls
snap-seccomp has always implemented an allow-list approach to syscalls - such
that the listed syscalls are allowed and any non-listed will get
blocked. However, in the case where we want to disallow a syscall with
particular arguments, it is only possible to block one instance of the sycall
with a given argument. If a second similar rule is added, each rule effectively
allows the other and so neither get disallowed as a result.

So introduce the concept of explicitly denying system calls listed in the
seccomp profile by prefixing them with a tilde (~). The seccomp action for these
is then EACCES (since EPERM is the default for unmatched syscalls and seccomp
doesn't allow to specify an action which is the same as the default).

This then allows to specify to block various syscall argument combinations as
expected, and so is used as the mechanism to fix CVE-2023-1523.

Signed-off-by: Alex Murray <alex.murray@canonical.com>
2023-05-26 18:32:26 +02:00
Valentin David
7812317552 snap-bootstrap: check when install can be done in initrd 2023-05-24 09:54:52 +02:00
Valentin David
eefba60eae cmd/snap-bootstrap: cache loaded seeds 2023-05-24 09:54:52 +02:00
Samuele Pedroni
ce63d44761 cmd/snap: have help reflect the relaxing of --revision rules (#12817)
the access to revisions limitations have been dropped in the store

* cmd/snap: clearer wording about --revision non-stickiness

thanks @degville
2023-05-16 17:18:58 +02:00
Sergio Cazzolato
5aeeeae239 tests: make sure there are not any snapd service listed after removing snapd (#12811)
* Make sure there are not any snapd service listed after removing snapd

This is to avoid snapd.apparmor.service snapd.mounts.target
snapd.mounts-pre.target are listed after snapd is purged in arch linux.

* Update tests/main/postrm-purge/task.yaml

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update tests/main/postrm-purge/task.yaml

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-05-15 18:29:44 -03:00
Alfonso Sánchez-Beato
8b418293cd cmd/snap-bootstrap: retry when looking for label on non-UEFI systems
Make sure that we retry when looking for a label on non-UEFI
systems. This is needed until we start to wait on udev to finish to
detect disks.
2023-05-11 12:49:58 +02:00
Philip Meulengracht
c09ae688c3 tests/main/snap-pack-integrity: add a spread test for the verity functionality 2023-05-05 08:46:31 +02:00
Philip Meulengracht
c25e420ea3 many: implement workaround for older versions of veritysetup which unfortunately have a write-bug when writing to files that do not exist or are less than 512 bytes in size (the size of the verity header) 2023-05-05 08:46:31 +02:00
Philip Meulengracht
990a2a0543 many: mock veritysetup calls which fails sporadically on some platforms 2023-05-05 08:46:31 +02:00
Spyros Seimenis
1e19a043ef cmd/snap,snap: parse verity superblock from the generated file
- Fix bug in marshal/unmarshal and add more tests.
- Better align function.
- Fix CI check failure.

Add new design changes:

- Instead of extracting the superblock, we 're going to keep it in the
  dm-verity hash device.
- We will now need to hash the entire integrity data (header + dm-verity
  hash device).
- A new DmVerityBlock struct was added that only contains the root hash
  for now. This can potentially be extended.
- The magic was changed from 'snap' to 'snapext'.
- Renamed 'IntegrityMetadata' to 'IntegrityDataHeader'.
- Fixed serialization bugs to properly account for the null byte after the
  JSON serialized header.
- Add extra tests for the serialization.

Address Samuele's comments.

Make size for IntegrityDataHeader fixed and simplify constructor.

Use Scanner to parse veritysetup output.
Fix internal error message in IntegrityDataHeader.Encode().

Address Alfonso's comments
2023-05-02 11:56:34 +02:00
Spyros Seimenis
8709744d17 cmd/snap,snap: add dm-verity support in snap pack
- alexm comments

- Clean parseVeritySetupOutput API
2023-05-02 11:56:34 +02:00
Sergio Cazzolato
39b6cb0815 tests: fix postrm-purge test on systems with sytemd v253 (#12764)
* Fix postrm-purge test on systems with sytemd v253

Move the removal for the $SNAP_MOUNT_DIR dir after the services are
removed because those errors are making services fail.

test-snapd-service.test-snapd-endure-service[19138]: error: cannot find
installed snap "test-snapd-service" at revision x1: missing file
/var/lib/snapd/snap/test-snapd-service/x1/meta/snap.yaml

Also, added a small wait to make sure the units are already stopped
before continue.

* Update the waiting time for a new service state
2023-05-02 11:14:41 +02:00
Philip Meulengracht
46059f8fee cmd/snap-seccomp/syscalls: update seccomp system call list (#12786)
* cmd/snap-seccomp/syscalls: update system calls to to this commit: aa168d4924

* cmd/snap-seccomp/syscalls: update referenced commit hash
2023-04-29 10:11:43 +02:00
Alfonso Sánchez-Beato
29d7f432dc cmd/bootstrap: ignore case for vfat partitions when looking for
partitions to be mounted.
2023-04-25 10:22:11 +02:00
Michael Vogt
0286764631 snapstate: notify user when refresh-app-awareness snap finished (#12715)
* snapstate: notify user when refresh-app-awareness snap refreshed

This is a minimal commit to show a notification when a refresh that
was triggered by the user closing an application is now ready
to use.

* {iface,snap}state: make LinkParticipant pass a *SnapSetup

* snapstate: use notifyLinkParticipant mechanism to trigger finish notification

* agentnotify: move agent notification into their own package

* snapstate: make AutoRefresh() take *AutoRefreshOptions

* agentnotify: import from overlord to ensure linkParticipant handler gets registered

* tests: add new refresh-app-awareness-notify spread test

* snapstate: fix unreachable code

* tests: move from wormhole to test-snapd-sh in refresh-app-awareness-notify

* agentnotify: send notification when snap starts to refresh

* usersession: tweak wording when refresh is ready (thanks to Oliver)

* usersession: actually add the missing finishRefreshNotificationCmd endpoint

* snap: disable graphicalSessionFlow() to avoid confusion

It's unclear if this flow ever worked and the finish-refresh
part for sure never worked because in the userd the API for
finish-notification was not wired in.

This needs to be re-examined when we have a proper UX design.

* usersession: show notification when update is finished (thanks to Oliver)

* agentnotify: remove uneeded notifyUnlinkSnap()

After a quick sync with Oliver the decision was taken to have
just a notification message when the snap refresh is finished
and not when it starts to avoid too many user distractions.

* usersession: tweak wording when refresh is ready (thanks to Oliver)

* agentnotify: remove unneeded comment

* usersession: one more wording tweak (thanks to Oliver)

* agentnotify: add missing unit test

* snapstate: add test that ensures the snapsup.Flags.IsContinuedAutoRefresh is set

* snapstate: add TODO

* many: tweak wordings/comment/variable names (thanks to Miguel)

* tests: simplify refresh-app-awareness-notify test (thanks to Miguel)

* tests: fix quoting in test

* snap: simplify how inhibit worflow inhibited

* tests: tweak tests and ensure "jq" is installed

* agent: fix unit test error
2023-04-18 14:35:02 +02:00