missing ptrace options needed by snap-confine

Bug #1633367 reported by You-Sheng Yang
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
Critical
Yuan-Chen Cheng
snap-confine
Fix Released
Undecided
Unassigned
snap-confine (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned
Yakkety
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

When porting snappy to our reference device -- m10 (xenial, arm64, kernel-3.10), execution of hello-world command from the hello-world snap fails due to the lack of appropriate permission in apparmor. It turns out ptrace is used between snap-confine and its mount helper, and the corresponding trace/tracedby permissions are not granted. Merge proposal https://github.com/snapcore/snap-confine/pull/170 addressed this issue.

[Test Case]

1. flash m10 with images from frieza_arm64 channel,
2. install snapd. You may need to setup networking, remount root filesystem as read-write first.
3. install hello-world snap
4. run `hello-world`

[Regression Potential]

This patch grants extra options carried to ptrace calls between snap-confine and mount-namespace-capture-helper only. However, this grants additional permission to ptrace options, so at least it means a certain level of security risk. Considering mount-namespace-capture-helper is actually snap-confine itself forked with apparmor change-hat trick, the effect to other part of the system, and possible regression should be pretty limited.

[Other Info]

* snap-confine is technically an integral part of snapd which has an SRU exception and is allowed to introduce new features and take advantage of accelerated procedure. For more information see https://wiki.ubuntu.com/SnapdUpdates

== # Pre-SRU bug description follows # ==

[ 2526.693811] (1)[30640:ubuntu-core-lau]type=1400 audit(1476430414.677:434): apparmor="DENIED" operation="ptrace" profile="/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=30640 comm="ubuntu-core-lau" requested_mask="read" denied_mask="read" peer="/usr/lib/snapd/snap-confine"
[ 2526.693845] (1)[30640:ubuntu-core-lau]type=1400 audit(1476430414.677:435): apparmor="DENIED" operation="ptrace" profile="/usr/lib/snapd/snap-confine" pid=30640 comm="ubuntu-core-lau" requested_mask="readby" denied_mask="readby" peer="/usr/lib/snapd/snap-confine//mount-namespace-capture-helper"
[ 3512.751438] (1)[8128:ubuntu-core-lau]type=1400 audit(1476431400.737:502): apparmor="DENIED" operation="ptrace" profile="/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=8128 comm="ubuntu-core-lau" requested_mask="read" denied_mask="read" peer="/usr/lib/snapd/snap-confine"

So we need to modify /etc/apparmor.d/usr.lib.snapd.snap-confine as:

/usr/lib/snapd/snap-confine flags=(attach_disconnected) {
    ...
    ptrace (read, readby, tracedby) ...

    ^mount-namespace-capture-helper flags=(attach_disconnected) {
    ...
    ptrace (read, trace, tracedby) ...

Revision history for this message
You-Sheng Yang (vicamo) wrote :

This, along with bug 1632272, are necessary to install/run snap hello-world package on avila.

Jason Yen (jasonyen)
Changed in canonical-devices-system-image:
milestone: none → x1
Revision history for this message
You-Sheng Yang (vicamo) wrote :

Enable necessary ptrace options for both snap-confine and its helper.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

Don't know where to send a merge proposal, so put a patch here first.

Revision history for this message
You-Sheng Yang (vicamo) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "diff.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

pull request in #4 merged.

Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

snap-confine in xenaial still 1.0.43-0ubuntu1~16.04.1

current build number: 68
device name: frieza_arm64
channel: ubuntu-touch/staging/ubuntu
last update: 2016-10-26 00:51:22
version version: 68
version ubuntu: 20161025
version device: 20161014.0
version custom: 20161025

Changed in snap-confine (Ubuntu):
status: New → Fix Committed
Changed in snap-confine:
status: New → Fix Committed
Changed in canonical-devices-system-image:
status: New → Fix Committed
Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

still no update on Nov 1.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

Upstream has merged this and tagged as 1.0.44 [1], so it should only be available after that.

[1]: https://github.com/snapcore/snap-confine/commits/1.0.44/src/snap-confine.apparmor.in

Changed in canonical-devices-system-image:
assignee: nobody → Yuan-Chen Cheng (ycheng-twn)
Changed in canonical-devices-system-image:
importance: Undecided → Critical
Zygmunt Krynicki (zyga)
Changed in snap-confine:
milestone: none → 1.0.44
status: Fix Committed → Fix Released
Zygmunt Krynicki (zyga)
description: updated
Zygmunt Krynicki (zyga)
tags: added: verification-needed
You-Sheng Yang (vicamo)
description: updated
description: updated
You-Sheng Yang (vicamo)
description: updated
Revision history for this message
Andy Whitcroft (apw) wrote : Please test proposed package

Hello Vicamo, or anyone else affected,

Accepted snap-confine into yakkety-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/snap-confine/1.0.44-0ubuntu1~16.10 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in snap-confine (Ubuntu Yakkety):
status: New → Fix Committed
Revision history for this message
Andy Whitcroft (apw) wrote :

Hello Vicamo, or anyone else affected,

Accepted snap-confine into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/snap-confine/1.0.44-0ubuntu1~16.04 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in snap-confine (Ubuntu Xenial):
status: New → Fix Committed
Revision history for this message
You-Sheng Yang (vicamo) wrote :

phablet@ubuntu-phablet:~$ hello-world
Hello World!

phablet@ubuntu-phablet:~$ system-image-cli -i
current build number: 76
device name: frieza_arm64
channel: ubuntu-touch/staging/ubuntu
last update: 2016-11-05 03:12:16
version version: 76
version ubuntu: 20161105
version device: 20161014.0
version custom: 20161105

phablet@ubuntu-phablet:~$ dpkg -l|grep snap
ii libsnappy1v5:arm64 1.1.3-2
ii snap-confine 1.0.44-0ubuntu1~16.04
ii snapd 2.17.1

tags: added: verification-done
removed: verification-needed
You-Sheng Yang (vicamo)
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
Changed in snap-confine (Ubuntu):
status: Fix Committed → Fix Released
Changed in snap-confine (Ubuntu Xenial):
status: Fix Committed → Fix Released
Changed in snap-confine (Ubuntu Yakkety):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.