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 405B53D890D; Tue, 16 Jun 2026 16:43:06 +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=1781628187; cv=none; b=NL3gwFuFcUiKpeBWhV7C4Bky2Unuzh/TpG91AOY5pB9kcEDe87COYd0DD4K5eNEuG2eum74WE4tWQfOTzPBcaM/1XZ1XTIR+DNzJVaI4RpjI/Ct12ff0ifM/qWiJ/ag+qhRXQdDDuZjceMYX4hANoK4byZrbo0SvlWYb8FPwZ/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628187; c=relaxed/simple; bh=mIEbaw/aK9flHZi1/UjDl5QAaY8HxE1nyK94v3VHoaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=awbojs3o4C424lpUIfHe6XonoPFsmzBQt/wF2jFyi2SckwsbGiRwoKoJDd/b6ptsRMJvgxKMNjHiaqR2zcSeDkKQBBm/VJ7wFgkEjfFsm8n6Kr7zY97BUEcLshuzIVEXtcAhf4z4EMfFZIbRY0YkGaVLZ1XGU7C7GQ80GS6T610= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hrcKUaRq; 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="hrcKUaRq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4312A1F000E9; Tue, 16 Jun 2026 16:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781628186; bh=5xIelE03B9Kfd324vtrs5uOz83GIGqkxVlWuKeDhGNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hrcKUaRq1aIy4PKgNJmNAsGTCfjiV1jAff37pgf2FU4n1Yvc3c1HsSAUmr6Xo65L8 kaY81/9h6yj0gBKtXerH3xQ+CofJITslTSc1/iisRPLEk+1JvWgD1JnR2CQri8tiR4 I/5ec6Z4etLDigQmEj2CZ+DH8yjwwBt1NNA0LXpg= 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.6 048/452] net: skbuff: fix pskb_carve leaking zcopy pages Date: Tue, 16 Jun 2026 20:24:35 +0530 Message-ID: <20260616145120.471783340@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@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.6-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 8b05866e93b195..2282b6ad4be21a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6397,6 +6397,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, @@ -6509,6 +6514,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