* [B.A.T.M.A.N.] [PATCH maint] batman-adv: compat: initialize sinfo in cfg80211_get_station
@ 2018-06-06 15:35 Sven Eckelmann
2018-06-12 19:45 ` Sven Eckelmann
0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2018-06-06 15:35 UTC (permalink / raw)
To: b.a.t.m.a.n
Most of the implementations behind cfg80211_get_station will not initialize
sinfo to zero before manipulating it. For example, the member "filled",
which indicates the filled in parts of this struct, is often only modified
by enabling certain bits in the bitfield while keeping the remaining bits
in their original state. A caller without a preinitialized sinfo.filled can
then no longer decide which parts of sinfo were filled in by
cfg80211_get_station (or actually the underlying implementations).
cfg80211_get_station must therefore take care that sinfo is initialized to
zero. Otherwise, the caller may tries to read information which was not
filled in and which must therefore also be considered uninitialized. In
batadv_v_elp_get_throughput's case, an invalid "random" expected throughput
may be stored for this neighbor and thus the B.A.T.M.A.N V algorithm may
switch to non-optimal neighbors for certain destinations.
batman-adv's compat layer must take care of intializing sinfo until it is
fixed in the upstream kernel.
Fixes: 7406353d43c8 ("cfg80211: implement cfg80211_get_station cfg80211 API")
Reported-by: Thomas Lauer <holminateur@gmail.com>
Reported-by: Marcel Schmidt <ff.z-casparistrasse@mailbox.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
compat-include/net/cfg80211.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h
index 50031788..79c028af 100644
--- a/compat-include/net/cfg80211.h
+++ b/compat-include/net/cfg80211.h
@@ -43,6 +43,7 @@ static inline int cfg80211_get_station(struct net_device *dev,
#endif /* < KERNEL_VERSION(3, 16, 0) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
#if !IS_ENABLED(CONFIG_CFG80211) && \
@@ -61,4 +62,21 @@ static inline int batadv_cfg80211_get_station(struct net_device *dev,
#endif /* < KERNEL_VERSION(4, 8, 0) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211)
+
+/* cfg80211 fix: https://patchwork.kernel.org/patch/10449857/ */
+static inline int batadv_cfg80211_get_station(struct net_device *dev,
+ const u8 *mac_addr,
+ struct station_info *sinfo)
+{
+ memset(sinfo, 0, sizeof(*sinfo));
+ return cfg80211_get_station(dev, mac_addr, sinfo);
+}
+
+#define cfg80211_get_station(dev, mac_addr, sinfo) \
+ batadv_cfg80211_get_station(dev, mac_addr, sinfo)
+
+#endif /* < KERNEL_VERSION(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ */
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH maint] batman-adv: compat: initialize sinfo in cfg80211_get_station
2018-06-06 15:35 [B.A.T.M.A.N.] [PATCH maint] batman-adv: compat: initialize sinfo in cfg80211_get_station Sven Eckelmann
@ 2018-06-12 19:45 ` Sven Eckelmann
0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2018-06-12 19:45 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]
On Mittwoch, 6. Juni 2018 17:35:29 CEST Sven Eckelmann wrote:
> Most of the implementations behind cfg80211_get_station will not initialize
> sinfo to zero before manipulating it. For example, the member "filled",
> which indicates the filled in parts of this struct, is often only modified
> by enabling certain bits in the bitfield while keeping the remaining bits
> in their original state. A caller without a preinitialized sinfo.filled can
> then no longer decide which parts of sinfo were filled in by
> cfg80211_get_station (or actually the underlying implementations).
>
> cfg80211_get_station must therefore take care that sinfo is initialized to
> zero. Otherwise, the caller may tries to read information which was not
> filled in and which must therefore also be considered uninitialized. In
> batadv_v_elp_get_throughput's case, an invalid "random" expected throughput
> may be stored for this neighbor and thus the B.A.T.M.A.N V algorithm may
> switch to non-optimal neighbors for certain destinations.
>
> batman-adv's compat layer must take care of intializing sinfo until it is
> fixed in the upstream kernel.
>
> Fixes: 7406353d43c8 ("cfg80211: implement cfg80211_get_station cfg80211 API")
> Reported-by: Thomas Lauer <holminateur@gmail.com>
> Reported-by: Marcel Schmidt <ff.z-casparistrasse@mailbox.org>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> compat-include/net/cfg80211.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
Added as d7280ffad5e9 [1]
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/d7280ffad5e9025bc6c26f9ad4925fd0797fb8db
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-12 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 15:35 [B.A.T.M.A.N.] [PATCH maint] batman-adv: compat: initialize sinfo in cfg80211_get_station Sven Eckelmann
2018-06-12 19:45 ` Sven Eckelmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox