Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest3 patches 2 repliesIn review
- v43 patches 0 repliesSuperseded
- v33 patches 0 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 3 patches | 0 replies | Superseded | |
| v1 | 1 patch | 1 reply | Superseded |
Changes in v5 from the cover letter
- Updated both lpss_spi_setup() and mrfld_spi_setup() in spi-pxa2xx-pci.c to consistently respect the force_pio module parameter across all supported PCI devices (avoiding hardcoded DMA enable on Merrifield systems).
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | Input: applespi - cancel pending work on driver removedrivers/ | +2 | 1 reply | |
| 2/3 | Input: applespi - fix NULL pointer dereference in tp_dim opendrivers/ | +7 | 0 replies | |
| 3/3 | spi: pxa2xx: disable DMA for Apple MacBook8,1drivers/ | +33 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference
Hi Dmitry, Mark, and the linux-input/linux-spi community,
This patch series addresses a long-standing DMA initialization timeout on the early 2015 12" MacBook (MacBook8,1) on any boot (including cold boot), as well as two pre-existing, high-severity UAF/NULL-pointer bugs in the applespi driver.
Changes in v5:
- Updated both lpss_spi_setup() and mrfld_spi_setup() in spi-pxa2xx-pci.c to consistently respect the force_pio module parameter across all supported PCI devices (avoiding hardcoded DMA enable on Merrifield systems).
Changes in v4:
- Reverted the runtime can_dma callback override from applespi.c to avoid architectural layering violation, data races (TOCTOU) with concurrent SPI transfers, and execute-after-free vulnerability upon module unload.
- Moved the DMI quirk forcing PIO mode for MacBook8,1 to the host PCI glue driver (spi-pxa2xx-pci.c) where LPSS setup occurs.
- Formatted the DMI match using a structured pxa2xx_spi_pci_dmi_table and helper function pxa2xx_spi_pci_can_dma().
- Added a force_pio module parameter in spi-pxa2xx-pci.c to allow other users to manually force PIO mode for debugging.
Changes in v3:
- Added a force_pio module parameter to applespi to allow users to manually disable DMA for SPI transfers.
- Resolved the execute-after-free vulnerability by unconditionally restoring the original can_dma callback (even if NULL) in the driver remove path.
- Fixed the probe timing issue by applying the can_dma override at the very beginning of applespi_probe() so that all early initialization transfers safely use PIO mode, and properly restoring it in all probe error paths.
- Documented the Bugzilla link in the commit message of Patch 1.
Changes in v2:
- Fixed an unbind/remove execute-after-free vulnerability by storing and restoring the host controller's original can_dma callback in applespi_probe() and applespi_remove().
- Split the fixes into a 3-patch logical series.
Patch 1 fixes a pre-existing UAF vulnerability in the driver unbind path by explicitly calling cancel_work_sync() on the asynchronous registration worker work struct before devres frees the driver private data.
Patch 2 fixes a pre-existing race condition in the debugfs interface where userspace could open the tp_dim file before the asynchronous worker has finished initializing applespi->touchpad_input_dev, leading to a NULL pointer dereference. We resolve this using smp_load_acquire() and checking for NULL.
Patch 3 introduces a structured DMI quirk and a force_pio module parameter in spi-pxa2xx-pci.c to disable DMA on MacBook8,1. This forces the controller to use the rock-solid PIO mode from the very beginning.
Best regards,
Shih-Yuan Lee
Shih-Yuan Lee (3):
Input: applespi - cancel pending work on driver remove
Input: applespi - fix NULL pointer dereference in tp_dim open
spi: pxa2xx: disable DMA for Apple MacBook8,1
drivers/input/keyboard/applespi.c | 10 ++++++++- drivers/spi/spi-pxa2xx-pci.c | 35 +++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.5