Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp494733ioo; Thu, 26 May 2022 08:06:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzshJrSU6IOEypDKoltDIhZTkmkc35w0DWUDIp6YMUx4hPNXK31AGHD0FmEgrTbn0KcB7q7 X-Received: by 2002:a17:902:8ecc:b0:15e:f63f:233f with SMTP id x12-20020a1709028ecc00b0015ef63f233fmr38092666plo.86.1653577587045; Thu, 26 May 2022 08:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653577587; cv=none; d=google.com; s=arc-20160816; b=Ssz5Vr3P0UteHYphnomHH54k8KEoQZs699xj6kM63UbO1fHwaJvQCzE3B7eW7cAI8G PhiQAvdsnuSuQVJDFe/SL57W1o/dj6ogerA/S3GA5QFelkkA3b+BxAhwnBKUCLqIG7rn mkvuvNv/H/U4LELfW2UlJ00jM+3L/NV/BMXjbAUrcbcV9DfALoFPTlXJ/0kMCYCjAKKr 7PUb168iy+ttYcu1BNvV+rqpyFTwROHj4qXbmurqnKh6cPb1ElxbUNxkBFUL+ih45zfr CeSQk24zR6sD9hJZzcfCKQI6fcTDt8b1dzX3FHFe+diAXgiGq05NA/PBi1lFKss/CXmK OQwg== 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=/lTZqxrMqc5ejlnA71+mREzAmjmavcgKMTAHD5DJbCs=; b=XEI1aFLCntJCsxb+GmSQ6i+2cbu5cW961SjKGzttFoxQNmFp1qlnUL3W7DPoXQ3u5T xdzyxPQ4gbFXJXioEJ6hZ4jHXP9jZZ2ZqfZEXq2IEsn++yTDjl0CA6itSwZLXrH3083h VlB1Q7wQj1Dp0D2OPHDIbQW0dikTIQmUGrkBxXZVEBapI68YPwweteB+DflOXl6q0RTi VG1Tqfs7LHBQbKIN7C2xYpHBRQ2y6dFONywcgy3fzLDrR8B8yzeq52f3D10By3cJdQMZ n6W+JNuoUdPY1JhIX3r98NpifpDFsB5nMbLey/f0I2FY0na9FPscW7T8lkXwK3KOfe78 Sx5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a655345000000b003f5e7c0649bsi2693295pgr.698.2022.05.26.08.06.10; Thu, 26 May 2022 08:06:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346840AbiEZJJK (ORCPT + 67 others); Thu, 26 May 2022 05:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346848AbiEZJJH (ORCPT ); Thu, 26 May 2022 05:09:07 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FEC1C6E60 for ; Thu, 26 May 2022 02:09:04 -0700 (PDT) X-UUID: 09f30c726dec4624952532b31b8c1c95-20220526 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:704cbe87-2e61-4fd4-b61b-8ecf7b671e68,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:e8d59147-4fb1-496b-8f1d-39e733fed1ea,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: 09f30c726dec4624952532b31b8c1c95-20220526 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 137534923; Thu, 26 May 2022 17:08:57 +0800 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Thu, 26 May 2022 17:08:56 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 May 2022 17:08:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Thu, 26 May 2022 17:08:56 +0800 From: Ryder Lee To: CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , "Ryder Lee" Subject: [PATCH] mac80211: check skb_shared in ieee80211_8023_xmit() Date: Thu, 26 May 2022 17:08:53 +0800 Message-ID: <1ef9b892cc93a36b1e62a6dda0e2e0a019f4e5f7.1653555361.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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-wireless@vger.kernel.org Add missing skb_shared check into 802.3 path as 802.11 path does to prevent potential use-after-free from happening. Signed-off-by: Ryder Lee --- net/mac80211/tx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0e4efc08c762..b026e746ac5b 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4437,7 +4437,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, struct net_device *dev, struct sta_info *sta, struct ieee80211_key *key, struct sk_buff *skb) { - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_info *info; struct ieee80211_local *local = sdata->local; struct tid_ampdu_tx *tid_tx; u8 tid; @@ -4452,6 +4452,17 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) goto out_free; + if (skb_shared(skb)) { + struct sk_buff *tmp_skb = skb; + + skb = skb_clone(skb, GFP_ATOMIC); + kfree_skb(tmp_skb); + + if (!skb) + return; + } + + info = IEEE80211_SKB_CB(skb); memset(info, 0, sizeof(*info)); ieee80211_aggr_check(sdata, sta, skb); -- 2.29.2