net: enetc: fix command BD ring issues
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 0 repliesApplied 2/2
- v12 patches 0 repliesSuperseded
Changes in v2 from the cover letter
1. Check the SBE bit in netc_xmit_ntmp_cmd().
2. Fix DMA buffer leak issue when netc_xmit_ntmp_cmd returns -EBUSY.
3. Check swcbd->buf in ntmp_free_data_mem().
4. Move ring_lock ownership to the caller to ensure the response buffer cannot be reclaimed prematurely. So add the helpers ntmp_unlock_cbdr() and ntmp_select_and_lock_cbdr().
---
Patches in v2 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | net: enetc: correct the command BD ring consumer indexdrivers/ drivers/ | +12 | 0 replies | Applied |
| 2/2 | net: enetc: fix NTMP DMA use-after-free issuedrivers/ drivers/ include/ | +134 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 net 0/2] net: enetc: fix command BD ring issues
Currently, the implementation of command BD ring has two issues, one is that the driver may obtain wrong consumer index of the ring, because the driver does not mask out the SBE bit of the CIR value, so a wrong index will be obtained when a SBE error ouccrs. The other one is that the DMA buffer may be used after free. If netc_xmit_ntmp_cmd() times out and returns an error, the pending command is not explicitly aborted, while ntmp_free_data_mem() unconditionally frees the DMA buffer. If the buffer has already been reallocated elsewhere, this may lead to silent memory corruption. Because the hardware eventually processes the pending command and perform a DMA write of the response to the physical address of the freed buffer. So this patch set is to fix these two issues.
---
v2:
1. Check the SBE bit in netc_xmit_ntmp_cmd().
2. Fix DMA buffer leak issue when netc_xmit_ntmp_cmd returns -EBUSY.
3. Check swcbd->buf in ntmp_free_data_mem().
4. Move ring_lock ownership to the caller to ensure the response buffer cannot be reclaimed prematurely. So add the helpers ntmp_unlock_cbdr() and ntmp_select_and_lock_cbdr().
---
Wei Fang (2):
net: enetc: correct the command BD ring consumer index
net: enetc: fix NTMP DMA use-after-free issue
drivers/net/ethernet/freescale/enetc/ntmp.c | 217 +++++++++++------- .../ethernet/freescale/enetc/ntmp_private.h | 10 +- include/linux/fsl/ntmp.h | 9 +- 3 files changed, 141 insertions(+), 95 deletions(-)
Signature · 1 line
2.34.1