Bug 105625

Summary: [PATCH] Fix crash leading to system freeze with some iOS devices
Product: upower Reporter: Martin S. <freedesktop-bugzilla>
Component: generalAssignee: Richard Hughes <richard>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: [PATCH 1/2] linux: Prevent crash after attaching an Apple TV
[PATCH 2/2] linux: Check "HasBattery" key for newer iOS versions

Description Martin S. 2018-03-20 13:55:01 UTC
After I plugged in an Apple TV 4, I noticed that upower goes havoc crashing and being respawned ending up in a loop eating up all CPU and freezing the system.

Investigating the issue lead me to the workflow that queries for battery support of the iOS device. Since this device does not feature a battery, it does not provide the "BatteryIsCharging" key. As there is no further check in the code before attempting to get the boolean value of the node upower will crash.

I'll cook up a patch to fix this and add another query for newer iOS versions.
Comment 1 Martin S. 2018-03-20 14:12:27 UTC
Created attachment 138223 [details] [review]
[PATCH 1/2] linux: Prevent crash after attaching an Apple TV

As Apple TVs do not have a battery and do not provide the "BatteryIsCharging" lockdown key, upower would crash due to a missing check whether the retrieved node is actually valid.
Comment 2 Martin S. 2018-03-20 14:13:22 UTC
Created attachment 138224 [details] [review]
[PATCH 2/2] linux: Check "HasBattery" key for newer iOS versions

This adds an extra check to query if the iOS device has a battery at all before actually trying to retrieve the battery status. Should still work for older iOS versions which do not provide this key.
Comment 3 Bastien Nocera 2018-03-20 14:30:38 UTC
Both committed to master, thanks!

commit 598fdbc5e00573d1b56d4107798f82bd615842b3
Author: Martin Szulecki <martin.szulecki@libimobiledevice.org>
Date:   Tue Mar 20 15:04:26 2018 +0100

    linux: Check "HasBattery" key for newer iOS versions
    
    This adds an extra check to query if the iOS device has a
    battery at all before actually trying to retrieve the battery
    status. Should still work for older iOS versions which do not
    provide this key.
    
    https://bugzilla.freedesktop.org/show_bug.cgi?id=105625

commit 9357aa60e7773d997e6208c9b3cab09adc166e38
Author: Martin Szulecki <martin.szulecki@libimobiledevice.org>
Date:   Tue Mar 20 15:00:21 2018 +0100

    linux: Prevent crash after attaching an Apple TV
    
    As Apple TVs do not have a battery and do not provide the
    "BatteryIsCharging" lockdown key, upower would crash due to a
    missing check whether the retrieved node is actually valid.
    
    https://bugzilla.freedesktop.org/show_bug.cgi?id=105625

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.