Skip to contentSkip to conversation

net/vxlan: fix potential null pointer deference

PATCH In review Young Xiao 3 participants 3 messages May 31, 2019

Subsystems (2)
lore
Share & tools
lore

Young Xiao

author
#0 lore raw

PATCH 1/1 net/vxlan: fix potential null pointer deference

There is a possible null pointer deference bug in vxlan_fdb_info(), which is similar to the bug which was fixed in commit 6adc5fd6a142 ("net/neighbour: fix crash at dumping device-agnostic proxy entries").

---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +1 -1
index 5994d54..1ba5977 100644
@@ -274,7 +274,7 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
 	} else
 		ndm->ndm_family	= AF_BRIDGE;
 	ndm->ndm_state = fdb->state;
-	ndm->ndm_ifindex = vxlan->dev->ifindex;
+	ndm->ndm_ifindex = vxlan->dev ? vxlan->dev->ifindex : 0;
 	ndm->ndm_flags = fdb->flags;
 	if (rdst->offloaded)
 		ndm->ndm_flags |= NTF_OFFLOADED;
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 14 lines · Young Xiao

There is a possible null pointer deference bug in vxlan_fdb_info(), which is similar to the bug which was fixed in commit 6adc5fd6a142 ("net/neighbour: fix crash at dumping device-agnostic proxy entries").

---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +0 -0
index 5994d54..1ba5977 100644

drivers/net/vxlan.c static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan, · line 280

Quoted 8 lines
drivers/net/vxlan.c +1 -1
@@ -274,7 +274,7 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
 	} else
 		ndm->ndm_family	= AF_BRIDGE;
 	ndm->ndm_state = fdb->state;
-	ndm->ndm_ifindex = vxlan->dev->ifindex;
+	ndm->ndm_ifindex = vxlan->dev ? vxlan->dev->ifindex : 0;
 	ndm->ndm_flags = fdb->flags;
 	if (rdst->offloaded)
 		ndm->ndm_flags |= NTF_OFFLOADED;

vxlan->dev points to the struct net_device for this vxlan device. It can't be NULL.

I suggest to look for working reproducer for this kind of issue before adding additional, unneeded, checks. We want to avoid as many unneeded conditionals as possible.

Thanks,

Paolo

#2 lore raw
In reply to Young Xiao
Quoted 15 lines · Young Xiao

There is a possible null pointer deference bug in vxlan_fdb_info(), which is similar to the bug which was fixed in commit 6adc5fd6a142 ("net/neighbour: fix crash at dumping device-agnostic proxy entries").

---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +0 -0
index 5994d54..1ba5977 100644

drivers/net/vxlan.c static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan, · line 280

Quoted 8 lines
drivers/net/vxlan.c +1 -1
@@ -274,7 +274,7 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
 	} else
 		ndm->ndm_family	= AF_BRIDGE;
 	ndm->ndm_state = fdb->state;
-	ndm->ndm_ifindex = vxlan->dev->ifindex;
+	ndm->ndm_ifindex = vxlan->dev ? vxlan->dev->ifindex : 0;
 	ndm->ndm_flags = fdb->flags;
 	if (rdst->offloaded)
 		ndm->ndm_flags |= NTF_OFFLOADED;

Please provide a stack trace, and/or a Fixes: tag, and a detailed analysis.