[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20141211.145740.2133438308870305336.davem@davemloft.net>
Date: Thu, 11 Dec 2014 14:57:40 -0500 (EST)
From: David Miller <davem@...emloft.net>
To: mleitner@...hat.com
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH net v2] Fix race condition between vxlan_sock_add and
vxlan_sock_release
From: Marcelo Ricardo Leitner <mleitner@...hat.com>
Date: Thu, 11 Dec 2014 10:02:22 -0200
> Currently, when trying to reuse a socket, vxlan_sock_add will grab
> vn->sock_lock, locate a reusable socket, inc refcount and release
> vn->sock_lock.
>
> But vxlan_sock_release() will first decrement refcount, and then grab
> that lock. refcnt operations are atomic but as currently we have
> deferred works which hold vs->refcnt each, this might happen, leading to
> a use after free (specially after vxlan_igmp_leave):
>
> CPU 1 CPU 2
>
> deferred work vxlan_sock_add
> ... ...
> spin_lock(&vn->sock_lock)
> vs = vxlan_find_sock();
> vxlan_sock_release
> dec vs->refcnt, reaches 0
> spin_lock(&vn->sock_lock)
> vxlan_sock_hold(vs), refcnt=1
> spin_unlock(&vn->sock_lock)
> hlist_del_rcu(&vs->hlist);
> vxlan_notify_del_rx_port(vs)
> spin_unlock(&vn->sock_lock)
>
>
> So when we look for a reusable socket, we check if it wasn't freed
> already before reusing it.
>
> Signed-off-by: Marcelo Ricardo Leitner <mleitner@...hat.com>
> Fixes: 7c47cedf43a8b3 ("vxlan: move IGMP join/leave to work queue")
Applied and queued up for -stable, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists