From patchwork Wed Nov 23 08:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 24786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2660447wrr; Wed, 23 Nov 2022 00:24:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf48UO4pLZKAUQjtaC2aZfumiDRg/mwBT3PYjH5Y4rYSzXerW44k7v1CbXdfLNPiWUAl48US X-Received: by 2002:a17:90b:681:b0:213:ff80:1828 with SMTP id m1-20020a17090b068100b00213ff801828mr35816292pjz.31.1669191896307; Wed, 23 Nov 2022 00:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669191896; cv=none; d=google.com; s=arc-20160816; b=tqa8VyG0s+hTTaqQo6rORv1L9YH6TYzLaACwKWyDyF9LVqbVIaaflyQuu0KO5cGIyj 1AJUQ4Aa2LITcQ1+31vmMW4tSGUCDH2LdfIfIFqKCJ/SFv1Gr8IlKl2naK5SdfajkQUu N/5ovtOx3Ne65n80wwVrg3GTAyrYbqr7ke/n7eMkGNzeM0ujE337KJZsm8yX7WuHwX3x zCByq4qLavWqAzD5faIHczPdHKujgvjcska+n66MKgFu1N5xGX/aFMqwAnpOmvzp1Q7C INkmAUItZwvTNTPzQCQFVMagp1x8U74Lr2W1xkfZEuXi4epylQ+KIRkdfqhERIRNoUFI mifg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=of5tzXG2ppo4pHxjH4g9bZGMf+7XTQWYY/oN9quPL80=; b=kDlK+a6CUi3g28sckJ1AbJQ65j/W2Pi6MDcNPzRzC5YZcBWxlavPoz3YPM2SLbJFCm 4yJ20lLwUC4wNdaR0KhLsRM6dL4VSgxHdj2pHiFKw+FFQj7K74QJyWGXyeyv8kKP65YW 7Z0BKfGsWnw3A0ipe1S1x7WwsK6WcXnKicfkRGJvEA4Jq2iuy7orbScYnhGR0K16kf8f Hu8GO/hwM+Uj1YrT0PJTnsiKjPkPJg6VgCSzNeSpzWGNSylMHwEf5hzQNf2x57zSFogw skS3nA0gQU295HeChdVy6TlCwClKm3ZZNBOrPUrOWnxK2sFcL/eozQMnMqFXG/55Olyl sHfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a1709027fca00b001889ad48288si15871612plb.384.2022.11.23.00.24.43; Wed, 23 Nov 2022 00:24:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235962AbiKWINK (ORCPT + 99 others); Wed, 23 Nov 2022 03:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235705AbiKWING (ORCPT ); Wed, 23 Nov 2022 03:13:06 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B88541E72C for ; Wed, 23 Nov 2022 00:13:03 -0800 (PST) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NHDPj1sHnzHw5J; Wed, 23 Nov 2022 16:12:25 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 16:13:01 +0800 From: YueHaibing To: , , , CC: , , YueHaibing Subject: [PATCH] staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor() Date: Wed, 23 Nov 2022 16:12:53 +0800 Message-ID: <20221123081253.22296-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750274561763860854?= X-GMAIL-MSGID: =?utf-8?q?1750274561763860854?= 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 --- 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 6a0f5bbb99ef..f8965afab767 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1489,9 +1489,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; }