]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: let skb_orphan_partial wake-up waiters.
authorPaolo Abeni <pabeni@redhat.com>
Tue, 30 Mar 2021 16:43:54 +0000 (18:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:47:13 +0000 (08:47 +0200)
commit1c453cfc613e02dab9df2866e9548883b338b1fd
tree9bac6e61be7710e70b4369d78e2a00658193b985
parent9b4c8b7a3acfab3273bd4640a2a5299e282f3382
net: let skb_orphan_partial wake-up waiters.

commit 9adc89af724f12a03b47099cd943ed54e877cd59 upstream.

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: f6ba8d33cfbb ("netem: fix skb_orphan_partial()")
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/sock.h
net/core/sock.c