Skip to content

Commit 15a48cc

Browse files
mark-blochBrian Maly
authored andcommitted
vxlan: fix use-after-free on deletion
Adding a vxlan interface to a socket isn't symmetrical, while adding is done in vxlan_open() the deletion is done in vxlan_dellink(). This can cause a use-after-free error when we close the vxlan interface before deleting it. We add vxlan_vs_del_dev() to match vxlan_vs_add_dev() and call it from vxlan_stop() to match the call from vxlan_open(). Orabug: 29755932 Fixes: 56ef9c9 ("vxlan: Move socket initialization to within rtnl scope") Acked-by: Jiri Benc <[email protected]> Tested-by: Roi Dayan <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit a53cb29) Reviewed-by: Rama Nichanamatlu <[email protected]> Signed-off-by: Venkat Venkatsubra <[email protected]> Signed-off-by: Brian Maly <[email protected]> Conflicts: drivers/net/vxlan.c Signed-off-by: Brian Maly <[email protected]>
1 parent 5533e5d commit 15a48cc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/net/vxlan.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static const u8 all_zeros_mac[ETH_ALEN];
7676

7777
static int vxlan_sock_add(struct vxlan_dev *vxlan);
7878

79+
static void vxlan_vs_del_dev(struct vxlan_dev *vxlan);
80+
7981
/* per-network namespace private data for this module */
8082
struct vxlan_net {
8183
struct list_head vxlan_list;
@@ -1052,6 +1054,8 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan)
10521054

10531055
synchronize_net();
10541056

1057+
vxlan_vs_del_dev(vxlan);
1058+
10551059
if (ipv4) {
10561060
udp_tunnel_sock_release(vxlan->vn4_sock->sock);
10571061
kfree(vxlan->vn4_sock);
@@ -2171,6 +2175,15 @@ static void vxlan_cleanup(unsigned long arg)
21712175
mod_timer(&vxlan->age_timer, next_timer);
21722176
}
21732177

2178+
static void vxlan_vs_del_dev(struct vxlan_dev *vxlan)
2179+
{
2180+
struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
2181+
2182+
spin_lock(&vn->sock_lock);
2183+
hlist_del_init_rcu(&vxlan->hlist);
2184+
spin_unlock(&vn->sock_lock);
2185+
}
2186+
21742187
static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan)
21752188
{
21762189
struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);

0 commit comments

Comments
 (0)