Re: [PATCH] net: correct zerocopy refcnt with newly allocated UDP or RAW uarg

From: linmiaohe
Date: Sat Aug 15 2020 - 22:02:42 EST


Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx> wrote:
>On Fri, Aug 14, 2020 at 10:17 AM linmiaohe <linmiaohe@xxxxxxxxxx> wrote:
>>
>
>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) {
>
>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.