Merge pull request #217 from HRogge/master
[feed/routing.git] / batman-adv / patches / 0002-batman-adv-Avoid-nullptr-dereference-in-dat-after-vl.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sat, 2 Jul 2016 09:52:14 +0200
3 Subject: [PATCH] batman-adv: Avoid nullptr dereference in dat after vlan_insert_tag
4
5 vlan_insert_tag can return NULL on errors. The distributed arp table code
6 therefore has to check the return value of vlan_insert_tag for NULL before
7 it can safely operate on this pointer.
8
9 Fixes: 53c6c262a581 ("batman-adv: tag locally generated ARP reply if needed")
10 Signed-off-by: Sven Eckelmann <sven@narfation.org>
11 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
12
13 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/898382d11fa1f737cd4f7033db1088c601fd11ed
14 ---
15 net/batman-adv/distributed-arp-table.c | 10 ++++++++--
16 1 file changed, 8 insertions(+), 2 deletions(-)
17
18 diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
19 index 278800a..aee3b39 100644
20 --- a/net/batman-adv/distributed-arp-table.c
21 +++ b/net/batman-adv/distributed-arp-table.c
22 @@ -1009,9 +1009,12 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
23 if (!skb_new)
24 goto out;
25
26 - if (vid & BATADV_VLAN_HAS_TAG)
27 + if (vid & BATADV_VLAN_HAS_TAG) {
28 skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
29 vid & VLAN_VID_MASK);
30 + if (!skb_new)
31 + goto out;
32 + }
33
34 skb_reset_mac_header(skb_new);
35 skb_new->protocol = eth_type_trans(skb_new,
36 @@ -1089,9 +1092,12 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
37 */
38 skb_reset_mac_header(skb_new);
39
40 - if (vid & BATADV_VLAN_HAS_TAG)
41 + if (vid & BATADV_VLAN_HAS_TAG) {
42 skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
43 vid & VLAN_VID_MASK);
44 + if (!skb_new)
45 + goto out;
46 + }
47
48 /* To preserve backwards compatibility, the node has choose the outgoing
49 * format based on the incoming request packet type. The assumption is