From patchwork Tue Mar 10 10:13:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 222772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A47E0C10F27 for ; Tue, 10 Mar 2020 10:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 767FC24682 for ; Tue, 10 Mar 2020 10:14:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="Of4xEvK4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726637AbgCJKOW (ORCPT ); Tue, 10 Mar 2020 06:14:22 -0400 Received: from mail-bn8nam12on2076.outbound.protection.outlook.com ([40.107.237.76]:6032 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726316AbgCJKOV (ORCPT ); Tue, 10 Mar 2020 06:14:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JiTDrLHJW030/yLAfhAq99N1dyeGbPGeEi5Facu2R9B66YsRpFLK82WtkuXO25Kn36UQmrodwUqrcayHOMDg/iZKEyZoBa5Uwr285C5O7vArVeozLihONKlfYRaTlaeHCENrAYcd0jhq4Y6mmbVnOpdzZ5XGCWQZkFcF1/kqO3AAGZznqLVxbvO4pcJXKF4b4YAMoFGoeeUgdaU4Mb5EVimLAATqoag5L6xVmD9lsQS0qYD9dxvru3C3niALFhjmhDXMQaidRGWrNYN5MCSH2Nt7XTmJh0CDqgGoBYFbXp4ebSSh6nGCeVj9g1WrY3fwg/QuiFP4hgZ7f4IN+73K5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E7/+NAZflO+4IVZuFWFhpIkVJOdHGRDq2rkYSpc44Y8=; b=NVN6dcY0BX5gp7hbxRCzQ2BYelOiOJUFiL7q4BjpHZGCEaNMrJ++U9andxfoR2l48BHCeI+F54IMy2DMJ3De6ioeVbSrUe0HVf21JBqM6yJzCyAvp7W122KO8N7m61+rz7pLchlFLo7E/QXASbGz1uPiqUypKkgjZBrQzGMCx9XEsJyMSTU7hgKFvvhqAUBQQb5sSpnPrgeUiWkJjyzF0uOW5TbwrVal7IY/anjWUercTwRFPzT/0nnfhbiwf85soC/J2LBACgVV5H1iipsDsvqg6B8suN4ktY9Kg5tcnbD2LCVNOFHSv+GMj3+agijsrBaDRuwlNrB4FqKlDLZ1kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E7/+NAZflO+4IVZuFWFhpIkVJOdHGRDq2rkYSpc44Y8=; b=Of4xEvK4o0NWiAg8l2ZnLRItscheLfDEMBWLpH2S7uhSCcv3OJJ0Np8GzJmr3t1tIIZt9EFN2Jbwnb+f9NuRTdnpcJOVIekkklsEkBq8QaFBBrn/KqcXTC7mK/4qdha/LE0MjkJ0aZk/ozor/Y1GTaEfI+yjLDZ6ybZoMrzQZvM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3615.namprd11.prod.outlook.com (2603:10b6:208:ec::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.17; Tue, 10 Mar 2020 10:14:19 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::ade4:5702:1c8b:a2b3]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::ade4:5702:1c8b:a2b3%7]) with mapi id 15.20.2793.013; Tue, 10 Mar 2020 10:14:19 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 4/5] staging: wfx: fix RCU usage in wfx_join_finalize() Date: Tue, 10 Mar 2020 11:13:55 +0100 Message-Id: <20200310101356.182818-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310101356.182818-1-Jerome.Pouiller@silabs.com> References: <20200310101356.182818-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR0P264CA0180.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::24) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (37.71.187.125) by PR0P264CA0180.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.14 via Frontend Transport; Tue, 10 Mar 2020 10:14:17 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [37.71.187.125] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae01b841-0c73-4dc4-f8a6-08d7c4dbcb94 X-MS-TrafficTypeDiagnostic: MN2PR11MB3615: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 033857D0BD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(136003)(366004)(376002)(396003)(346002)(189003)(199004)(6666004)(52116002)(5660300002)(2616005)(86362001)(316002)(956004)(36756003)(478600001)(7696005)(8936002)(54906003)(4326008)(16526019)(186003)(26005)(6486002)(66574012)(66946007)(8676002)(1076003)(81166006)(2906002)(66476007)(81156014)(66556008)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3615; H:MN2PR11MB4063.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lyOiIEVhMj+C9glfYT61Mcfyfhv+4kVzTE5ukiDaA46oA82whQOxe00LuEqlL5Nsj2WYe5ORFBfw+XbUFF3K5nHwKTAB2jqFjoOyJSAnTxo7JUcnoVxXAmtQq6Dynd1hAjO4WxiPwoVH6wPDT4BQYdX2BUFU6RpzIEHDSaAQ1tHMRPNT19bgot12iJiVUDsCWYkj0VEoNsMQLvciMR1NNa+Ygnx0MC6IbgL3w/FQMAu7frpNF0C1nTgiIM3Wz0xkHwNHxJXuSRRXaM43oeX7iOk0DlHVFhNhz/KzuSQzIcglpr+HUyvDQUBe+UYeSgXQkDaYzUsAddN+6rY2Z0xrlDU26Uy+sllSRsaNekd/yWMusF+k6+SE/BkJeIl7FhICDi9xgXb0F80zFP3YIDGhMyam0Pa1Le1822h/5dAv0rNTKkPFrErccypD01h9ViaK X-MS-Exchange-AntiSpam-MessageData: N/kzrS6g6KLHlAsh7IOwanNA+mf+gQd8wtxijQ7ISBPwse+SeodN39hp459M0su7KiF0X43fjutymbksGpcWFH+V6qIsC+4FYslm8NxtgCuVhLl/3VpQ2CHwuWAZEEpXWOtnnzF2W3FBO2du6prPzw== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae01b841-0c73-4dc4-f8a6-08d7c4dbcb94 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2020 10:14:19.1342 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4lw/Y+lBWNxjE3CBk5Wm3SSlEOF4GwrLiXx2FWEdtKGJ30qVFmCa8XTUeQNsOc5JE6L0mfWSYXXGvdyb/QkMdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3615 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Access to sta->ht_cap is protected by RCU. However, hif_set_association_mode() may sleep, so it can't be called in RCU. This patch fix this behavior by handling sta and its RCU directly from function hif_set_association_mode(). Signed-off-by: Jérôme Pouiller Fixes: d00149011066 ("staging: wfx: fix RCU usage") --- drivers/staging/wfx/hif_tx_mib.h | 15 ++++++++++----- drivers/staging/wfx/sta.c | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index bf3769c2a9b6..26b1406f9f6c 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -191,10 +191,10 @@ static inline int hif_set_block_ack_policy(struct wfx_vif *wvif, } static inline int hif_set_association_mode(struct wfx_vif *wvif, - struct ieee80211_bss_conf *info, - struct ieee80211_sta_ht_cap *ht_cap) + struct ieee80211_bss_conf *info) { int basic_rates = wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates); + struct ieee80211_sta *sta = NULL; struct hif_mib_set_association_mode val = { .preambtype_use = 1, .mode = 1, @@ -204,12 +204,17 @@ static inline int hif_set_association_mode(struct wfx_vif *wvif, .basic_rate_set = cpu_to_le32(basic_rates) }; + rcu_read_lock(); // protect sta + if (info->bssid && !info->ibss_joined) + sta = ieee80211_find_sta(wvif->vif, info->bssid); + // FIXME: it is strange to not retrieve all information from bss_info - if (ht_cap && ht_cap->ht_supported) { - val.mpdu_start_spacing = ht_cap->ampdu_density; + if (sta && sta->ht_cap.ht_supported) { + val.mpdu_start_spacing = sta->ht_cap.ampdu_density; if (!(info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) - val.greenfield = !!(ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD); + val.greenfield = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); } + rcu_read_unlock(); return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_ASSOCIATION_MODE, &val, sizeof(val)); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 010e13bcd33e..ed16475c207c 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -691,6 +691,7 @@ static void wfx_join_finalize(struct wfx_vif *wvif, wfx_rate_mask_to_hw(wvif->wdev, sta->supp_rates[wvif->channel->band]); else wvif->bss_params.operational_rate_set = -1; + rcu_read_unlock(); if (sta && info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) hif_dual_cts_protection(wvif, true); @@ -703,8 +704,7 @@ static void wfx_join_finalize(struct wfx_vif *wvif, wvif->bss_params.beacon_lost_count = 20; wvif->bss_params.aid = info->aid; - hif_set_association_mode(wvif, info, sta ? &sta->ht_cap : NULL); - rcu_read_unlock(); + hif_set_association_mode(wvif, info); if (!info->ibss_joined) { hif_keep_alive_period(wvif, 30 /* sec */);