snap/apparmor default confinement rejects socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT);

Bug #1663221 reported by Albert Astals Cid
8
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapd
Fix Released
High
Jamie Strandboge

Bug Description

This call is used by udev in
udev_monitor_new_from_netlink/udev_monitor_new_from_netlink_fd

udev_monitor_new_from_netlink is used by QInputInfoManagerUdev in QtSystems

QInputInfoManagerUdev is used by QuickUtils in UbuntuToolkit to provide different interaction paradigms whether a mouse/keyboard are attached or not

tags: added: snap-interface
tags: added: snapd-interface
removed: snap-interface
description: updated
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Based on the bug description, it sounds like you want this rule:

network netlink raw,

To be sure, can you paste the denial from /var/log/syslog? I spoke to mterry about a similar issue and AIUI, this only happens on X and not mir, is that correct?

Changed in snapd:
status: New → Incomplete
Revision history for this message
Albert Astals Cid (aacid) wrote :

The denial is

Feb 9 14:22:08 tsdgeos-ThinkPad-Yoga-460 kernel: [17683.935917] audit: type=1400 audit(1486646528.842:73): apparmor="DENIED" operation="create" profile="snap.red-rectangle-uitk.red-rectangle-uitk" pid=27306 comm="qmlscene" family="netlink" sock_type="raw" protocol=15 requested_mask="create" denied_mask="create"

Yes, this particular case is only happening in X since when using Mir QtSystems uses QInputInfoManagerMir instead of QInputInfoManagerUdev that doesn't need udev since it talks directly to mir

Changed in snapd:
status: Incomplete → New
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Unfortunately 'network netlink raw' isn't finely mediated, but since this only happens on X, adding this rule to the transitional unity7 and x11 interfaces should be fine. Justification: DAC offers some protections for netlink raw on the system, most applications using X/unity7 run as non-root, X is insecure so blocking this particular rule needed by Qt on X is arguably specious, and breaking out 'netlink raw' into an interface isn't very interesting because it is entirely too general.

Changed in snapd:
assignee: nobody → Jamie Strandboge (jdstrand)
importance: Undecided → High
status: New → Triaged
Changed in snapd:
status: Triaged → In Progress
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

@Albert, can you provide a snap or snapcraft.yaml that can be used to demonstrate the problem?

Revision history for this message
Albert Astals Cid (aacid) wrote :

Here it comes.

Currently it crashes because of the code was not prepared for the socket to be denied, that part is fixed in https://codereview.qt-project.org/#/c/185071/

If you had that fix you'd see that it says you don't have a mouse even if you actually do.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

As a sidenote the fixed qtsystems is now in zesty and xenial overlay PPA, so the latter part of Albert's message applies now.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

In discussing this more we decided that 'netlink raw' was too broad of a stroke. We can however adjust our seccomp policy for socket() for something like this:

socket PF_NETLINK SOCK_RAW NETLINK_KOBJECT_UEVENT

and then apparmor with:

# apparmor
# needed by QtSystems on X to detect mouse and keyboard. Note, the 'netlink raw'
# rule is not finely mediated by apparmor so we mediate with seccomp arg filtering.
network netlink raw,
/run/udev/data/c13:[0-9]* r,
/run/udev/data/+input:* r,

The above should be fine for non-root, but there is some more investigating to be had here. Allowing NETLINK_KOBJECT_UEVENT for a root process is undesirable.

Revision history for this message
Albert Astals Cid (aacid) wrote :

I guess if what we care is user applications running under X that need udev, rejecting for the root case is ok

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This is fixed in 2.26.

Changed in snapd:
status: In Progress → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Fine grained netlink mediation was added in 2.26 but rules weren't added to unity7 and x11. I'll fix that.

Changed in snapd:
status: Fix Released → In Progress
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I believe this was fixed and released as snapd 2.27.2

Changed in snapd:
status: In Progress → Fix Committed
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.