[PATCH net 0/4] ionic: fix register reads racing the BAR unmap on PCI reset

From: Nikhil P. Rao

Date: Tue Dec 01 2026 - 19:39:26 EST


A PCI reset of an ionic device runs ionic_reset_prepare(), which ends
in ionic_clear_pci(): it clears the driver's pointers into BAR0 and
unmaps it. Several readers test one of those pointers and then read
through it without synchronizing with that teardown, so a reset that
lands between the test and the read makes them access the unmapped
BAR. This series closes those windows.

Patch 1 clears and sets the device command registers under
dev_cmd_lock and takes the lock in the two readers that did not.

Patch 2 turns the lockless device info readers (firmware status,
heartbeat and the ethtool register dump) into RCU readers and has the
teardown wait for them.

Patch 3 clears the PHC counter registers under phc->lock when the
reset starts and has the PHC operations check them under that lock.

Patch 4 holds queue_lock while ethtool -C writes the interrupt control
registers, so the update cannot race the queue teardown.

The races in patches 1-3 were reproduced on an AMD Pensando NIC under
KASAN by holding the reader between its check and its access with a
test-only kprobe module while a PCI reset ran: without the series the
access faults on the unmapped BAR, with it the reset waits for the
reader or the reader backs off. The race in patch 4 was not reproduced.
The series was also run through 30 PCI resets per test under concurrent
ethtool, devlink and PHC load with lockdep enabled, without regressions.

The races in patches 1-3 were found by Sashiko and the one in patch 4
by a Claude Code review; Claude Code was also used in developing and
testing the fixes.

Signed-off-by: Nikhil P. Rao <nikhil.rao@xxxxxxx>
---
Nikhil P. Rao (4):
ionic: fix devcmds racing the BAR unmap on PCI reset
ionic: fix device info register reads racing the BAR unmap on PCI reset
ionic: fix PHC reads racing the BAR unmap on PCI reset
ionic: fix ethtool coalesce updates racing a PCI reset

.../net/ethernet/pensando/ionic/ionic_bus_pci.c | 21 ++++++++++++-
drivers/net/ethernet/pensando/ionic/ionic_dev.c | 34 +++++++++++++---------
.../net/ethernet/pensando/ionic/ionic_ethtool.c | 18 ++++++++++--
drivers/net/ethernet/pensando/ionic/ionic_fw.c | 6 ++++
drivers/net/ethernet/pensando/ionic/ionic_lif.h | 2 +-
drivers/net/ethernet/pensando/ionic/ionic_phc.c | 20 +++++++++++--
6 files changed, 80 insertions(+), 21 deletions(-)
---
base-commit: 0e4c3240b03093264d501ab24c65726d29921987
change-id: 20261118-b4-pr60-5fd83c966e7a

Best regards,
--
Nikhil P. Rao <nikhil.rao@xxxxxxx>