Bug in ensure_not_symlink() from 0003-CVE-2015-1335.patch

Bug #1509752 reported by Steve
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Invalid
High
Unassigned
Trusty
Fix Released
High
Unassigned

Bug Description

=======================================================================
SRU Justification
Impact: cannot start containers with lxc.mount.entries which are recursive bind mounts
Regression potential: this makes assumptions about the ordering of /proc/self/mountinfo, but no more so than the original CVE patch. So it should not regress from the previous lxc version.
Test case:

#!/bin/sh
set -ex
cleanup() {
        umount /mnt/etc /mnt/proc || true
        lxc-stop -n t1 -k || true
        lxc-destroy -n t1 || true
}
trap cleanup EXIT
mkdir -p /mnt/etc /mnt/proc
mount --bind /etc /mnt/etc
mount --bind /proc /mnt/proc
lxc-create -t download -n t1 -- -d ubuntu -r trusty -a amd64
cat >> /var/lib/lxc/t1/config << EOF
lxc.mount.entry = /mnt hostmnt none rbind,create=dir
EOF
lxc-start -n t1 -F -l trace -o /dev/stdout
echo "DONE"

=======================================================================
This bug/limitation is present in lxc from 1.0.7-0ubuntu0.5 through 1.0.7-0ubuntu0.9 (or anything that incorporates 0003-CVE-2015-1335.patch). Basically, the limitation is obvious when using recursive bind mounts because ensure_not_symlink() only checks the last line of /proc/self/mountinfo which will be a submount so will always fail the test and trigger:

ensure_not_symlink: 1413 Mount onto /usr/lib/x86_64-linux-gnu/lxc/storage resulted in /usr/lib/x86_64-linux-gnu/lxc/storage/submount, not /usr/lib/x86_64-linux-gnu/lxc/storage

Sorry if this is a duplicate, I did spend quite some time trying to find a similar report.

Thanks!

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 1509752] [NEW] Bug in ensure_not_symlink() from 0003-CVE-2015-1335.patch

Thanks - haven't tested, but it certainly makes sense.

 status: confirmed
 importance: high

Changed in lxc (Ubuntu):
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Apparently the kernel is now fixed so that we should be able to use the upstream fix. I'm going to try to get that into the trusty package rather than keep tweakng this separate patch.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Yup, switching in the upstream fix works - will upload that in a bit.

Changed in lxc (Ubuntu Trusty):
importance: Undecided → High
Changed in lxc (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

No, sadly one testcase - lxc-test-unpriv - still fails:

Oct 28 15:33:49 lxct1 kernel: [ 2659.417204] type=1400 audit(1446046429.177:52): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="/usr/bin/lxc-start" name="/home/lxcunpriv/.local/share/lxc/c1/rootfs/dev/console" pid=23805 comm="lxc-start" srcname="/dev/console" flags="rw, bind"

(Note that running unprivileged containers by hand does work)

description: updated
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

(invalid would probably be a better status for the development release, but i dont' want to scare the SRU team :)

Uploaded a workaround for this bug. Using the upstream fix sadly is still broken by apparmor+overlayfs bugs.

Revision history for this message
Stéphane Graber (stgraber) wrote : Please test proposed package

Hello Steve, or anyone else affected,

Accepted lxc into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/lxc/1.0.7-0ubuntu0.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 lxc (Ubuntu):
status: Fix Released → Invalid
Changed in lxc (Ubuntu Trusty):
status: New → In Progress
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Steve (m-dave-r) wrote :

I am now running 1.0.7-0ubuntu0.10 and can confirm that it resolves the issue. I can successfully start containers with recursive bind mounts.

Thanks for the fix! Greatly appreciated!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 1.0.7-0ubuntu0.10

---------------
lxc (1.0.7-0ubuntu0.10) trusty; urgency=medium

  * Update the /proc/self/mountinfo no-symlink verification to accomodate
    recursive mounts. (LP: #1509752)

 -- Serge Hallyn <email address hidden> Wed, 28 Oct 2015 12:21:38 -0500

Changed in lxc (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Stéphane Graber (stgraber) wrote : Update Released

The verification of the Stable Release Update for lxc has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.