Bug 105625 - [PATCH] Fix crash leading to system freeze with some iOS devices
Summary: [PATCH] Fix crash leading to system freeze with some iOS devices
Status: RESOLVED FIXED
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium major
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-20 13:55 UTC by Martin S.
Modified: 2018-03-20 14:30 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
[PATCH 1/2] linux: Prevent crash after attaching an Apple TV (1019 bytes, patch)
2018-03-20 14:12 UTC, Martin S.
Details | Splinter Review
[PATCH 2/2] linux: Check "HasBattery" key for newer iOS versions (1.47 KB, patch)
2018-03-20 14:13 UTC, Martin S.
Details | Splinter Review

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.