QNetworkSession::isOpen() always returns false
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | Canonical System Image |
High
|
Zoltan Balogh | ||
| | apparmor-easyprof-ubuntu (Ubuntu) |
Undecided
|
Unassigned | ||
| | qtbase-opensource-src (Ubuntu) |
Undecided
|
Unassigned | ||
| | qtbase-opensource-src (Ubuntu RTM) |
Undecided
|
Unassigned | ||
Bug Description
Using QNetworkSession
The test app in lp:~mzanetti/+junk/nmsessiontest can reproduce the issue. Open this project in ubuntu-sdk's qtcreator and run it on a vivid device. Press the button and watch the debug prints.
On a vivid-desktop or a RTM based phone it will print "all is well". On a vivid phone however, it'll print "network session not open..."
This used to work fine at least back in utopic images.
Related branches
| Changed in qtbase-opensource-src (Ubuntu): | |
| assignee: | nobody → Lorn Potter (lorn-potter) |
| Lorn Potter (lorn-potter) wrote : | #1 |
| Lorn Potter (lorn-potter) wrote : | #2 |
[05:34:57] <lpotter> QDBusConnection: error: could not send message to service "org.freedeskto
[05:35:01] <lpotter> hmm
[05:35:24] <mzanetti> oh, you're still working. I hope it's not just for this
[05:35:34] <lpotter> morning time :)
[05:35:44] <lpotter> just thought I'd look at it
[05:35:50] <mzanetti> ok :)
[05:35:58] <mzanetti> that looks like apparmor
[05:36:05] <lpotter> there's also some other odd output
[05:36:15] <lpotter> yes, my thought too
[05:36:56] <mzanetti> not sure if we can convince jamie to allow apps calling Introspect on that interface
[05:40:09] <lpotter> there was another bug mentioning that abstract dbus interface does not introspect, whereas QDBusInterface does
[05:40:41] <mzanetti> ah, that might well be true
[05:40:56] <lpotter> I use QDBusInterface all over in those classes
[05:41:40] <mzanetti> hmm, I guess if that would solve the issue it would be way to go... I think it's also in upstream's interest to allow more fine grained control on Qt's permissions
[05:49:05] <lpotter> wish I could remember what bug was that. it was only yesterday I looked at it
[05:50:33] <lpotter> ahh 1403508
[05:54:05] <lpotter> I even thought about changing those to use QDBusAbstractIn
| Lorn Potter (lorn-potter) wrote : | #3 |
Added some error reporting:
QNetworkManager
QNetworkManager
| Michael Zanetti (mzanetti) wrote : | #4 |
This upstream patch removes the use of Introspect: https:/
However, apparmor still prevents the required Get calls on properties so it still doesn't work and prints the error pasted in comment #3.
| affects: | apparmor-easyprof-ubuntu → apparmor-easyprof-ubuntu (Ubuntu) |
| Jamie Strandboge (jdstrand) wrote : | #5 |
There are explicit deny rules for talking to NetworkManager that silence the denials. Apps are supposed to use connectivity-api instead. (QNetworkSessio
| Lorn Potter (lorn-potter) wrote : | #6 |
QNetworkSession is part of Qt. Making isOpen use connectivity-api will not work, because the QNetworkSession state isn't necessarily a one to one relationship to the connectivity state.
QNetworkAccessM
So any Qml or Qt app that uses QNetworkAccessM
Take for example this:
QNetworkAccessM
manager-
QNAM uses a QNetworkConfigu
| Dmitry Shachnev (mitya57) wrote : | #7 |
Is https:/
| Michael Zanetti (mzanetti) wrote : | #8 |
@Dimitry, this upstream patch doesn't seem to completely get around this issue, however, it should for sure improve the situation and if we decide to punch a hole into apparmors policy, this patch would require less punching. So IMO, yes, let's add it.
| Launchpad Janitor (janitor) wrote : | #9 |
This bug was fixed in the package qtbase-
---------------
qtbase-
[ Dmitry Shachnev ]
* Add a patch to prefer QPA implementation for systemtrayicon, when it
is available. This makes tray icons work on Plasma 5.
* Refresh debian/
twice.
[ Timo Jyrinki ]
* Update Use-a-property-
not print warnings about using blocking call.
* Add a patch Refactor-
(LP: #1404188)
-- Dmitry Shachnev <email address hidden> Tue, 27 Jan 2015 16:25:13 +0300
| Changed in qtbase-opensource-src (Ubuntu): | |
| status: | New → Fix Released |
| no longer affects: | apparmor-easyprof-ubuntu (Ubuntu) |
| Michael Zanetti (mzanetti) wrote : | #10 |
This is still not working
| Michael Zanetti (mzanetti) wrote : | #11 |
re-added apparmor-
| Jamie Strandboge (jdstrand) wrote : | #12 |
Sorry, this will not be fixed in apparmor-
| Launchpad Janitor (janitor) wrote : | #13 |
Status changed to 'Confirmed' because the bug affects multiple users.
| Changed in apparmor-easyprof-ubuntu (Ubuntu): | |
| status: | New → Confirmed |
| affects: | apparmor-easyprof-ubuntu → apparmor-easyprof-ubuntu (Ubuntu) |
| Changed in apparmor-easyprof-ubuntu (Ubuntu): | |
| status: | New → Won't Fix |
| Jamie Strandboge (jdstrand) wrote : | #14 |
Note, if someone presented a list of rules that need to be added to the policy that would fix this bug since 5.3.2+dfsg-4ubuntu9 was added, I'd be happy to review them. However, before you do, please see https:/
| Lorn Potter (lorn-potter) wrote : | #15 |
You do realize this means QNetworkAccessM
Any network request, GET, etc... done with Qt runs though QNetworkConfigu
I cannot test this, as my ubuntu phone is currently as good as bricked.
| Changed in qtbase-opensource-src (Ubuntu): | |
| status: | Fix Released → Confirmed |
| Changed in canonical-devices-system-image: | |
| status: | New → Confirmed |
| importance: | Undecided → High |
| assignee: | nobody → Zoltan Balogh (bzoltan) |
| milestone: | none → ww40-2015 |
| Timo Jyrinki (timo-jyrinki) wrote : | #16 |
There's now a PPA with a Qt build for vivid+overlay that allows you to experiment with the option of not using the NM bearer backend but the generic backend (with very limited functionality compared). With that you can get "all is fine" even with a click installed / confined nmsessiontest app. But this does bring the notorious bug #1357321 back. However, for comparison:
https:/
That is:
sudo apt-add-repository ppa:canonical-
sudo apt update
sudo vi /etc/apt/
# Add the following content to the file:
Package: *
Pin: release o=LP-PPA-
Pin-Priority: 1002
sudo apt upgrade
The mentioned -no-feature-
| Timo Jyrinki (timo-jyrinki) wrote : | #17 |
The dummier generic plugin works since it returns a result without actually checking anything. It does not seem to be realistic option to switch to it.
Currently there's no other offered solution than the apparmor way, and this bug would still need to get fixed. Would it be possible to push the earlier attempt to somewhere in bzr and we could try to refine it? Maybe for example one could get the Michael's test app to work with more restrictions even if the qtsysteminfo would not like it enough.
| Changed in apparmor-easyprof-ubuntu (Ubuntu): | |
| status: | Won't Fix → Confirmed |
| Timo Jyrinki (timo-jyrinki) wrote : | #18 |
The connectivity-api option was discussed in comment #6 and unlikely to solve the issue in a way to make developers like the bug filer happy. Other proper/robust solutions would include writing a proxy service to filter sensitive data out, or adding "a single nm api call that doesn't make the app traverse all of the nm api". Those however do not have a plan or an implementer at the moment.
For the apparmor policy relaxing option, Jamie opposes a policy that would expose MAC addresses, SSIDs etc to all apps. But there's possibility to try to experiment with the rules, by:
< jdstrand> this easiest thing to do is this: create an app with the networking policy group that does what people what it to do. install it. then modify the generated apparmor profile in /var/lib/
< jdstrand> then tail -f /var/log/syslog in one terminal, then launch the app to use whatever api people are trying to use. in the syslog there will be an apparmor denial. add a rule to allow the access to the profile, then reload the profile
< jdstrand> then repeat until you have a full list of rules. important-- the rules should be very specific (ie, interface, path and method are specified) so it is clear everything that is being exposed
< jdstrand> people may want to do 'sudo sysctl -w kernel.
| Timo Jyrinki (timo-jyrinki) wrote : | #19 |
Playing with it, I came up with the attached minimal set of rules to get the test case working. There's a whole majority of Network Manager dbus calls still being denied, and three allowed. Despite that I assume this minimal set reveals the discussed "too much", but it might be useful reference.
Using the patch as is results in log noise due to default being apparently "audit deny", and I didn't know how to "deny everything without audit like before, but allow these three exceptions to pass".
| Timo Jyrinki (timo-jyrinki) wrote : | #20 |
The still denied ones.
| tags: | added: patch |
| Changed in canonical-devices-system-image: | |
| milestone: | ww40-2015 → backlog |
| Jamie Strandboge (jdstrand) wrote : | #21 |
This is likely too specific (ActiveConnecti
+ dbus (send)
+ bus=system
+ interface=
+ path=/org/
+ member=GetAll
+ peer=(name=
This is too lenient:
+ dbus (send)
+ bus=system
+ interface=
+ path=/org/
+ member=GetAll
+ peer=(name=
The Get*() and Set() methods are precisely what I was talking about before because these methods specify what to get and set based on member arguments and thus cannot be further restriceted by apparmor. In other words, this method allows an app to get any property from network manager, which is far too lenient. Network manager is designed with a different trust model that does not fit within the context of trusted helpers. Namely, network manager relies on policy kit and assumes the user that is able to talk to it (via policy kit ACLs) is trusted. On touch, the app is not trusted but the user is allowed to talk to network manager. Therefore, network manager's current design does not afford itself to opening up its api in the manner requested by this patch.
Which gets us back to the several choices:
* use connectivity api instead. It was specifically designed for this. apps talk to connectivity api via its simple and safe api, and it talks to network manager.
* write a proxy that is able to inspect the member data and filter it accordingly.
* patch network manager to provide a safe api for the things apps need
connectivity api is implemented precisely to address the concerns in this bug and it seems clear (to me) that we should be using it. The proxy idea would work and other libraries wouldn't have to be patched (much) to use it, but is yet another service, is error prone and the hardest to implement in the short term. Patching network manager requires effort, increases maintenance costs and ultimately the same work for apps to use it as adjusting them to use connectivity api.
| Lorn Potter (lorn-potter) wrote : | #22 |
Not sure that QtBearer is being understood.
http://
QNetworkAccessM
QtNetwork / Bearer Management cannot be made to use connectivity-api. connectivity-api is much too simple. There is no way to control the interfaces and start a connection (wifi/mobile data, etc) to be made when a network request is made and there is no existing connection. There is no way to get list of network configurations/wifi API's, etc.
The only realistic solution I see is to either only use generic plugin or completely compile out use of bearermanagement (QtBase configured with —no-feature-
This way, people using QNetworkAccessM
Developers won't be mislead that they will have a fully working bearer (generic plugin has many issues in regards to a fully working bearer).
| Jamie Strandboge (jdstrand) wrote : | #23 |
Thanks Lorn, and just so I'm clear-- I don't think that QtNetwork/etc should be modified if it doesn't make sense for it in the general case.
All I'm getting at is untrusted apps shouldn't be able to control interfaces and start a connection as you mentioned, let alone get privileged info out of network manager. These untrusted apps simply need to know if they are online or not and maybe some other details that connectivity-api can provide. How they get that information I don't particularly care so long as they don't get this privileged access.
It seems clear that QtBearer is written with the traditional session/policykit trust model, which is fine, but it doesn't align with the app store trust model where apps are untrusted by the system and session, so perhaps your idea makes sense. I'll let others work out the details of what needs to change and how.
| Lorn Potter (lorn-potter) wrote : | #24 |
QtBearer just runs on top of the system networking, so if the platform specifies it doesn't allow start/stop of interfaces, like the generic bearer plugin, it is allowed to return an error of 'not allowed' or somesuch.
It's the current network-manager bearer plugin that does not take into account security limitations.
That said, a QtBearer plugin could be written using connectivity-api. It would simply supply one configuration "System configuration" or some name and advertise it is not able to start and stop interfaces/
Maybe I will do that today and you guys could use it or not.
| Lorn Potter (lorn-potter) wrote : | #25 |
Might try using bearer plugin based on connectivity-api
| Tony Espy (awe) wrote : | #26 |
A couple of comments.
I've actually been chasing down a DBus performance issue on touch since mid-Summer, related to NetworkManager and WiFi scanning.
The high-level summary is that we have a number of system processes listening for NM AccessPoint DBus signals on specific AccessPoint DBus objects, and never cleaning up the associated DBus watch rules when the access points are removed. This can lead to a single processing adding 5k match rules to the system bus if WiFi is enabled long enough. For details see bug #1480877, an in particular from the following comment onwards:
https:/
I've traced what I think is the cause to the bearer mgmt networkmanager plugin and am attempting to patch it.
Note, this bug that I'm now adding this comment to, is about a confined app's usage of QNetworkSession. I should remind folks that there are a number of system processes ( eg. unity8 ) that either use QNetworkSession directly, or via QNetworkAccessM
| Timo Jyrinki (timo-jyrinki) wrote : | #27 |
We need only a subset of the NM bearer features so it would be ok to replace or patch to limit its behavior.
What we need is existing QNAM instances to not fall dead if user is on 3G + wifi and then disables wifi, or alternatively if on 3G and wifi gets enabled the connections should migrate to wifi. I don't know if connectivity-api currently has what would be needed for the bearer.
We do not need network controlling in bearer since indicator-network handles that.
| Lorn Potter (lorn-potter) wrote : | #28 |
I tried a working connectivity-api bearer plugin (verified with unconfined test app) with the attached example app, and I still got app armor errors:
Syslog> Jan 21 06:55:34 ubuntu-phablet dbus[1809]: apparmor="DENIED" operation=
Even if we wanted to move to connectivity-api, we would need to fix those.
After looking further atks the connectivity-api, it is quite limited and cannot even detect when network is using mobile data or wifi.
We could:
* Use connectivity-api knowing that bearer functionality will be mostly broken, but should allow basic bearer use, and allow QNAM & friends to function unhindered.
* add some functionality to connectivity-api
| Jamie Strandboge (jdstrand) wrote : | #29 |
Note, there is already a 'connectivity' policy group that should allow this, but it is not included by default. Please adjust your security manifest to use both "networking" and "connectivity".
| Lorn Potter (lorn-potter) wrote : | #30 |
After adding 'connectivity' to the manifest, it is working with connectivity-api plugin
| Lorn Potter (lorn-potter) wrote : | #31 |
If this is still an issue Silo 032 currently has a fix for this. Using this set of patches I do not recall having any issues with isOpen
This bug seems to affect dekko (See Dan's comment on bug 1501912 ), but this is probably not critical.
| Changed in qtbase-opensource-src (Ubuntu): | |
| status: | Confirmed → Fix Committed |
| Changed in apparmor-easyprof-ubuntu (Ubuntu): | |
| status: | Confirmed → Invalid |
| Changed in canonical-devices-system-image: | |
| status: | Confirmed → Fix Committed |
| Changed in qtbase-opensource-src (Ubuntu RTM): | |
| status: | New → Fix Committed |
| Changed in qtbase-opensource-src (Ubuntu): | |
| status: | Fix Committed → Fix Released |
| Changed in qtbase-opensource-src (Ubuntu RTM): | |
| status: | Fix Committed → Fix Released |
| Changed in canonical-devices-system-image: | |
| milestone: | backlog → ww08-2016 |
| Changed in canonical-devices-system-image: | |
| status: | Fix Committed → Fix Released |
| Michael Zanetti (mzanetti) wrote : | #33 |
I've just tested this. It is *NOT* fixed.
| Changed in canonical-devices-system-image: | |
| status: | Fix Released → Confirmed |
| Changed in qtbase-opensource-src (Ubuntu): | |
| status: | Fix Released → Confirmed |
| Changed in qtbase-opensource-src (Ubuntu RTM): | |
| status: | Fix Released → Confirmed |
| Changed in canonical-devices-system-image: | |
| milestone: | ww08-2016 → 11 |
| Lorn Potter (lorn-potter) wrote : | #34 |
So the solution to this is using connectivity-api in a new bearer plugin.
The connectivity-api based bearer plugin is blocked by the bandwidthLimita
https:/
| Changed in canonical-devices-system-image: | |
| milestone: | 11 → 12 |
| Changed in canonical-devices-system-image: | |
| milestone: | 12 → 13 |
| Changed in canonical-devices-system-image: | |
| milestone: | 13 → backlog |
| Changed in qtbase-opensource-src (Ubuntu): | |
| assignee: | Lorn Potter (lorn-potter) → nobody |


Looks like an app armour thing.
Debug-helper> Executing /usr/bin/ qmlscene[ '/usr/bin/ qmlscene' , '$@', 'share/ qml/nmsessionte st/nmsessiontes t.qml'] new_method_ call() were incorrect, assertion "_dbus_ check_is_ valid_path (path)" failed in file ../../dbus/ dbus-message. c line 1344. set_auto_ start() were incorrect, assertion "message != NULL" failed in file ../../dbus/ dbus-message. c line 3029. iter_init_ append( ) were incorrect, assertion "message != NULL" failed in file ../../dbus/ dbus-message. c line 2426. p.NetworkManage r" path "" interface "org.freedeskto p.DBus. Introspectable" member "Introspect": new_method_ call() were incorrect, assertion "_dbus_ check_is_ valid_path (path)" failed in file ../../dbus/ dbus-message. c line 1344. set_auto_ start() were incorrect, assertion "message != NULL" failed in file ../../dbus/ dbus-message. c line 3029. iter_init_ append( ) were incorrect, assertion "message != NULL" failed in file ../../dbus/ dbus-message. c line 2426. p.NetworkManage r" path "" interface "org.freedeskto p.DBus. Introspectable" member "Introspect": :handleSurfaceF ocusChange( focused= true) :handleSurfaceR esize(width= 540, height=919)
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
QDBusConnection: error: could not send message to service "org.freedeskto
using blocking call!
Using blocking call!
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
process 7885: arguments to dbus_message_
This is normally a bug in some application using the D-Bus library.
QDBusConnection: error: could not send message to service "org.freedeskto
using blocking call!
Using blocking call!
UbuntuWindow:
UbuntuWindow:
UbuntuClipboard - Got invalid serialized mime data. Ignoring it.
There was another bug mentioning that abstract dbus interface does not introspect, whereas QDBusInterface does
QDBusInterface is used all over in the nm QtBearer plugin.