Skip to contentSkip to conversation

hwmon: (sis5595) potential null pointer dereference in probe

DISCUSSION Evgeny Novikov 2 participants 3 messages Aug 4, 2020 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

sis5595_pci_probe() registers platform driver callbacks and just then initializes global pointer variable s_bridge. sis5595_probe() may dereference it before this happens that can result in null pointer dereference.

We can not swap registration of platform driver callbacks with initialization of s_bridge since sm_sis5595_exit() assumes the current order. Perhaps it has sense to implement a pci_driver.remove callback that will take care about deregistration of platform driver callbacks.

Found by Linux Driver Verification project (linuxtesting.org).

maintainer
#1 lore raw
Quoted 5 lines · Evgeny Novikov

sis5595_pci_probe() registers platform driver callbacks and just then initializes global pointer variable s_bridge. sis5595_probe() may dereference it before this happens that can result in null pointer dereference.

sis5595_probe() is only called after the device is registered, which happens in sis5595_device_add() after s_bridge is set. This is a southbridge, so there won't be any hot insertion/removal events.

Quoted 6 lines

We can not swap registration of platform driver callbacks with initialization of s_bridge since sm_sis5595_exit() assumes the current order. Perhaps it has sense to implement a pci_driver.remove callback that will take care about deregistration of platform driver callbacks.

Agreed regarding the remove function. However, given the age of the chip, I'd rather remove the driver than spending time on cleanup efforts. This looks like a perfect candidate for depreciation.

Guenter

#2 lore raw

04.08.2020, 17:33, "Guenter Roeck" <[email protected]>:

Quoted 10 lines · Evgeny Novikov
Quoted 4 lines

 sis5595_pci_probe() registers platform driver callbacks and just then initializes global pointer variable s_bridge. sis5595_probe() may dereference it before this happens that can result in null pointer dereference.

sis5595_probe() is only called after the device is registered, which happens in sis5595_device_add() after s_bridge is set. This is a southbridge, so there won't be any hot insertion/removal events.

Thank you for this hint. We need to tune our models appropriately.

Quoted 10 lines
Quoted 5 lines

 We can not swap registration of platform driver callbacks with initialization of s_bridge since sm_sis5595_exit() assumes the current order. Perhaps it has sense to implement a pci_driver.remove callback that will take care about deregistration of platform driver callbacks.

Agreed regarding the remove function. However, given the age of the chip, I'd rather remove the driver than spending time on cleanup efforts. This looks like a perfect candidate for depreciation.

This is completely up to you. Anyway the driver does not have the bug.

Best regards,
Evgeny

Quoted 1 line

Guenter