Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3687829lfo; Mon, 23 May 2022 11:28:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3tVaXdoTJvmfnrsxe4SUTzsbuSxz3KOGrWLzkR+kCQ505E+/LamB2R1yIjBTThXZMPKrN X-Received: by 2002:a17:903:d1:b0:15f:3277:fae with SMTP id x17-20020a17090300d100b0015f32770faemr24245204plc.69.1653330511087; Mon, 23 May 2022 11:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330511; cv=none; d=google.com; s=arc-20160816; b=smYP9cUADeRkYwRTsIJc/JXhAditiVI39BAIEPKU8PIAQqdRXYEI0odhRF/nXPbUqR rAv3lW6sBL+jQMhwEPqiy75qcGkWH2+MuPOBWe/IlBd/DFn4OAftxMaqhkQ/XyTaiyLs KEKma6Mjw1KoL70Cv7tJ2lunQrOkyR8Kb5TuHoageo/yN8FfMBNFbYvngplXfoysC/fm r7LROiTGkEiGh66GrkY2A6zoOh/YINAgp3sU4Uo1CNZx1XDgy/mnKGPDXbXd//YNpsuE lQgjxT9tlGRpuxYb12mKkj6UBNsIzdLKRSr72HloSwXMYrEvsx/1JfKyTU3AXvwmX61x a2AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SVaB3R84WAE0UejZFOcc3tVnerZ1o7WHrzwb1fL0siM=; b=kL3IJgxyUD4aQqzQiT+wmgU/tmDk+aXkKP/V8SLToPFyk2QjCshO4zOTlzJsqIV/xs InqZZ8uYZD6rS473GE4olvR50oWMOSfjIeHVZiq557849fHsl5DIofoUtN7j4uZmNmtN 9uNUho6Uh9hV3xgG0JH+zxer2f/0S5toseNxyM4HhykMhWdlpp9xGxydxuMObM8XMH3s ypBWAQMhmjs2XrX2YNKk2OvymTtwaAifkZYRnjbnyyFevWdmTm8zXJKXBNqgqO6N4oKo qcvf3oLCiuGilAvvQaqiZ6zIvGh5rAG4pHyVM05JUQThmck6NSWf63eJleppqczUsyaB XpnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgMJj3SH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d11-20020a170903230b00b00161e9f72b11si9408292plh.540.2022.05.23.11.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:28:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgMJj3SH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4AC89CF00; Mon, 23 May 2022 11:27:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343964AbiEWSIq (ORCPT + 99 others); Mon, 23 May 2022 14:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243578AbiEWRiS (ORCPT ); Mon, 23 May 2022 13:38:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B42A6B7C2; Mon, 23 May 2022 10:32:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AAA24B811FE; Mon, 23 May 2022 17:31:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B56EC385AA; Mon, 23 May 2022 17:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653327069; bh=m80PVdEZX1lH4vWt6edcuHR6RqQ39qIO0Eig5ttw22Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgMJj3SHumIOJ5vu2MdieIW4Nns6uIwxpPEncdk9VIRlIQe1LzEJiWfB6LGrO0yGD Ir04TLEhMzqk/4jOl/99NozQNvnJWBKrtYdw7gR4NdOUisBdHy04GAW8Ye0gAe59B6 My8FqnADKJ6viZofD7FdhXob4EDYFnd4OhTKc+3U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Sasha Levin Subject: [PATCH 5.17 147/158] nl80211: fix locking in nl80211_set_tx_bitrate_mask() Date: Mon, 23 May 2022 19:05:04 +0200 Message-Id: <20220523165854.543117070@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit f971e1887fdb3ab500c9bebf4b98f62d49a20655 ] This accesses the wdev's chandef etc., so cannot safely be used without holding the lock. Signed-off-by: Johannes Berg Link: https://lore.kernel.org/r/20220506102136.06b7205419e6.I2a87c05fbd8bc5e565e84d190d4cfd2e92695a90@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/nl80211.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 06a35f1bec23..0c20df052db3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -11573,18 +11573,23 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, struct cfg80211_bitrate_mask mask; struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; int err; if (!rdev->ops->set_bitrate_mask) return -EOPNOTSUPP; + wdev_lock(wdev); err = nl80211_parse_tx_bitrate_mask(info, info->attrs, NL80211_ATTR_TX_RATES, &mask, dev, true); if (err) - return err; + goto out; - return rdev_set_bitrate_mask(rdev, dev, NULL, &mask); + err = rdev_set_bitrate_mask(rdev, dev, NULL, &mask); +out: + wdev_unlock(wdev); + return err; } static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) -- 2.35.1