• Paolo Abeni's avatar
    net: let skb_orphan_partial wake-up waiters. · 9adc89af
    Paolo Abeni authored
    Currently the mentioned helper can end-up freeing the socket wmem
    without waking-up any processes waiting for more write memory.
    
    If the partially orphaned skb is attached to an UDP (or raw) socket,
    the lack of wake-up can hang the user-space.
    
    Even for TCP sockets not calling the sk destructor could have bad
    effects on TSQ.
    
    Address the issue using skb_orphan to release the sk wmem before
    setting the new sock_efree destructor. Additionally bundle the
    whole ownership update in a new helper, so that later other
    potential users could avoid duplicate code.
    
    v1 -> v2:
     - use skb_orphan() instead of sort of open coding it (Eric)
     - provide an helper for the ownership change (Eric)
    
    Fixes: f6ba8d33 ("netem: fix skb_orphan_partial()")
    Suggested-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    9adc89af
sock.c 89.1 KB