Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3864468pxb; Mon, 30 Aug 2021 12:27:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6FdjQ0mZKtBrIeLy3zRuXOHnBNdPQ/iTNxGP3KO9cfkv3PTgpKYIIyqNtryH05hMwSI05 X-Received: by 2002:a05:6e02:2183:: with SMTP id j3mr5351850ila.149.1630351656850; Mon, 30 Aug 2021 12:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630351656; cv=none; d=google.com; s=arc-20160816; b=PEmbcETH+PGF9EICAZsJrqsIfl7KC3FkHCbSfJEgdyjHk0EsVwyeZaDGUlX6uViTUD jCtm+7m+EzCJavoLFtngVmZ06zpBHpvO6YPsQymGMsi1zEvv/zJzSRbDb19/FuSEIkp4 vsc8Ca7lATEmLLhX/ZFU8b2s+TJfbjcelXQa6Is7KgGctZ0kleE5aCFvWWtg8+pNayB8 K4ICgwhK2nV9BrHU8BZeP6TlTcL1RGplN9OEqC2Y6tN3VVdFyvVmPVsYpbig0geK43a4 5x8CGrhENjQ8SJ4S+sSpJTblmoD95PMTMu0xHR0WRum4w89bJCiII/JgOzaRu36YbzV+ RCHg== 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=Il7nX1EGN2KP4aDwDr8T1kqFJjr1jC/4sMGzTkyhikk=; b=BvZtqkzC7HTMCcg6y0XQujD478vGdWIhwvC21fhEyCfq1SI8sbaJ77Y3w6PV+0xFma hea7nnp2VTEOEAFjlckGV83VnYp4lFGOu744VpQLLu/oLNAOI70zXO4ZY9komBvWfHzM Pn/eeSOE1t8TgUcoQBS0HbU4BcKGemqTKtOpp32UwdiTISrUKCCxZIVMXxr2vcZuECtl taUW3FE9Tkx+yW7TTCHZZOazLczvk9LRTPnwxbaYrET/D5rwhCc4aDr7KY6xe3bgKsl2 Tdng5U14Pef6LtHIKOXCQYUa/ZGP8yEqQPXQPtKPYXX1/xoSNLAlb7DpU1w0NTnT9gEO bDUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=IbboYbIZ; 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 y28si14843869iot.48.2021.08.30.12.27.24; Mon, 30 Aug 2021 12:27:36 -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=IbboYbIZ; 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 S238465AbhH3SKO (ORCPT + 99 others); Mon, 30 Aug 2021 14:10:14 -0400 Received: from relay.sw.ru ([185.231.240.75]:47086 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238150AbhH3SKJ (ORCPT ); Mon, 30 Aug 2021 14:10:09 -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=Il7nX1EGN2KP4aDwDr8T1kqFJjr1jC/4sMGzTkyhikk=; b=IbboYbIZyTqcfruYl oaXd0tv/HedgYMeF20PHNiYZww/CwYvu3MCxiDk9rL+0hyQ6RnWuRc9nlwDylx4Wn64bPMOQVY44h dXQ3HtcRyeHwtqHhorzEkej4IxPCf0YvMVsyFkSyvWx+/s3xR/Nn9W6/ia0xn9iN8ghWwIrX7e7X4 =; Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1mKliX-000Fbh-Lk; Mon, 30 Aug 2021 21:09:09 +0300 Subject: Re: [PATCH v2] 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 References: <860513d5-fd02-832b-1c4c-ea2b17477d76@virtuozzo.com> <9f0c5e45-ad79-a9ea-dab1-aeb3bc3730ae@gmail.com> From: Vasily Averin Message-ID: Date: Mon, 30 Aug 2021 21:09:08 +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: <9f0c5e45-ad79-a9ea-dab1-aeb3bc3730ae@gmail.com> 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/30/21 7:01 PM, Eric Dumazet wrote: > On 8/29/21 5:59 AM, Vasily Averin wrote: >> Christoph Paasch reports [1] about incorrect skb->truesize >> after skb_expand_head() call in ip6_xmit. >> This may happen because of two reasons: >> - skb_set_owner_w() for newly cloned skb is called too early, >> before pskb_expand_head() where truesize is adjusted for (!skb-sk) case. >> - pskb_expand_head() does not adjust truesize in (skb->sk) case. >> In this case sk->sk_wmem_alloc should be adjusted too. >> >> [1] https://lkml.org/lkml/2021/8/20/1082 >> @@ -1756,9 +1756,13 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, >> * For the moment, we really care of rx path, or >> * when skb is orphaned (not attached to a socket). >> */ >> - if (!skb->sk || skb->destructor == sock_edemux) >> - skb->truesize += size - osize; >> - >> + delta = size - osize; >> + if (!skb->sk || skb->destructor == sock_edemux) { >> + skb->truesize += delta; >> + } else if (update_truesize) { > > Unfortunately we can not always do this sk_wmem_alloc change here. > > Some skb have skb->sk set, but the 'reference on socket' is not through sk_wmem_alloc Could you please provide some example? In past in all handeled cases we have cloned original skb and then unconditionally assigned skb sock_wfree destructor. Do you want to say that it worked correctly somehow? I expected if we set sock_wfree, we have guarantee that old skb adjusted sk_wmem_alloc. Am I wrong? Could you please point on such case? > It seems you need a helper to make sure skb->destructor is one of > the destructors that use skb->truesize and sk->sk_wmem_alloc > > For instance, skb_orphan_partial() could have been used. Thank you, will investigate. Vasily Averin