379-cfg80211-initialize-sinfo-in-cfg80211_get_station.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 4f717a2589be649afddbbd3ac58b67ebfa7426f7 Mon Sep 17 00:00:00 2001
  2. From: Sven Eckelmann <[email protected]>
  3. Date: Wed, 6 Jun 2018 10:18:31 +0200
  4. Subject: [PATCH v2] cfg80211: initialize sinfo in cfg80211_get_station
  5. Most of the implementations behind cfg80211_get_station will not initialize
  6. sinfo to zero before manipulating it. For example, the member "filled",
  7. which indicates the filled in parts of this struct, is often only modified
  8. by enabling certain bits in the bitfield while keeping the remaining bits
  9. in their original state. A caller without a preinitialized sinfo.filled can
  10. then no longer decide which parts of sinfo were filled in by
  11. cfg80211_get_station (or actually the underlying implementations).
  12. cfg80211_get_station must therefore take care that sinfo is initialized to
  13. zero. Otherwise, the caller may tries to read information which was not
  14. filled in and which must therefore also be considered uninitialized. In
  15. batadv_v_elp_get_throughput's case, an invalid "random" expected throughput
  16. may be stored for this neighbor and thus the B.A.T.M.A.N V algorithm may
  17. switch to non-optimal neighbors for certain destinations.
  18. Fixes: 7406353d43c8 ("cfg80211: implement cfg80211_get_station cfg80211 API")
  19. Reported-by: Thomas Lauer <[email protected]>
  20. Reported-by: Marcel Schmidt <[email protected]>
  21. Cc: [email protected]
  22. Signed-off-by: Sven Eckelmann <[email protected]>
  23. Forwarded: https://patchwork.kernel.org/patch/10449857/
  24. ---
  25. net/wireless/util.c | 2 ++
  26. 1 file changed, 2 insertions(+)
  27. --- a/net/wireless/util.c
  28. +++ b/net/wireless/util.c
  29. @@ -1749,6 +1749,8 @@ int cfg80211_get_station(struct net_devi
  30. if (!rdev->ops->get_station)
  31. return -EOPNOTSUPP;
  32. + memset(sinfo, 0, sizeof(*sinfo));
  33. +
  34. return rdev_get_station(rdev, dev, mac_addr, sinfo);
  35. }
  36. EXPORT_SYMBOL(cfg80211_get_station);