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 3940E8494 for ; Thu, 5 Jan 2023 13:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1B76C433F1; Thu, 5 Jan 2023 13:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672923821; bh=cKxFVoRDndxq+75mI7m+XCgtCF96VQrQCnULyj/q0lI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pq5FGNKp3Gb6SXrLHXwCnTM6L6YliCwBVPDx2sCb1nlnRavNADfWiKedRhd5O9KHs GK9k1DrmHXAHF5LLFBOF5ZylyMLcY9Avx/tQqNhHhd1oqo+Nb3GHv1QuWaVDJdFZwn k+XH6spg6eo4o7+FEmMHexQ0SMnzsh5DpXhzOIAE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, YueHaibing , Sasha Levin Subject: [PATCH 4.9 144/251] staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor() Date: Thu, 5 Jan 2023 13:54:41 +0100 Message-Id: <20230105125341.431045015@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105125334.727282894@linuxfoundation.org> References: <20230105125334.727282894@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: YueHaibing [ Upstream commit d30f4436f364b4ad915ca2c09be07cd0f93ceb44 ] The skb is delivered to netif_rx() in rtllib_monitor_rx(), which may free it, after calling this, dereferencing skb may trigger use-after-free. Found by Smatch. Fixes: 94a799425eee ("From: wlanfae [PATCH 1/8] rtl8192e: Import new version of driver from realtek") Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20221123081253.22296-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 247475aa522e..23c917342943 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1508,9 +1508,9 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen += 4; } - rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen); ieee->stats.rx_packets++; ieee->stats.rx_bytes += skb->len; + rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen); return 1; } -- 2.35.1