]> asedeno.scripts.mit.edu Git - linux.git/commit
skbuff: in skb_copy_ubufs unclone before releasing zerocopy
authorWillem de Bruijn <willemb@google.com>
Thu, 28 Dec 2017 17:38:13 +0000 (12:38 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Dec 2017 19:26:22 +0000 (14:26 -0500)
commitf72c4ac695573699dde5b71da1c3b9ef80440616
tree0c2ec556c1218b9dafcbbaa8c2906082d7d8b6f1
parent517d7c79bdb39864e617960504bdc1aa560c75c6
skbuff: in skb_copy_ubufs unclone before releasing zerocopy

skb_copy_ubufs must unclone before it is safe to modify its
skb_shared_info with skb_zcopy_clear.

Commit b90ddd568792 ("skbuff: skb_copy_ubufs must release uarg even
without user frags") ensures that all skbs release their zerocopy
state, even those without frags.

But I forgot an edge case where such an skb arrives that is cloned.

The stack does not build such packets. Vhost/tun skbs have their
frags orphaned before cloning. TCP skbs only attach zerocopy state
when a frag is added.

But if TCP packets can be trimmed or linearized, this might occur.
Tracing the code I found no instance so far (e.g., skb_linearize
ends up calling skb_zcopy_clear if !skb->data_len).

Still, it is non-obvious that no path exists. And it is fragile to
rely on this.

Fixes: b90ddd568792 ("skbuff: skb_copy_ubufs must release uarg even without user frags")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c