From patchwork Sun Jan 14 18:03:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Brodowski X-Patchwork-Id: 10162723 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.web.codeaurora.org (Postfix) with ESMTP id 63F5160216 for ; Sun, 14 Jan 2018 18:12:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 529F528A68 for ; Sun, 14 Jan 2018 18:12:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 456BE28AC3; Sun, 14 Jan 2018 18:12:14 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 EC14928A68 for ; Sun, 14 Jan 2018 18:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751820AbeANSML (ORCPT ); Sun, 14 Jan 2018 13:12:11 -0500 Received: from isilmar-4.linta.de ([136.243.71.142]:55610 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751622AbeANSML (ORCPT ); Sun, 14 Jan 2018 13:12:11 -0500 X-Greylist: delayed 506 seconds by postgrey-1.27 at vger.kernel.org; Sun, 14 Jan 2018 13:12:10 EST Received: from light.dominikbrodowski.net (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTPS id 608C32008BC; Sun, 14 Jan 2018 18:03:43 +0000 (UTC) Received: by light.dominikbrodowski.net (Postfix, from userid 1000) id 63DD3206C7; Sun, 14 Jan 2018 19:03:38 +0100 (CET) Date: Sun, 14 Jan 2018 19:03:38 +0100 From: Dominik Brodowski To: johannes.berg@intel.com Cc: regressions@leemhuis.info, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] nl80211: take RCU read lock when calling ieee80211_bss_get_ie() Message-ID: <20180114180338.GA1569@light.dominikbrodowski.net> References: <20171222072012.GA3110@light.dominikbrodowski.net> <20171230131132.GA2624@light.dominikbrodowski.net> <20180108100403.GA4715@light.dominikbrodowski.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180108100403.GA4715@light.dominikbrodowski.net> User-Agent: Mutt/1.9.2 (2017-12-15) 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 As ieee80211_bss_get_ie() derefences an RCU, it needs to be called with rcu_read_lock held. Fixes: 44905265bc15 ("nl80211: don't expose wdev->ssid for most interfaces") Signed-off-by: Dominik Brodowski --- This patch fixes the regression I reported in the last couple of weeks for various v4.15-rcX revisions to netdev, where a "suspicious RCU usage" showed up in net/wireless/util.c:778. diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2b3dbcd40e46..1eecc249fb5e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2618,8 +2618,10 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag const u8 *ssid_ie; if (!wdev->current_bss) break; + rcu_read_lock(); ssid_ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, WLAN_EID_SSID); + rcu_read_unlock(); if (!ssid_ie) break; if (nla_put(msg, NL80211_ATTR_SSID, ssid_ie[1], ssid_ie + 2))