Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp871336pxb; Wed, 1 Sep 2021 11:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylnv6HZ9eU5UbFP+1m0PPSTMCWLnINb7OFmb9UH0ClhDYGxf81LEoFKA79RYiBiCbhRPPM X-Received: by 2002:a92:d3cf:: with SMTP id c15mr628777ilh.131.1630521966837; Wed, 01 Sep 2021 11:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630521966; cv=none; d=google.com; s=arc-20160816; b=q7RqtqH2/0c1W7Ld3vRlgf77Pf5OmBKxEifbVQCMYLbSjOWCRepQuAR7+06FYnaDPd aC9qy6QSaQ3ISUiIFe5DifmrsQivpCCmL7QHbRDeZ5EJKdWYW9n8ciFnofENg3GgjVRc pP3PS8RPwPU+Dv3r0YDvf/qvU0sjut3XDHLHvpwG2C1iZk9x1Ab4iJE3hoGxpPVzCaOW 5jZpFGEq02ZzSWTTjbd25y6j70HKki42t3z00q92YqIoyS2L/Lzk9BnC91keWGUNByFG 7xGygSunco5PcKW5tFsk4RFoHaYWZCvhR7v4VbmOfIsoiJmBBoV1S0d9Z7++U3k11TVV Dwew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=CMn1n/Dh7ekMa8GdsiwO8//8ZOlUAm/ndqbU97gmQrE=; b=JNPlT5Uh+PIgTb4ryws4tRbMsYMBBbrBLaP/i/ySrpCVhoYme4dsUaw9NEDTNHVE4S yvmR+bZqSwD+dZfj9wVL6mNyP/jXo79ELrPN51/aUFDSS55BXwm42e3zNx2pqMihg7CF 8cJXPI8BQ0G7WiiXSOgYfsfuiJTw7QJXIb36apXDHH2Rr1TCLvLJLAiROcXj4x1vwogh EiEnZc2QE6qAeuvoqyHlyGx5ROUfUiAZlhNxJYInFr8xxbVwW7MlS65oHzceNiPY/0qZ O5A/Ml+rvb5Wj681sBUWNa9ISdgxDjaVO1ep052P47B64pEVRb8UfoNwv7fE4Kt7oM1F JpYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=TfISTGvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si375981ila.78.2021.09.01.11.45.55; Wed, 01 Sep 2021 11:46:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=TfISTGvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242230AbhIAGVf (ORCPT + 99 others); Wed, 1 Sep 2021 02:21:35 -0400 Received: from relay.sw.ru ([185.231.240.75]:41322 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242071AbhIAGVe (ORCPT ); Wed, 1 Sep 2021 02:21:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:From: Subject; bh=CMn1n/Dh7ekMa8GdsiwO8//8ZOlUAm/ndqbU97gmQrE=; b=TfISTGvLL9l2i0BUL sWUB5ThmJHilTO/IVkK3C72J4BJVljG2C6JpxX3J7dtHiLut1cG06OgdPHSOTMX5aP3UbPepCHlQe sMYjjZ4sCuf1fQfzQQRA6l9jmAXyAzW5Bvuv/vSL8c0jwcLC6ts+J62x2scs2zP5czjYIzVWqpsS8 =; Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1mLJbo-000R9a-Rw; Wed, 01 Sep 2021 09:20:28 +0300 Subject: Re: [PATCH net-next v3 RFC] skb_expand_head() adjust skb->truesize incorrectly To: Eric Dumazet , Christoph Paasch , "David S. Miller" Cc: Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , netdev , linux-kernel@vger.kernel.org, kernel@openvz.org, Julian Wiedmann , Alexey Kuznetsov References: <8fd56805-2ac8-dcbe-1337-b20f91f759d6@gmail.com> From: Vasily Averin Message-ID: Date: Wed, 1 Sep 2021 09:20:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/31/21 10:38 PM, Eric Dumazet wrote: > On 8/31/21 7:34 AM, Vasily Averin wrote: >> RFC because it have an extra changes: >> new is_skb_wmem() helper can be called >> - either before pskb_expand_head(), to create skb clones >> for skb with destructors that does not change sk->sk_wmem_alloc >> - or after pskb_expand_head(), to change owner in skb_set_owner_w() >> >> In current patch I've added both these ways, >> we need to keep one of them. If nobody object I vote for 2nd way: >> diff --git a/net/core/skbuff.c b/net/core/skbuff.c >> index f931176..3ce33f2 100644 >> --- a/net/core/skbuff.c >> +++ b/net/core/skbuff.c >> @@ -1804,30 +1804,47 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom) >> struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom) >> { ... skipped ... >> - return skb; >> + if (oskb) { >> + if (sk) >> + skb_set_owner_w(skb, sk); > > Broken for non full sockets. > Calling skb_set_owner_w(skb, sk) for them is a bug. I think you're wrong here. It is 100% equivalent of old code, skb_set_owner_w() handles sk_fullsock(sk) inside and does not adjust sk->sk_wmem_alloc. Please explain if I'm wrong. >> + consume_skb(oskb); >> + } else if (sk) { >> + delta = osize - skb_end_offset(skb); >> + if (!is_skb_wmem(skb)) >> + skb_set_owner_w(skb, sk); > > This would be broken for non full sockets. > Calling skb_set_owner_w(skb, sk) for them is a bug. See my comment above. >> + skb->truesize += delta; >> + if (sk_fullsock(sk)) >> + refcount_add(delta, &sk->sk_wmem_alloc); > > >> + } return skb; Strange line, will fix it. >> } >> EXPORT_SYMBOL(skb_expand_head);