Skip to content

Commit 75612c1

Browse files
ecsvgregkh
authored andcommitted
batman-adv: prevent ELP transmission interval underflow
commit 5e50d4b upstream. batadv_v_elp_start_timer() enqeues a delayed work. The time when it starts is randomly chosen between (elp_interval - BATADV_JITTER) and (elp_interval + BATADV_JITTER). The configured elp_interval must therefore be larger or equal to BATADV_JITTER to avoid that it causes an underflow of the unsigned integer. If this would happen, then a "fast" ELP interval would turn into a "day long" delay. At the same time, it must not be larger than the maximum value the variable can store. Cc: stable@kernel.org Fixes: a108008 ("batman-adv: Add elp_interval hardif genl configuration") [ Context ] Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 43733e5 commit 75612c1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

net/batman-adv/netlink.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,15 @@ static int batadv_netlink_set_hardif(struct sk_buff *skb,
917917
#ifdef CONFIG_BATMAN_ADV_BATMAN_V
918918

919919
if (info->attrs[BATADV_ATTR_ELP_INTERVAL]) {
920+
u32 elp_interval;
921+
920922
attr = info->attrs[BATADV_ATTR_ELP_INTERVAL];
923+
elp_interval = nla_get_u32(attr);
924+
925+
elp_interval = min_t(u32, elp_interval, INT_MAX);
926+
elp_interval = max_t(u32, elp_interval, BATADV_JITTER);
921927

922-
atomic_set(&hard_iface->bat_v.elp_interval, nla_get_u32(attr));
928+
atomic_set(&hard_iface->bat_v.elp_interval, elp_interval);
923929
}
924930

925931
if (info->attrs[BATADV_ATTR_THROUGHPUT_OVERRIDE]) {

0 commit comments

Comments
 (0)