From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CA99B2E7179; Sun, 7 Jun 2026 10:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827705; cv=none; b=qBnhvGoWXWrkgaikV8X9dBD6thj5YJvY/8gg0B95uUpitssbRcjgIwoO2jYdP/Ci4xH/IvscFge+lZBUKEdzL0ZvFf/gfo+qwzF52vGapLAfwp9mvj3ls4atPgfZ87HFcMvyz4RxGpap/Za3FrJxw0WNIMccGLD+RaBg2lyDuWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827705; c=relaxed/simple; bh=EPHHCda4539HO6IuFwkWQTPGhEMSkRJ/H5tnrPcDdXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hYM0DcacYF2WSs7hhTEsAhmRYExoONDN/IcsA9+Gm1SEu4x3T9BMsjVbTRnnF5D9/I2uZMwr3DGJtxqOepx6xZmtqNcy8HBTSwhH0xIIYndl9p872xgQdnX7AgmHoeoJkmCvPcnBDAmID1acCnmCaUyX100S7aRnBOrpPwDqxPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=f0pvTZRz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="f0pvTZRz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B30931F00893; Sun, 7 Jun 2026 10:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780827704; bh=O+jovUaDCW8ZEUn6IYCU768i9hguPjmEPYnui8saA5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f0pvTZRzMwNi7NaMQglGOoDQUWPo2dm/P05KHQSa1wslGG3kv9uDgQ8aE4cwcy4NK N6rdxUYCiPD3Hk44ek7tYWO5PgI29bHCPKg1EEqyo/wItixmAiPa9UX9EDq6i/FDHm X3usn7VQEjmj6zy20G09vGliLbj+0kQF4VnGYuCI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Minh Nguyen , Willem de Bruijn , Pavel Begunkov , Willem de Bruijn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 094/315] net: skbuff: fix pskb_carve leaking zcopy pages Date: Sun, 7 Jun 2026 11:58:01 +0200 Message-ID: <20260607095731.085027954@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pavel Begunkov [ Upstream commit ff6e798c2eac3ebd0501ad7e796f583fab928de8 ] When SKBFL_MANAGED_FRAG_REFS is set, frag pages are not refcounted but their lifetime is controlled by the attached ubuf_info. To make a copy of the skb_shared_info, we either should clear the flag and reference the frags, or keep the flag and have frags unreferenced. pskb_carve_inside_header() and pskb_carve_inside_nonlinear() don't follow the rule and thus can leak page references. Let's clear SKBFL_MANAGED_FRAG_REFS from the original skb to fix it. It's the simplest way to address it, but there are more performant ways to do that if it ever becomes a problem. Link: https://lore.kernel.org/all/20260523085809.26331-1-nvminh232@clc.fitus.edu.vn/ Fixes: 753f1ca4e1e50 ("net: introduce managed frags infrastructure") Reported-by: Minh Nguyen Reported-by: Willem de Bruijn Signed-off-by: Pavel Begunkov Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/1e2086aa69217d7f9c8da3d38f5be7160f1b4cd1.1779993185.git.asml.silence@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/skbuff.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 6618bfa70ca444..a52aa79b0fdbaf 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6772,6 +6772,11 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off, skb_copy_from_linear_data_offset(skb, off, data, new_hlen); skb->len -= off; + /* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it + * while refcounting frags below. + */ + skb_zcopy_downgrade_managed(skb); + memcpy((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info, @@ -6883,6 +6888,11 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off, return -ENOMEM; size = SKB_WITH_OVERHEAD(size); + /* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it + * while refcounting frags below. + */ + skb_zcopy_downgrade_managed(skb); + memcpy((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0])); if (skb_orphan_frags(skb, gfp_mask)) { -- 2.53.0