Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9579650ybi; Wed, 24 Jul 2019 06:33:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdYZjeZTqFimiVze92DTbD9i+vSKrWOqugHF+FNat29DCSFxm4CoqHwrgrOroL1kmkLD8o X-Received: by 2002:a17:90a:ac13:: with SMTP id o19mr87962569pjq.143.1563975228856; Wed, 24 Jul 2019 06:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563975228; cv=none; d=google.com; s=arc-20160816; b=FRJbd3FxDlkpxYmoMefsflYDy+w+0G6sIgt7pNYOLK9AW1wyqYQrp4YzpbQktSS2Ff W2hqeunuOydw98HLewbJMqCspDqnUoCWaVlPyVICKRTS6rZztss/FaHudwCT/RnUcG8o hZtR9oR3o1cABrjeNVmQArRpgzbKnVxppN3qc997f7MD4Ca0nkR4My44nK4o7Wf1SgvD wiqj0ThHDThD0qh6OkFyt0gdGiD0D953kIqERpIX46V9Fb3RDpSMFSl1OK7mMwZeTMFi HjskRSVFH510N3nyT3SfmdENHZbA8AokgK1BSn0VeR0BytZTU8oop2+TVMTEqF+40tTT 0yyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=4kFGVQZY9I0OMqjA+TXCJoqeRUuUARnDiyE+ekteJw8=; b=RlpL9EMVyxbU+67l9/e+DR+u8IU1/nAyqDtbEPk/DR9CC5MJEdBzJ6hSAxvHv6MYnS oEo9biOn8Cll5e+XyKDcavnuXnbS/KXDZNlV66rEgP50XudmGv2yfCfYY+PZFW2IMcMe 551YH23x5FRsTOVUrWn9kzjSsSCtMfCHEgYNeDu1CQnhs/uOgV7bhdWCrFOXBFpAlBdL YQBwCnUtYVvMe0No8n6UOUleZmOIIpjmfmYFvL6H/wHSXAdLgQrxDe+xBTEqIC/rYd68 deNjCbrJ93CFFqG/SCJ3R9ThvOyCcShDnMeu7qenf+kCQoxTO+6DGb4WAQXRCI01MmvG gxsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GBmh8afT; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf16si13046452plb.346.2019.07.24.06.33.33; Wed, 24 Jul 2019 06:33:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GBmh8afT; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728343AbfGXMgb (ORCPT + 99 others); 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-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 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; -- 2.17.0