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 A08AD1C29 for ; Wed, 23 Nov 2022 09:35:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06572C433C1; Wed, 23 Nov 2022 09:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669196144; bh=p1uLgSVqztVqCqfj2kFE2qwQ5TmyRCQNvq1V4eSlrVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjA05Pq1TslClCfkE83Ji6V2iWxNQfzPdnRByOD5+xomShA6ftPIQ3vlsJc2Jewhe PrVQAdbL4nbpb7JdUsGPkSIOOanXzEf5BPbgOwBmyKi8lF1BX94fDSujmEw2/lXj2T VedWzRqIQY6wgwBDEkH6ai1zyXKzhJsp+c/5fup0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wei Yongjun , Martin Schiller , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 101/181] net/x25: Fix skb leak in x25_lapb_receive_frame() Date: Wed, 23 Nov 2022 09:51:04 +0100 Message-Id: <20221123084606.683078624@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084602.707860461@linuxfoundation.org> References: <20221123084602.707860461@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Wei Yongjun [ Upstream commit 2929cceb2fcf0ded7182562e4888afafece82cce ] x25_lapb_receive_frame() using skb_copy() to get a private copy of skb, the new skb should be freed in the undersized/fragmented skb error handling path. Otherwise there is a memory leak. Fixes: cb101ed2c3c7 ("x25: Handle undersized/fragmented skbs") Signed-off-by: Wei Yongjun Acked-by: Martin Schiller Link: https://lore.kernel.org/r/20221114110519.514538-1-weiyongjun@huaweicloud.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/x25/x25_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c index 5259ef8f5242..748d8630ab58 100644 --- a/net/x25/x25_dev.c +++ b/net/x25/x25_dev.c @@ -117,7 +117,7 @@ int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev, if (!pskb_may_pull(skb, 1)) { x25_neigh_put(nb); - return 0; + goto drop; } switch (skb->data[0]) { -- 2.35.1