From patchwork Wed Jul 24 12:36:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 11056771 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FBCA746 for ; Wed, 24 Jul 2019 12:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F2A628803 for ; Wed, 24 Jul 2019 12:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4247C28814; Wed, 24 Jul 2019 12:36:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B0228803 for ; Wed, 24 Jul 2019 12:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728358AbfGXMgb (ORCPT ); Wed, 24 Jul 2019 08:36:31 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42699 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbfGXMgb (ORCPT ); Wed, 24 Jul 2019 08:36:31 -0400 Received: by mail-pl1-f193.google.com with SMTP id ay6so21993078plb.9; Wed, 24 Jul 2019 05:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4kFGVQZY9I0OMqjA+TXCJoqeRUuUARnDiyE+ekteJw8=; b=GBmh8afT6DCU6YFrZicRslPpNSfzFbIalG6g47iHbI6MZKpj6hddTpPHpSnVXiOAi0 xNwTNNqy0rtsgF5r4CMIm5bAWYig2gq/0N+twP2Dbf5nZ8Z3EZSCO3fJ5TOHRDmmYPnF +KK4i9btnFwmmaHtiTlP/o6u7Cwbo2AY6zEd6f6Br9JAS4oslD6GchDETIEU0zuFEEMb ZyKN1Y6F4hJLlKHzWOWVHKNij4oKmZOSDgWyQJbTGDOKU5BZKquto+KwDCQ38TjUbj+M Xfsm6C6bwFiMRJ0vHtSrT7cNLwoXZzS7PYuFOk4UtqgzYunHQFZnPuf4wnWm7k2Mwuvc 79yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4kFGVQZY9I0OMqjA+TXCJoqeRUuUARnDiyE+ekteJw8=; b=W83x79UobYbmuStTD2oZhhi252izhmd15AGrnObFDuMtcpudYxxM1aJW3diCThXgM0 U97mSN+58RIUlSIESaVbbR+Pe9ngSyIYYrg/Va15HDzeZ7rB2dfIa0z2eXsYQ+CHJh8O qbmwUWxoDFQMLiZ2NGY23gw9yY/YcRHbZ/3Awma2OGe28PVJgfcXkCGDV91xcQa+aYtV fl4PdETh4I4UmSwWKjorHBoogXSDPpTCxQzkdEdACIq4O4Pe6HsMxLz8/9BVxa0l1uiI JgWCrmBcC8YBNH5ZSXbAeFirHSe3NvDtMlKrB1QxPr7jjaKk3AypcLEzdsqUibd0yCaE Zjmg== X-Gm-Message-State: APjAAAUNtXWKWkr8wLpQVH8AOwdo83715Pzz5dqhNDtAi37X2z5qFodH +Ff3rzQBzcOhgJWZ9OlzUXeaggkbl78= X-Google-Smtp-Source: APXvYqzqvclR6pNhtPq4cidLWcB2P/tDnhN5lpGXAHGlFB6jrqMIQPCz4PfQO+sx5+p4RaFC1Kr9Qw== X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr76301912plp.245.1563971790673; Wed, 24 Jul 2019 05:36:30 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id p65sm45935526pfp.58.2019.07.24.05.36.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 05:36:30 -0700 (PDT) From: Jia-Ju Bai To: johannes@sipsolutions.net, davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 1/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_setup_sdata() Date: Wed, 24 Jul 2019 20:36:23 +0800 Message-Id: <20190724123623.10093-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In ieee80211_setup_sdata(), there is an if statement on line 1410 to check whether sdata->dev is NULL: if (sdata->dev) When sdata->dev is NULL, it is used on lines 1458 and 1459: sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP; sdata->dev->netdev_ops = &ieee80211_monitorif_ops; Thus, possible null-pointer dereferences may occur. To fix these bugs, sdata->dev is checked before being used. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- net/mac80211/iface.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 06aac0aaae64..e49264981a7b 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1455,8 +1455,10 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, ieee80211_mesh_init_sdata(sdata); break; case NL80211_IFTYPE_MONITOR: - sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP; - sdata->dev->netdev_ops = &ieee80211_monitorif_ops; + if (sdata->dev) { + sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP; + sdata->dev->netdev_ops = &ieee80211_monitorif_ops; + } sdata->u.mntr.flags = MONITOR_FLAG_CONTROL | MONITOR_FLAG_OTHER_BSS; break; From patchwork Wed Jul 24 12:36:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 11056773 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B41813AC for ; Wed, 24 Jul 2019 12:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC0528803 for ; Wed, 24 Jul 2019 12:36:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 004BE28814; Wed, 24 Jul 2019 12:36:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A92E128803 for ; Wed, 24 Jul 2019 12:36:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbfGXMgo (ORCPT ); Wed, 24 Jul 2019 08:36:44 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37788 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbfGXMgo (ORCPT ); Wed, 24 Jul 2019 08:36:44 -0400 Received: by mail-pl1-f193.google.com with SMTP id b3so21975302plr.4; Wed, 24 Jul 2019 05:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9Y7vn96lG/SonoxneykCtISW/bv1WUyhoDMBdhzYd/E=; b=kz9EUmanSnC0l/FHzyWj0Ew0jqrIOrwgL336BcPBG3gHWyiTHDEzdoYDIraHIe0+2M IhH8Kd98DS0LyweccALZ/EZRsxhoZ4fFojrMyz4VNemWc4Y8RtQ6F7YS4z8WGqeUdnik YXUvjX44JbFwapw5WvXxvnapGJfAzevcBjZafXBLoyY6w2hzRjHv3FFpgPLIdC8rxGPT Z9/bi2BLGSMmHXaYMZ8ZL0tjRoRZXnAZiOvPVuuKcdep0sa+m8soM3GDA0P+Oe21Htm9 1A6Sh9+IZz7HaKcq21Y48wEmpNz2fl92Rp75FwovdAkNcM3a/+1imsnn1YdEKkvEIjIj 50Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9Y7vn96lG/SonoxneykCtISW/bv1WUyhoDMBdhzYd/E=; b=JJcK7XImxmytvJy/86+cA3fyV7Kw2oHP3rlYFeHXRZPLxAW8rVM947TFK8BiIDvD6e 6yLEmTZbSv/9CuBjKYisHwFmOZQo3kyhHZ1WP6WSu8ItxtoGxNpSBY6h7uYqbC6TyyFA T1PFCIMlhYyoJ0eaym5y2n6w1zxcMO1RGEzHHthXHibrVFLwha4PRmBjElwT6Zfn1nFZ 8JvheZfOLeREKTCOZJFYCJzmsJy9vNSXd/LD7d4tRERWwLbncZLml9LJO4nE9k18XDRf W99TpvRWO4fVANRd765S6XwoZSO6kNP+nLrcpoIr3J4+g4CqT5znbtR3Rcpf/MxPx2hT sfdA== X-Gm-Message-State: APjAAAU1NasXJ0SnPCaJ2ALJZY+Sqnd07a0huAPMZOERyoUXgAYRpBIB qVUJd2xg+qE8V7hW2QLhNH4= X-Google-Smtp-Source: APXvYqz66tE/8060PJx6PuNGrwOD5jd3AB+6NsG3+Bdx64V6jnhIBRluTLEoFbPyEYNDgpc63gbOYw== X-Received: by 2002:a17:902:aa83:: with SMTP id d3mr83294210plr.74.1563971803776; Wed, 24 Jul 2019 05:36:43 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id j15sm68288184pfn.150.2019.07.24.05.36.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 05:36:43 -0700 (PDT) From: Jia-Ju Bai To: johannes@sipsolutions.net, davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_xmit_fast_finish() Date: Wed, 24 Jul 2019 20:36:33 +0800 Message-Id: <20190724123633.10145-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In ieee80211_xmit_fast_finish(), there is an if statement on line 3356 to check whether key is NULL: if (key) When key is NULL, it is used on line 3388: switch (key->conf.cipher) and line 3393: pn = atomic64_inc_return(&key->conf.tx_pn); and line 3396: crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); Thus, possible null-pointer dereferences may occur. To fix these bugs, key is checked on line 3384. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f13eb2f61ccf..2cc261165b91 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3381,7 +3381,7 @@ static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata, sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; - if (pn_offs) { + if (key && pn_offs) { u64 pn; u8 *crypto_hdr = skb->data + pn_offs;