CVE-2023-53166: power: supply: bq25890: Fix external_power_changed race
In the Linux kernel, the following vulnerability has been resolved:
power: supply: bq25890: Fix externalpowerchanged race
bq25890chargerexternalpowerchanged() dereferences bq->charger, which gets sets in bq25890powersupplyinit() like this:
bq->charger = devmpowersupplyregister(bq->dev, &bq->desc, &psycfg);
As soon as devmpowersupplyregister() has called deviceadd() the externalpowerchanged callback can get called. So there is a window where bq25890chargerexternalpowerchanged() may get called while bq->charger has not been set yet leading to a NULL pointer dereference.
This race hits during boot sometimes on a Lenovo Yoga Book 1 yb1-x90f when the chtwcovepwrsrc (extcon) powersupply is done with detecting the connected charger-type which happens to exactly hit the small window:
BUG: kernel NULL pointer dereference, address: 0000000000000018 <snip> RIP: 0010:powersupplyissuppliedby+0xb/0xb0 <snip> Call Trace: <TASK> powersupplygetsupplierproperty+0x19/0x50 classforeachdevice+0xb1/0xe0 powersupplygetpropertyfromsupplier+0x2e/0x50 bq25890chargerexternalpowerchanged+0x38/0x1b0 [bq25890charger] powersupplychangedwork+0x30/0x40 classforeachdevice+0xb1/0xe0 powersupplychangedwork+0x5f/0xe0 <snip>
Fixing this is easy. The externalpowerchanged callback gets passed the powersupply which will eventually get stored in bq->charger, so bq25890chargerexternalpowerchanged() can simply directly use the passed in psy argument which is always valid.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2023-53166?
CVE-2023-53166 is classified with a high severity due to the potential for race condition vulnerabilities in power supply management.
How do I fix CVE-2023-53166?
To mitigate CVE-2023-53166, users should update to the latest version of the Linux kernel where the vulnerability has been resolved.
What systems are affected by CVE-2023-53166?
CVE-2023-53166 affects the Linux kernel across various distributions that utilize the bq25890 power supply driver.
What type of vulnerability is CVE-2023-53166?
CVE-2023-53166 is a race condition vulnerability specifically related to external power state changes in power management.
Is there any workaround for CVE-2023-53166?
Currently, the best approach is to apply the kernel update as a workaround for CVE-2023-53166 since no other official workaround has been provided.