From mboxrd@z Thu Jan 1 00:00:00 1970 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 8DE8014BFA2; Sun, 7 Sep 2025 20:17:05 +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=1757276225; cv=none; b=LnpPPxXqJ3IQf6unfeCwn0Tq6y/YS09Z9PrX1ZVpZlx3TRlfjr29sGN4O3D6fidjRWlNlcFnpoJs8d47XK9ZUTXf7ffaZGEMQBHwIxpbpyhqKYwdAl3sKAlBix94IQ7E9/1OY7MtCpkGmoio+fJBzNhUU+43/uP1jqp5EDSD7oI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757276225; c=relaxed/simple; bh=pYT+XW04jwk02pD2S2UMQFEThYp6y9uEdwf3ifsumYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h3JGk1fsUj8bceWOss+kogFPFTZS13qrefP+7HTtnapUxLBjD/Cf4gx9eoHIQWpaB6ZjWAMimP/aMKMK9wkckv9eS8RmDci2F7OrxFBZD168CWVS+y78ETS/bJt1vCIE3bhgvciTOiSHoDjoPMiOD+r/hsdo6bsj1P16LYKzWuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MwvBVnbX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MwvBVnbX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBDFFC4CEF0; Sun, 7 Sep 2025 20:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757276225; bh=pYT+XW04jwk02pD2S2UMQFEThYp6y9uEdwf3ifsumYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MwvBVnbXhzJw5oQA8Q9066z2gf5XSoeHqbv15Pdj4GpCux+D9NxVUgbaONFoSYnW8 TEejWzexdVCTgcMol18On/YkhoZ0+bqrEt3bwACsRIMumHS6gBjRF0EMK5QWUJW3Et wCGFkIpyhG6AdFkJaflcAp9DKClDkWnoraQaM8fo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qingfang Deng , Eric Dumazet , Yue Haibing , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 037/104] ppp: fix memory leak in pad_compress_skb Date: Sun, 7 Sep 2025 21:57:54 +0200 Message-ID: <20250907195608.660189685@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195607.664912704@linuxfoundation.org> References: <20250907195607.664912704@linuxfoundation.org> User-Agent: quilt/0.68 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qingfang Deng [ Upstream commit 4844123fe0b853a4982c02666cb3fd863d701d50 ] If alloc_skb() fails in pad_compress_skb(), it returns NULL without releasing the old skb. The caller does: skb = pad_compress_skb(ppp, skb); if (!skb) goto drop; drop: kfree_skb(skb); When pad_compress_skb() returns NULL, the reference to the old skb is lost and kfree_skb(skb) ends up doing nothing, leading to a memory leak. Align pad_compress_skb() semantics with realloc(): only free the old skb if allocation and compression succeed. At the call site, use the new_skb variable so the original skb is not lost when pad_compress_skb() fails. Fixes: b3f9b92a6ec1 ("[PPP]: add PPP MPPE encryption module") Signed-off-by: Qingfang Deng Reviewed-by: Eric Dumazet Reviewed-by: Yue Haibing Link: https://patch.msgid.link/20250903100726.269839-1-dqfext@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ppp/ppp_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index cbf1c1f23281d..f184368d5c5e7 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -1753,7 +1753,6 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb) */ if (net_ratelimit()) netdev_err(ppp->dev, "ppp: compressor dropped pkt\n"); - kfree_skb(skb); consume_skb(new_skb); new_skb = NULL; } @@ -1855,9 +1854,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) "down - pkt dropped.\n"); goto drop; } - skb = pad_compress_skb(ppp, skb); - if (!skb) + new_skb = pad_compress_skb(ppp, skb); + if (!new_skb) goto drop; + skb = new_skb; } /* -- 2.50.1