From 66a744b0fd54b90cb8f7bcf1403833163c103b00 Mon Sep 17 00:00:00 2001 From: Linyu Yuan Date: Tue, 4 Jun 2024 06:32:42 +0000 Subject: [PATCH] net: cdc_eem: fix tx fixup skb leak stable inclusion from stable-v4.19.196 commit f4e6a7f19c82f39b1803e91c54718f0d7143767d category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9R4FF CVE: CVE-2021-47236 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f4e6a7f19c82f39b1803e91c54718f0d7143767d -------------------------------- [ Upstream commit c3b26fdf1b32f91c7a3bc743384b4a298ab53ad7 ] when usbnet transmit a skb, eem fixup it in eem_tx_fixup(), if skb_copy_expand() failed, it return NULL, usbnet_start_xmit() will have no chance to free original skb. fix it by free orginal skb in eem_tx_fixup() first, then check skb clone status, if failed, return NULL to usbnet. Fixes: 9f722c0978b0 ("usbnet: CDC EEM support (v5)") Signed-off-by: Linyu Yuan Reviewed-by: Greg Kroah-Hartman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Cai Xinchen --- drivers/net/usb/cdc_eem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c index 61ea4eaace5d..e3f108080af1 100644 --- a/drivers/net/usb/cdc_eem.c +++ b/drivers/net/usb/cdc_eem.c @@ -135,10 +135,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, } skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); + dev_kfree_skb_any(skb); if (!skb2) return NULL; - dev_kfree_skb_any(skb); skb = skb2; done: -- Gitee