Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp509991lqm; Wed, 1 May 2024 07:28:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUwL1x0aiHwiCcjkuB/aM1i4N0gp4KiuwMNUiClK1yDOMmGYiHikbd4L6YcOXujj/XDXmSmmQMMXzbI+KexxONLaKhdWmJz8rRFOi4d2Q== X-Google-Smtp-Source: AGHT+IHM4Y25TQnJ+7zvHNYNQ6H8PEVDDlzMXGtzNRAwqkCeWDSMkUUPILIKVG6UYTb0Gyf17IVw X-Received: by 2002:a05:6871:e01c:b0:23c:58e5:9d7d with SMTP id by28-20020a056871e01c00b0023c58e59d7dmr2799392oac.32.1714573731180; Wed, 01 May 2024 07:28:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714573731; cv=pass; d=google.com; s=arc-20160816; b=WGuJB1/MhhwchY7DNJ/M35p9lFWRHPYhum4JQdrPP2QLwhyspCKtRyrlJjBC4NfIyA YgDkICqYyLHt57I763klo3Z5MXyRfs8WJOxoWbXrkJ5JeyVULs6s3diIlYMmRkodydUD mHqZJ1zjuTOMCMCQtXNd9EJmNi2sKuMmqYo27WbjwBxe20JXwarRrSFp221pT6YRdMBq 9HbCZV0tJBWKMv7+tkUOdY/5pVcybMowcefrZEaGKi9aNO4fjDcP1uNiCZsDP6kXJ68m 7gSElfOAPRo7lb7OJwiOAJO2gSLcFSYaY04EpiD34Jsg+ADin1hGrpjTp22m6JnbOyL7 GeZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=zVUB9o5EOW32bqWtrE7YFrYZ/Wlnmkyb0tl7p74NsUQ=; fh=Ltm6X/cs5MqNXwSymiDF56+AdMe5rzroCyDlPBmiFW8=; b=IfesG5+b5Ps56OsSdRox53qjKFMPuoDaZ1ieLdE9FtAdP09M2DBywbmmOjdixtbcac TVNe0YGmGFLKOWCHoj++hox5y+Lls79NP6mxKfmeUwUfHef1skPT2QcdYBL3W01fJuQD DC0PV+QhxUvjRpkrweocJ7SdPe2U+fDxKMgBMUcw5sH/j70plsLLVgSQ9gr1JkwpbMok 8c2fLvMa+F0htjSnvBF8AUv/B5dzqstmEdjY+FFYMKHrntYMEP8BANq8ScXRcpNx4WPb avm7BY7/SaAtAJYeirkOhy47WVi1z05//jjqNJ1m0ISCJZsz9hWcMRIjHVmSxJtnIOYJ x1mw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="YinB/Tw0"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bb11-20020a05622a1b0b00b0043af44175a7si6345398qtb.294.2024.05.01.07.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="YinB/Tw0"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DA42E1C21BA0 for ; Wed, 1 May 2024 14:28:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B2FC12F399; Wed, 1 May 2024 14:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YinB/Tw0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 546CC1758D; Wed, 1 May 2024 14:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714573717; cv=none; b=iCpmr4ZiTi+hGOL7llh6uH7qkPpLQuD8zz8FaHUVQzY7M31OOA9UbPno41gCDWBgY1Ul2qdZ9Gja6TxZyurGqld17DxYgpWO6fuv634NtzvNILW4XMOuy9XSA3tHSjbE5jh62VZkL7EL6fCHuc5i8e/ujB+w8i4HppCoPu1DnZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714573717; c=relaxed/simple; bh=FZNQ8iWfNQYPNeiTDqWByloJQKxPn8yJ9IlYcd1zXx0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=at9e2u5Xy0BSIrR1u8ZB33nfZNyddfBr5U5kGTB14JAvuGQn9uCHMGx5nhHKLRYngA/1Nrg1k/0S9mMbzV4p1FCwMwDgqK1gYEuom5o2YEULachhVVNIE6jVgvjTpKNAWDrRHVk/7mWCjW4xktqiEfN2MilyutvQmWHQVe3oD6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YinB/Tw0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65D81C072AA; Wed, 1 May 2024 14:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714573716; bh=FZNQ8iWfNQYPNeiTDqWByloJQKxPn8yJ9IlYcd1zXx0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YinB/Tw04tiUJTptvJiGlXsCFmxozNuoBkBk6mlC8lIXjeZNi5YS3ap7Oppqi+7jo QVevGt6M8z0/h1uiUuCwlKPq0CXEv0UQWWmjVAVU7PmCetSbz+wLjntcWukw4EORSt TWpyfVDiTcukQezMm3zAJfu/ghZ62XUw5B4F1m0uPas78ZcZz8VIefH4hPUrFvNSE5 giUBZnnsVOwDgWbCrGsEBUwGd4OS75+b4ypPLd3N1Wz0AYXyLVfH/9aPp9/IuLXDIW jUJge5JZ2F5oft97PhC/dRvEKOgitZIWNL6owQ1uemeRJhQIZOqiME/mvqgqqmnSwD FyBwz44p3cJdA== Date: Wed, 1 May 2024 07:28:35 -0700 From: Jakub Kicinski To: Mina Almasry Cc: Dragos Tatulea , "davem@davemloft.net" , "ilias.apalodimas@linaro.org" , "linux-kernel@vger.kernel.org" , "jacob.e.keller@intel.com" , "pabeni@redhat.com" , Jianbo Liu , "netdev@vger.kernel.org" , "edumazet@google.com" Subject: Re: [RFC PATCH] net: Fix one page_pool page leak from skb_frag_unref Message-ID: <20240501072835.631dcda0@kernel.org> In-Reply-To: <20240501072434.5720fd42@kernel.org> References: <20240424165646.1625690-2-dtatulea@nvidia.com> <4ba023709249e11d97c78a98ac7db3b37f419960.camel@nvidia.com> <4c20b500c2ed615aba424c0f3c7a79f5f5a04171.camel@nvidia.com> <20240426160557.51de91f9@kernel.org> <7a5a1d74040052afc8cc6cc5c2700fdf2e836b0c.camel@nvidia.com> <20240501072434.5720fd42@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 1 May 2024 07:24:34 -0700 Jakub Kicinski wrote: > I vote #2, actually :( Or #3 make page pool ref safe to acquire > concurrently, but that plus fixing all the places where we do crazy > things may be tricky. > > Even taking the ref is not as simple as using atomic_long_inc_not_zero() > sadly, partly because we try to keep the refcount at one, in an apparent > attempt to avoid dirtying the cache line twice. > > So maybe partial revert to stop be bleeding and retry after more testing > is the way to go? > > I had a quick look at the code and there is also a bunch of functions > which "shift" frags from one skb to another, without checking whether > the pp_recycle state matches. BTW these two refs seem to look at the wrong skb: diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 0c8b82750000..afd3336928d0 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2148,7 +2148,7 @@ struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb, int headroom, } for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i]; - skb_frag_ref(skb, i); + skb_frag_ref(n, i); } skb_shinfo(n)->nr_frags = i; } @@ -5934,7 +5934,7 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, * since we set nr_frags to 0. */ for (i = 0; i < from_shinfo->nr_frags; i++) - __skb_frag_ref(&from_shinfo->frags[i], from->pp_recycle); + __skb_frag_ref(&from_shinfo->frags[i], to->pp_recycle); to->truesize += delta; to->len += len;