978-ath10k-fix-possible-out-of-bound-access-of-ath10k_ra.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From: Sriram R <[email protected]>
  2. Date: Wed, 3 Oct 2018 08:43:50 +0530
  3. Subject: [PATCH] ath10k: fix possible out of bound access of ath10k_rates array
  4. While using 'ath10k_mac_get_rate_hw_value()' to obtain the hw value
  5. from the passed bitrate, there is a chance of out of bound array access
  6. when wrong bitrate is passed. This is fixed by comparing the bitrates
  7. within the correct size of the ath10k_rates array.
  8. Fixes commit f279294e9ee2 ("ath10k: add support for configuring management
  9. packet rate"). Also correction made to some indents used in the above commit.
  10. Signed-off-by: Sriram R <[email protected]>
  11. Signed-off-by: Kalle Valo <[email protected]>
  12. Origin: backport, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e141eea7dd8525dd1ef7a925459e455b4d307f
  13. ---
  14. --- a/drivers/net/wireless/ath/ath10k/mac.c
  15. +++ b/drivers/net/wireless/ath/ath10k/mac.c
  16. @@ -166,7 +166,7 @@ static int ath10k_mac_get_rate_hw_value(
  17. if (ath10k_mac_bitrate_is_cck(bitrate))
  18. hw_value_prefix = WMI_RATE_PREAMBLE_CCK << 6;
  19. - for (i = 0; i < sizeof(ath10k_rates); i++) {
  20. + for (i = 0; i < ARRAY_SIZE(ath10k_rates); i++) {
  21. if (ath10k_rates[i].bitrate == bitrate)
  22. return hw_value_prefix | ath10k_rates[i].hw_value;
  23. }
  24. @@ -5699,22 +5699,22 @@ static void ath10k_bss_info_changed(stru
  25. return;
  26. }
  27. - sband = ar->hw->wiphy->bands[def.chan->band];
  28. - basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1;
  29. - bitrate = sband->bitrates[basic_rate_idx].bitrate;
  30. -
  31. - hw_rate_code = ath10k_mac_get_rate_hw_value(bitrate);
  32. - if (hw_rate_code < 0) {
  33. - ath10k_warn(ar, "bitrate not supported %d\n", bitrate);
  34. - mutex_unlock(&ar->conf_mutex);
  35. - return;
  36. - }
  37. + sband = ar->hw->wiphy->bands[def.chan->band];
  38. + basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1;
  39. + bitrate = sband->bitrates[basic_rate_idx].bitrate;
  40. +
  41. + hw_rate_code = ath10k_mac_get_rate_hw_value(bitrate);
  42. + if (hw_rate_code < 0) {
  43. + ath10k_warn(ar, "bitrate not supported %d\n", bitrate);
  44. + mutex_unlock(&ar->conf_mutex);
  45. + return;
  46. + }
  47. - vdev_param = ar->wmi.vdev_param->mgmt_rate;
  48. - ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
  49. - hw_rate_code);
  50. - if (ret)
  51. - ath10k_warn(ar, "failed to set mgmt tx rate %d\n", ret);
  52. + vdev_param = ar->wmi.vdev_param->mgmt_rate;
  53. + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
  54. + hw_rate_code);
  55. + if (ret)
  56. + ath10k_warn(ar, "failed to set mgmt tx rate %d\n", ret);
  57. }
  58. mutex_unlock(&ar->conf_mutex);