0052-wifi-ath11k-Fix-invalid-management-rx-frame-length-i.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From 447b0398a9cd41ca343dfd43e555af92d6214487 Mon Sep 17 00:00:00 2001
  2. From: Bhagavathi Perumal S <quic_bperumal@quicinc.com>
  3. Date: Fri, 24 Mar 2023 16:57:00 +0200
  4. Subject: [PATCH] wifi: ath11k: Fix invalid management rx frame length issue
  5. The WMI management rx event has multiple arrays of TLVs, however the common
  6. WMI TLV parser won't handle multiple TLV tags of same type.
  7. So the multiple array tags of WMI management rx TLV is parsed incorrectly
  8. and the length calculated becomes wrong when the target sends multiple
  9. array tags.
  10. Add separate TLV parser to handle multiple arrays for WMI management rx
  11. TLV. This fixes invalid length issue when the target sends multiple array
  12. tags.
  13. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  14. Signed-off-by: Bhagavathi Perumal S <quic_bperumal@quicinc.com>
  15. Co-developed-by: Nagarajan Maran <quic_nmaran@quicinc.com>
  16. Signed-off-by: Nagarajan Maran <quic_nmaran@quicinc.com>
  17. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  18. Link: https://lore.kernel.org/r/20230320133840.30162-1-quic_nmaran@quicinc.com
  19. ---
  20. drivers/net/wireless/ath/ath11k/wmi.c | 45 +++++++++++++++++++++------
  21. 1 file changed, 35 insertions(+), 10 deletions(-)
  22. --- a/drivers/net/wireless/ath/ath11k/wmi.c
  23. +++ b/drivers/net/wireless/ath/ath11k/wmi.c
  24. @@ -82,6 +82,12 @@ struct wmi_tlv_fw_stats_parse {
  25. bool chain_rssi_done;
  26. };
  27. +struct wmi_tlv_mgmt_rx_parse {
  28. + const struct wmi_mgmt_rx_hdr *fixed;
  29. + const u8 *frame_buf;
  30. + bool frame_buf_done;
  31. +};
  32. +
  33. static const struct wmi_tlv_policy wmi_tlv_policies[] = {
  34. [WMI_TAG_ARRAY_BYTE]
  35. = { .min_len = 0 },
  36. @@ -5633,28 +5639,49 @@ static int ath11k_pull_vdev_stopped_para
  37. return 0;
  38. }
  39. +static int ath11k_wmi_tlv_mgmt_rx_parse(struct ath11k_base *ab,
  40. + u16 tag, u16 len,
  41. + const void *ptr, void *data)
  42. +{
  43. + struct wmi_tlv_mgmt_rx_parse *parse = data;
  44. +
  45. + switch (tag) {
  46. + case WMI_TAG_MGMT_RX_HDR:
  47. + parse->fixed = ptr;
  48. + break;
  49. + case WMI_TAG_ARRAY_BYTE:
  50. + if (!parse->frame_buf_done) {
  51. + parse->frame_buf = ptr;
  52. + parse->frame_buf_done = true;
  53. + }
  54. + break;
  55. + }
  56. + return 0;
  57. +}
  58. +
  59. static int ath11k_pull_mgmt_rx_params_tlv(struct ath11k_base *ab,
  60. struct sk_buff *skb,
  61. struct mgmt_rx_event_params *hdr)
  62. {
  63. - const void **tb;
  64. + struct wmi_tlv_mgmt_rx_parse parse = { };
  65. const struct wmi_mgmt_rx_hdr *ev;
  66. const u8 *frame;
  67. int ret;
  68. - tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
  69. - if (IS_ERR(tb)) {
  70. - ret = PTR_ERR(tb);
  71. - ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
  72. + ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len,
  73. + ath11k_wmi_tlv_mgmt_rx_parse,
  74. + &parse);
  75. + if (ret) {
  76. + ath11k_warn(ab, "failed to parse mgmt rx tlv %d\n",
  77. + ret);
  78. return ret;
  79. }
  80. - ev = tb[WMI_TAG_MGMT_RX_HDR];
  81. - frame = tb[WMI_TAG_ARRAY_BYTE];
  82. + ev = parse.fixed;
  83. + frame = parse.frame_buf;
  84. if (!ev || !frame) {
  85. ath11k_warn(ab, "failed to fetch mgmt rx hdr");
  86. - kfree(tb);
  87. return -EPROTO;
  88. }
  89. @@ -5673,7 +5700,6 @@ static int ath11k_pull_mgmt_rx_params_tl
  90. if (skb->len < (frame - skb->data) + hdr->buf_len) {
  91. ath11k_warn(ab, "invalid length in mgmt rx hdr ev");
  92. - kfree(tb);
  93. return -EPROTO;
  94. }
  95. @@ -5685,7 +5711,6 @@ static int ath11k_pull_mgmt_rx_params_tl
  96. ath11k_ce_byte_swap(skb->data, hdr->buf_len);
  97. - kfree(tb);
  98. return 0;
  99. }