Skip to contentSkip to conversation

net: correct zerocopy refcnt with newly allocated UDP or RAW uarg

PATCH linmiaohe 1 participant 1 message Aug 16, 2020

Subsystems (2)
lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 10 lines · Willem de Bruijn
Quoted 1 line · linmiaohe

I don't think that can happen.

The question is when this branch is false

               next = (u32)atomic_read(&sk->sk_zckey);
               if ((u32)(uarg->id + uarg->len) == next) {
Quoted 6 lines

I cannot come up with a case. I think it might be vestigial. The goal is to ensure to append only a consecutive range of notification IDs.
Each notification ID corresponds to a sendmsg invocation with MSG_ZEROCOPY. In both TCP and UDP with corking, data is ordered and access to changes to these fields happen together as a transaction:

               /* realloc only when socket is locked (TCP, UDP cork),
                * so uarg->len and sk_zckey access is serialized
                */

So what I concerned is just a theoretically problems. If we can always guarantee sock_zerocopy_realloc only returns the existing uarg or NULL when on skb_zcopy(skb), bad things won't happen.

Many thanks for your detailed explaination.