Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1417481lqa; Mon, 29 Apr 2024 08:00:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpgh6fDyNRcReSM9Ws6N+ZbhA3X3/XK8Rne8LBQEIwCLkyebG2835INJYm5FGlpi4mT4Mej1cxnGN6wKhg8JliP5hLgrsmFgPPrHiCjw== X-Google-Smtp-Source: AGHT+IF9eNxCn5ZV2ydnjIfVLBGCzT1Go2apGd3bHsvsY4vq+iRzm/S0ah1cYFt3+z5JiXo/ZiPc X-Received: by 2002:ac2:53ae:0:b0:519:8963:c678 with SMTP id j14-20020ac253ae000000b005198963c678mr6008725lfh.23.1714402835092; Mon, 29 Apr 2024 08:00:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714402835; cv=pass; d=google.com; s=arc-20160816; b=mSHiRuNCCaC+dRJFXnY0rzUcSEz5+8WYGE7ulxZ8XEEhbNpNX/bGB9caGmRh1bWHIy T0nYZgIngluFSZLY/53pBZY7q9GDPIP9RUB8UUSSK1uYn+Ud6kmXcCjQEGzitReXvVDM B6IRZ6aRiUMda29EWuEhXV0J+77lRkTjJanEsYUxCBN9n/e8YCbmuBA+l8tnWLn1McZ/ GaVYIzM6mips16At/+TicX+MAppPS1TU4CTCdKteLksU/g0J75RTMxuphJzcssaRxM36 kDbEd3yYT7ww0t3gGgvM4SaX6rERkOW+sX3vBRxk38IusYvzeHpwhsWVzNs7GGdjHdeZ VT4g== 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=/oIe4LX7xYJWg6mCgiiKvYjP9m8PCxDgfZAB7MwfA4Y=; fh=YAgCvzWH/sfB3ayGugF9BiZbuv02GjVp1U68ESTyAJ8=; b=XRdxDkb+YK4xEloHI4Mhu861N/+p8KbfIkn87psHfauvMg1/SNa77ASoX3KoE93D4a E6k+KkIdxWmmd1O5sIcUwKZYLFfJYRe43XXqv9D+lgTlRWcL0/Mtm3E5B6sGDNG8GlMB v+eGWJVae3WlzRiqZ1PZj8tbpsD1u/MV0KjQuCyUzZsyvnpLxa1RoRL+tvFcJ5/0gxVz lWfCDk8cqkIkH+sCdVcIEAffIqbYlnM0owNQv7Mwd+H+ETF+QFX0yrNZo90f3d0mWbhW nUwxMlFCMlFvAV9Um/Ne/fPsbccICkC9NI0WskgaU9MWONxcURCldRLbrE0rvGY91RMC obwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DMZxveWv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 9-20020a170906310900b00a46f27b23dcsi14276902ejx.432.2024.04.29.08.00.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DMZxveWv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162505-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A73821F212C1 for ; Mon, 29 Apr 2024 15:00:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CF048120C; Mon, 29 Apr 2024 15:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DMZxveWv" 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 C39AB7E0E8; Mon, 29 Apr 2024 15:00:24 +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=1714402825; cv=none; b=FRNBXoL2wKLQew6MHJBTV5kNn2EovUPhWq4GQ/sN0STv5ErGwSacbNJOuEuphhu86Du/o8AVyyeLM1DDcDvKHpR7rUJTwky1SXLvjfppUduz9nexWAzk2J1pRGzMiUfdUh4953lb/usQWyPDPoVDh/VvXchc2LioscYO4XsDE5s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714402825; c=relaxed/simple; bh=VmHwpGGRoY1SKBqjn2H7w2QMYcuoLTkqQAl5r7KlsGI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UUxUuPC06T88u+d8HW66pt4RWpFuKqikfkKzD9+Uhjdt2cjbdu/9h9hZv82PYbL9iVm2ZS3pM+3wL9eI7kikGQUVDJCg/dJY3CnIbRVMnjOcrKgKULqmtyzurPn11ZNSB+K5eprjpnM5TVQvQWB2uG1uTgdRH2bI8f1RggBEFpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DMZxveWv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9C4FC113CD; Mon, 29 Apr 2024 15:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714402824; bh=VmHwpGGRoY1SKBqjn2H7w2QMYcuoLTkqQAl5r7KlsGI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DMZxveWviuEWLZFgBKggE03uoHY90WE09ANHyLG4gJASmt4mNa+5VIz5ObPICztrc h+wv/AZNFm5LW8uFVX8qgCUadPzI6tBCobcXhDXg2gHjYF7mRo3qafoBfpu4iqLvD9 fFZwvP213pB1zKMq1dc7wd0YbaABW1jJpz9acIvFycANUb4x183p7BOyGYFjujH2gk j9hovHIQkmPmEK8pLwtes1MxzgMDrbjHcUd/RaX0N0OwsScVKRWCe29HhHLDcD3ZRy fBGv72+KXijBcrKIuDoyXUb4pFCJ/pzioiz+R0A682ZyaMeec9fboohr0T1g0Bq/Lz FfzG+ThtxVviw== Date: Mon, 29 Apr 2024 08:00:22 -0700 From: Jakub Kicinski To: Mina Almasry Cc: Dragos Tatulea , "davem@davemloft.net" , "pabeni@redhat.com" , "ilias.apalodimas@linaro.org" , "linux-kernel@vger.kernel.org" , "jacob.e.keller@intel.com" , "netdev@vger.kernel.org" , Jianbo Liu , "edumazet@google.com" Subject: Re: [RFC PATCH] net: Fix one page_pool page leak from skb_frag_unref Message-ID: <20240429080022.214a9df9@kernel.org> In-Reply-To: References: <20240424165646.1625690-2-dtatulea@nvidia.com> <4ba023709249e11d97c78a98ac7db3b37f419960.camel@nvidia.com> <4c20b500c2ed615aba424c0f3c7a79f5f5a04171.camel@nvidia.com> <20240426160859.0d85908e@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=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 26 Apr 2024 21:24:09 -0700 Mina Almasry wrote: > On Fri, Apr 26, 2024 at 4:09=E2=80=AFPM Jakub Kicinski = wrote: > > > > On Thu, 25 Apr 2024 12:20:59 -0700 Mina Almasry wrote: =20 > > > - if (recycle && napi_pp_get_page(page)) > > > + if (napi_pp_get_page(page)) =20 > > > > Pretty sure you can't do that. The "recycle" here is a concurrency > > guarantee. A guarantee someone is holding a pp ref on that page, > > a ref which will not go away while napi_pp_get_page() is executing. =20 >=20 > I don't mean to argue, but I think the get_page()/put_page() pair we > do in the page ref path is susceptible to the same issue. AFAIU it's > not safe to get_page() if another CPU can be dropping the last ref, > get_page_unless_zero() should be used instead. Whoever gave us the pointer to operate on has a reference, so the page can't disappear. get_page() is safe. The problem with pp is that we don't know whether the caller has a pp ref or a page ref. IOW the pp ref may not be owned by whoever called us. I guess the situation may actually be worse and we can only pp-ref a page if both "source" and "destination" skb has pp_recycle =3D 1 :S > Since get_page() is good in the page ref path without some guarantee, > it's not obvious to me why we need this guarantee in the pp ref path, > but I could be missing some subtlety. At any rate, if you prefer us > going down the road of reverting commit 2cc3aeb5eccc ("skbuff: Fix a > potential race while recycling page_pool packets"), I think that could > also fix the issue.