lkml.org 
[lkml]   [2017]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 11/54] l2tp: purge socket queues in the .destruct() callback
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Guillaume Nault <g.nault@alphalink.fr>


    [ Upstream commit e91793bb615cf6cdd59c0b6749fe173687bb0947 ]

    The Rx path may grab the socket right before pppol2tp_release(), but
    nothing guarantees that it will enqueue packets before
    skb_queue_purge(). Therefore, the socket can be destroyed without its
    queues fully purged.

    Fix this by purging queues in pppol2tp_session_destruct() where we're
    guaranteed nothing is still referencing the socket.

    Fixes: 9e9cb6221aa7 ("l2tp: fix userspace reception on plain L2TP sockets")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/l2tp/l2tp_ppp.c | 7 ++++---
    1 file changed, 4 insertions(+), 3 deletions(-)

    --- a/net/l2tp/l2tp_ppp.c
    +++ b/net/l2tp/l2tp_ppp.c
    @@ -450,6 +450,10 @@ static void pppol2tp_session_close(struc
    static void pppol2tp_session_destruct(struct sock *sk)
    {
    struct l2tp_session *session = sk->sk_user_data;
    +
    + skb_queue_purge(&sk->sk_receive_queue);
    + skb_queue_purge(&sk->sk_write_queue);
    +
    if (session) {
    sk->sk_user_data = NULL;
    BUG_ON(session->magic != L2TP_SESSION_MAGIC);
    @@ -488,9 +492,6 @@ static int pppol2tp_release(struct socke
    l2tp_session_queue_purge(session);
    sock_put(sk);
    }
    - skb_queue_purge(&sk->sk_receive_queue);
    - skb_queue_purge(&sk->sk_write_queue);
    -
    release_sock(sk);

    /* This will delete the session context via

    \
     
     \ /
      Last update: 2017-05-02 00:00    [W:4.141 / U:0.084 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site