Skip to content

Commit 956a7ff

Browse files
committed
Merge tag 'batman-adv-fix-for-davem' of git://git.open-mesh.org/linux-merge
Antonio Quartulli says: ==================== In this patchset you can find the following fixes: 1) check skb size to avoid reading beyond its border when delivering payloads, by Sven Eckelmann 2) initialize last_seen time in neigh_node object to prevent cleanup routine from accidentally purge it, by Marek Lindner 3) release "recently added" slave interfaces upon virtual/batman interface shutdown, by Sven Eckelmann 4) properly decrease router object reference counter upon routing table update, by Sven Eckelmann 5) release queue slots when purging OGM packets of deactivating slave interface, by Linus Lüssing Patch 2 and 3 have no "Fixes:" tag because the offending commits date back to when batman-adv was not yet officially in the net tree. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents eb63efb + c4fdb6c commit 956a7ff

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

net/batman-adv/hard-interface.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
572572
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
573573
struct batadv_hard_iface *primary_if = NULL;
574574

575-
if (hard_iface->if_status == BATADV_IF_ACTIVE)
576-
batadv_hardif_deactivate_interface(hard_iface);
575+
batadv_hardif_deactivate_interface(hard_iface);
577576

578577
if (hard_iface->if_status != BATADV_IF_INACTIVE)
579578
goto out;

net/batman-adv/originator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node,
663663
ether_addr_copy(neigh_node->addr, neigh_addr);
664664
neigh_node->if_incoming = hard_iface;
665665
neigh_node->orig_node = orig_node;
666+
neigh_node->last_seen = jiffies;
666667

667668
/* extra reference for return */
668669
kref_init(&neigh_node->refcount);

net/batman-adv/routing.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
105105
neigh_node = NULL;
106106

107107
spin_lock_bh(&orig_node->neigh_list_lock);
108+
/* curr_router used earlier may not be the current orig_ifinfo->router
109+
* anymore because it was dereferenced outside of the neigh_list_lock
110+
* protected region. After the new best neighbor has replace the current
111+
* best neighbor the reference counter needs to decrease. Consequently,
112+
* the code needs to ensure the curr_router variable contains a pointer
113+
* to the replaced best neighbor.
114+
*/
115+
curr_router = rcu_dereference_protected(orig_ifinfo->router, true);
116+
108117
rcu_assign_pointer(orig_ifinfo->router, neigh_node);
109118
spin_unlock_bh(&orig_node->neigh_list_lock);
110119
batadv_orig_ifinfo_put(orig_ifinfo);

net/batman-adv/send.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,9 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
675675

676676
if (pending) {
677677
hlist_del(&forw_packet->list);
678+
if (!forw_packet->own)
679+
atomic_inc(&bat_priv->bcast_queue_left);
680+
678681
batadv_forw_packet_free(forw_packet);
679682
}
680683
}
@@ -702,6 +705,9 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
702705

703706
if (pending) {
704707
hlist_del(&forw_packet->list);
708+
if (!forw_packet->own)
709+
atomic_inc(&bat_priv->batman_queue_left);
710+
705711
batadv_forw_packet_free(forw_packet);
706712
}
707713
}

net/batman-adv/soft-interface.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,17 @@ void batadv_interface_rx(struct net_device *soft_iface,
408408
*/
409409
nf_reset(skb);
410410

411+
if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
412+
goto dropped;
413+
411414
vid = batadv_get_vid(skb, 0);
412415
ethhdr = eth_hdr(skb);
413416

414417
switch (ntohs(ethhdr->h_proto)) {
415418
case ETH_P_8021Q:
419+
if (!pskb_may_pull(skb, VLAN_ETH_HLEN))
420+
goto dropped;
421+
416422
vhdr = (struct vlan_ethhdr *)skb->data;
417423

418424
if (vhdr->h_vlan_encapsulated_proto != ethertype)
@@ -424,8 +430,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
424430
}
425431

426432
/* skb->dev & skb->pkt_type are set here */
427-
if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
428-
goto dropped;
429433
skb->protocol = eth_type_trans(skb, soft_iface);
430434

431435
/* should not be necessary anymore as we use skb_pull_rcsum()

0 commit comments

Comments
 (0)