0067-wifi-ath11k-Fix-SKB-corruption-in-REO-destination-ri.patch 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From f9fff67d2d7ca6fa8066132003a3deef654c55b1 Mon Sep 17 00:00:00 2001
  2. From: Nagarajan Maran <quic_nmaran@quicinc.com>
  3. Date: Mon, 17 Apr 2023 13:35:02 +0300
  4. Subject: [PATCH] wifi: ath11k: Fix SKB corruption in REO destination ring
  5. While running traffics for a long time, randomly an RX descriptor
  6. filled with value "0" from REO destination ring is received.
  7. This descriptor which is invalid causes the wrong SKB (SKB stored in
  8. the IDR lookup with buffer id "0") to be fetched which in turn
  9. causes SKB memory corruption issue and the same leads to crash
  10. after some time.
  11. Changed the start id for idr allocation to "1" and the buffer id "0"
  12. is reserved for error validation. Introduced Sanity check to validate
  13. the descriptor, before processing the SKB.
  14. Crash Signature :
  15. Unable to handle kernel paging request at virtual address 3f004900
  16. PC points to "b15_dma_inv_range+0x30/0x50"
  17. LR points to "dma_cache_maint_page+0x8c/0x128".
  18. The Backtrace obtained is as follows:
  19. [<8031716c>] (b15_dma_inv_range) from [<80313a4c>] (dma_cache_maint_page+0x8c/0x128)
  20. [<80313a4c>] (dma_cache_maint_page) from [<80313b90>] (__dma_page_dev_to_cpu+0x28/0xcc)
  21. [<80313b90>] (__dma_page_dev_to_cpu) from [<7fb5dd68>] (ath11k_dp_process_rx+0x1e8/0x4a4 [ath11k])
  22. [<7fb5dd68>] (ath11k_dp_process_rx [ath11k]) from [<7fb53c20>] (ath11k_dp_service_srng+0xb0/0x2ac [ath11k])
  23. [<7fb53c20>] (ath11k_dp_service_srng [ath11k]) from [<7f67bba4>] (ath11k_pci_ext_grp_napi_poll+0x1c/0x78 [ath11k_pci])
  24. [<7f67bba4>] (ath11k_pci_ext_grp_napi_poll [ath11k_pci]) from [<807d5cf4>] (__napi_poll+0x28/0xb8)
  25. [<807d5cf4>] (__napi_poll) from [<807d5f28>] (net_rx_action+0xf0/0x280)
  26. [<807d5f28>] (net_rx_action) from [<80302148>] (__do_softirq+0xd0/0x280)
  27. [<80302148>] (__do_softirq) from [<80320408>] (irq_exit+0x74/0xd4)
  28. [<80320408>] (irq_exit) from [<803638a4>] (__handle_domain_irq+0x90/0xb4)
  29. [<803638a4>] (__handle_domain_irq) from [<805bedec>] (gic_handle_irq+0x58/0x90)
  30. [<805bedec>] (gic_handle_irq) from [<80301a78>] (__irq_svc+0x58/0x8c)
  31. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  32. Signed-off-by: Nagarajan Maran <quic_nmaran@quicinc.com>
  33. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  34. Link: https://lore.kernel.org/r/20230403191533.28114-1-quic_nmaran@quicinc.com
  35. ---
  36. drivers/net/wireless/ath/ath11k/dp_rx.c | 9 ++++++---
  37. 1 file changed, 6 insertions(+), 3 deletions(-)
  38. --- a/drivers/net/wireless/ath/ath11k/dp_rx.c
  39. +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
  40. @@ -389,10 +389,10 @@ int ath11k_dp_rxbufs_replenish(struct at
  41. goto fail_free_skb;
  42. spin_lock_bh(&rx_ring->idr_lock);
  43. - buf_id = idr_alloc(&rx_ring->bufs_idr, skb, 0,
  44. - rx_ring->bufs_max * 3, GFP_ATOMIC);
  45. + buf_id = idr_alloc(&rx_ring->bufs_idr, skb, 1,
  46. + (rx_ring->bufs_max * 3) + 1, GFP_ATOMIC);
  47. spin_unlock_bh(&rx_ring->idr_lock);
  48. - if (buf_id < 0)
  49. + if (buf_id <= 0)
  50. goto fail_dma_unmap;
  51. desc = ath11k_hal_srng_src_get_next_entry(ab, srng);
  52. @@ -2665,6 +2665,9 @@ try_again:
  53. cookie);
  54. mac_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_PDEV_ID, cookie);
  55. + if (unlikely(buf_id == 0))
  56. + continue;
  57. +
  58. ar = ab->pdevs[mac_id].ar;
  59. rx_ring = &ar->dp.rx_refill_buf_ring;
  60. spin_lock_bh(&rx_ring->idr_lock);