diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 20 | ||||
-rw-r--r-- | net/batman-adv/bat_v_ogm.c | 18 | ||||
-rw-r--r-- | net/batman-adv/multicast.c | 8 | ||||
-rw-r--r-- | net/batman-adv/netlink.c | 2 |
4 files changed, 31 insertions, 17 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 240ed70912d6..d78938e3e008 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -277,17 +277,23 @@ static u8 batadv_hop_penalty(u8 tq, const struct batadv_priv *bat_priv) | |||
277 | * batadv_iv_ogm_aggr_packet() - checks if there is another OGM attached | 277 | * batadv_iv_ogm_aggr_packet() - checks if there is another OGM attached |
278 | * @buff_pos: current position in the skb | 278 | * @buff_pos: current position in the skb |
279 | * @packet_len: total length of the skb | 279 | * @packet_len: total length of the skb |
280 | * @tvlv_len: tvlv length of the previously considered OGM | 280 | * @ogm_packet: potential OGM in buffer |
281 | * | 281 | * |
282 | * Return: true if there is enough space for another OGM, false otherwise. | 282 | * Return: true if there is enough space for another OGM, false otherwise. |
283 | */ | 283 | */ |
284 | static bool batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, | 284 | static bool |
285 | __be16 tvlv_len) | 285 | batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, |
286 | const struct batadv_ogm_packet *ogm_packet) | ||
286 | { | 287 | { |
287 | int next_buff_pos = 0; | 288 | int next_buff_pos = 0; |
288 | 289 | ||
289 | next_buff_pos += buff_pos + BATADV_OGM_HLEN; | 290 | /* check if there is enough space for the header */ |
290 | next_buff_pos += ntohs(tvlv_len); | 291 | next_buff_pos += buff_pos + sizeof(*ogm_packet); |
292 | if (next_buff_pos > packet_len) | ||
293 | return false; | ||
294 | |||
295 | /* check if there is enough space for the optional TVLV */ | ||
296 | next_buff_pos += ntohs(ogm_packet->tvlv_len); | ||
291 | 297 | ||
292 | return (next_buff_pos <= packet_len) && | 298 | return (next_buff_pos <= packet_len) && |
293 | (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); | 299 | (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); |
@@ -315,7 +321,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, | |||
315 | 321 | ||
316 | /* adjust all flags and log packets */ | 322 | /* adjust all flags and log packets */ |
317 | while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, | 323 | while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, |
318 | batadv_ogm_packet->tvlv_len)) { | 324 | batadv_ogm_packet)) { |
319 | /* we might have aggregated direct link packets with an | 325 | /* we might have aggregated direct link packets with an |
320 | * ordinary base packet | 326 | * ordinary base packet |
321 | */ | 327 | */ |
@@ -1704,7 +1710,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, | |||
1704 | 1710 | ||
1705 | /* unpack the aggregated packets and process them one by one */ | 1711 | /* unpack the aggregated packets and process them one by one */ |
1706 | while (batadv_iv_ogm_aggr_packet(ogm_offset, skb_headlen(skb), | 1712 | while (batadv_iv_ogm_aggr_packet(ogm_offset, skb_headlen(skb), |
1707 | ogm_packet->tvlv_len)) { | 1713 | ogm_packet)) { |
1708 | batadv_iv_ogm_process(skb, ogm_offset, if_incoming); | 1714 | batadv_iv_ogm_process(skb, ogm_offset, if_incoming); |
1709 | 1715 | ||
1710 | ogm_offset += BATADV_OGM_HLEN; | 1716 | ogm_offset += BATADV_OGM_HLEN; |
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index fad95ef64e01..bc06e3cdfa84 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c | |||
@@ -631,17 +631,23 @@ batadv_v_ogm_process_per_outif(struct batadv_priv *bat_priv, | |||
631 | * batadv_v_ogm_aggr_packet() - checks if there is another OGM aggregated | 631 | * batadv_v_ogm_aggr_packet() - checks if there is another OGM aggregated |
632 | * @buff_pos: current position in the skb | 632 | * @buff_pos: current position in the skb |
633 | * @packet_len: total length of the skb | 633 | * @packet_len: total length of the skb |
634 | * @tvlv_len: tvlv length of the previously considered OGM | 634 | * @ogm2_packet: potential OGM2 in buffer |
635 | * | 635 | * |
636 | * Return: true if there is enough space for another OGM, false otherwise. | 636 | * Return: true if there is enough space for another OGM, false otherwise. |
637 | */ | 637 | */ |
638 | static bool batadv_v_ogm_aggr_packet(int buff_pos, int packet_len, | 638 | static bool |
639 | __be16 tvlv_len) | 639 | batadv_v_ogm_aggr_packet(int buff_pos, int packet_len, |
640 | const struct batadv_ogm2_packet *ogm2_packet) | ||
640 | { | 641 | { |
641 | int next_buff_pos = 0; | 642 | int next_buff_pos = 0; |
642 | 643 | ||
643 | next_buff_pos += buff_pos + BATADV_OGM2_HLEN; | 644 | /* check if there is enough space for the header */ |
644 | next_buff_pos += ntohs(tvlv_len); | 645 | next_buff_pos += buff_pos + sizeof(*ogm2_packet); |
646 | if (next_buff_pos > packet_len) | ||
647 | return false; | ||
648 | |||
649 | /* check if there is enough space for the optional TVLV */ | ||
650 | next_buff_pos += ntohs(ogm2_packet->tvlv_len); | ||
645 | 651 | ||
646 | return (next_buff_pos <= packet_len) && | 652 | return (next_buff_pos <= packet_len) && |
647 | (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); | 653 | (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); |
@@ -818,7 +824,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, | |||
818 | ogm_packet = (struct batadv_ogm2_packet *)skb->data; | 824 | ogm_packet = (struct batadv_ogm2_packet *)skb->data; |
819 | 825 | ||
820 | while (batadv_v_ogm_aggr_packet(ogm_offset, skb_headlen(skb), | 826 | while (batadv_v_ogm_aggr_packet(ogm_offset, skb_headlen(skb), |
821 | ogm_packet->tvlv_len)) { | 827 | ogm_packet)) { |
822 | batadv_v_ogm_process(skb, ogm_offset, if_incoming); | 828 | batadv_v_ogm_process(skb, ogm_offset, if_incoming); |
823 | 829 | ||
824 | ogm_offset += BATADV_OGM2_HLEN; | 830 | ogm_offset += BATADV_OGM2_HLEN; |
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 67d7f83009ae..1d5bdf3a4b65 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c | |||
@@ -2303,7 +2303,7 @@ __batadv_mcast_flags_dump(struct sk_buff *msg, u32 portid, | |||
2303 | 2303 | ||
2304 | while (bucket_tmp < hash->size) { | 2304 | while (bucket_tmp < hash->size) { |
2305 | if (batadv_mcast_flags_dump_bucket(msg, portid, cb, hash, | 2305 | if (batadv_mcast_flags_dump_bucket(msg, portid, cb, hash, |
2306 | *bucket, &idx_tmp)) | 2306 | bucket_tmp, &idx_tmp)) |
2307 | break; | 2307 | break; |
2308 | 2308 | ||
2309 | bucket_tmp++; | 2309 | bucket_tmp++; |
@@ -2420,8 +2420,10 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig) | |||
2420 | batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS); | 2420 | batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS); |
2421 | batadv_mcast_want_ipv4_update(bat_priv, orig, BATADV_NO_FLAGS); | 2421 | batadv_mcast_want_ipv4_update(bat_priv, orig, BATADV_NO_FLAGS); |
2422 | batadv_mcast_want_ipv6_update(bat_priv, orig, BATADV_NO_FLAGS); | 2422 | batadv_mcast_want_ipv6_update(bat_priv, orig, BATADV_NO_FLAGS); |
2423 | batadv_mcast_want_rtr4_update(bat_priv, orig, BATADV_NO_FLAGS); | 2423 | batadv_mcast_want_rtr4_update(bat_priv, orig, |
2424 | batadv_mcast_want_rtr6_update(bat_priv, orig, BATADV_NO_FLAGS); | 2424 | BATADV_MCAST_WANT_NO_RTR4); |
2425 | batadv_mcast_want_rtr6_update(bat_priv, orig, | ||
2426 | BATADV_MCAST_WANT_NO_RTR6); | ||
2425 | 2427 | ||
2426 | spin_unlock_bh(&orig->mcast_handler_lock); | 2428 | spin_unlock_bh(&orig->mcast_handler_lock); |
2427 | } | 2429 | } |
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 6f08fd122a8d..7e052d6f759b 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c | |||
@@ -164,7 +164,7 @@ batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype) | |||
164 | { | 164 | { |
165 | struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype); | 165 | struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype); |
166 | 166 | ||
167 | return attr ? nla_get_u32(attr) : 0; | 167 | return (attr && nla_len(attr) == sizeof(u32)) ? nla_get_u32(attr) : 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | /** | 170 | /** |