Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp92994pxb; Wed, 23 Mar 2022 13:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHhbEY0URXSMCLT2JPLxMHbUxs/67ZHJ/bH6uCaek3kwazZlfFORA4DRuQng85n+nAaXqC X-Received: by 2002:a65:46c2:0:b0:385:fb1c:f0c4 with SMTP id n2-20020a6546c2000000b00385fb1cf0c4mr1284284pgr.405.1648068408859; Wed, 23 Mar 2022 13:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648068408; cv=none; d=google.com; s=arc-20160816; b=Qa1wKYRH++7jTk78ahLg9mY3BsfesjtXNXhNwxwWGEZZ16vhTzCR4VKXLkCk8Z3fAp spzKhXMlvHtEwEOaGctCDzrR5xh4LjYJqp5p2UmZMX3j+Mc/3/OqYMc1E08kp74vJC+D HbvD1nnU2sKFs6kQRcFKDc6BqCDg0bpaho6t0QEL2hJZOx78V7JqDMMNf8fhDW82FrN7 XXM/3MGrYYz1s877mnZ/8dBx5ipQRwNoXWZHR58Gs1+SlR+QD1nDTZj3vH3M8UfC7LJx P4ZSaVdDgymyi7lLNpnYWuCHjSwo5qEcT7p5Cmyumlb6luCSux8it9ejEuHs411a/yhL AxDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qF5/zXwuEnWpLIRsAVxVh/Job5uOkCMuFaxCIQWpM7g=; b=rBtG7M6HyhvzVrPzWFI3Rbkfij8Xk7pB4wDLWk233VeO8gcs2meLLA300dMemrbgqn qy/zqKGXIP4zmYT5UY7FrL6O2E8+o7W/NjXbzaYgbOLENDJvfUKOoPgZQrqiqMaGceLg AYzs8gYyabXPsjC0Jyskm/Jr+2/GdW1XLij8YxC3bldeNfjm67MZOv0HSSeRaEIHMjGM NkTKs1erZACVxTmvXcNbNRvPqMY9OwQfnQ+I+BtQUSq8famAGfImmubbcwW+exunQ57A VnoZjb3W6mtJsfRp0/ceGyIwSDUt0OwCUDynwD/8d4A+rn5DybFzpoMgyRrrOdutgJrT w0eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=vnYlJ7LW; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a170902d3c200b00153b2d16437si17847366plb.63.2022.03.23.13.46.33; Wed, 23 Mar 2022 13:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=vnYlJ7LW; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245369AbiCWQII (ORCPT + 70 others); Wed, 23 Mar 2022 12:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245445AbiCWQIB (ORCPT ); Wed, 23 Mar 2022 12:08:01 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E89B7C17E for ; Wed, 23 Mar 2022 09:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1648051592; x=1679587592; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=qF5/zXwuEnWpLIRsAVxVh/Job5uOkCMuFaxCIQWpM7g=; b=vnYlJ7LW7OY4OGzSDNJa/6KpTUUNqBNxfOMshlfE7AU0Krz5m/RapqEe dqy3L1+o6ZwA/wYukh+yg4hm7Ttj0O5Y1zZIyd2tZPh074h6OAnEpH9VS dQ5i3hfepn+5XMf3iSXHUNg+vywCEHLkZjmufvvl/19jxBKvVda4QbwM6 8=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 23 Mar 2022 09:06:32 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 09:06:32 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 23 Mar 2022 09:06:31 -0700 Received: from [10.110.23.155] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 23 Mar 2022 09:06:31 -0700 Message-ID: Date: Wed, 23 Mar 2022 09:06:30 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [BUG] deadlock in nl80211_vendor_cmd Content-Language: en-US To: William McVicker CC: Johannes Berg , , Marek Szyprowski References: <0000000000009e9b7105da6d1779@google.com> <99eda6d1dad3ff49435b74e539488091642b10a8.camel@sipsolutions.net> <5d5cf050-7de0-7bad-2407-276970222635@quicinc.com> From: Jeff Johnson In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-wireless@vger.kernel.org On 3/22/2022 2:58 PM, William McVicker wrote: > On 03/22/2022, Jeff Johnson wrote: >> On 3/21/2022 1:07 PM, Johannes Berg wrote: >> [..snip..] >> >>>> I'm not an networking expert. So my main question is if I'm allowed to take >>>> the RTNL lock inside the nl80211_vendor_cmd callbacks? >>> >>> Evidently, you're not. It's interesting though, it used to be that we >>> called these with the RTNL held, now we don't, and the driver you're >>> using somehow "got fixed" to take it, but whoever fixed it didn't take >>> into account that this is not possible? >> >> On this point I just want to remind that prior to the locking change that a >> driver would specify on a per-vendor command basis whether or not it wanted >> the rtnl_lock to be held via NL80211_FLAG_NEED_RTNL. I'm guessing for the >> command in question the driver did not set this flag since the driver wanted >> to explicitly take the lock itself, otherwise it would have deadlocked on >> itself with the 5.10 kernel. >> >> /jeff > > On the 5.10 kernel, the core kernel sets NL80211_FLAG_NEED_RTNL as part of > the internal_flags for NL80211_CMD_VENDOR: > > net/wireless/nl80211.c: > { > .cmd = NL80211_CMD_VENDOR, > .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, > .doit = nl80211_vendor_cmd, > .dumpit = nl80211_vendor_cmd_dump, > .flags = GENL_UNS_ADMIN_PERM, > .internal_flags = NL80211_FLAG_NEED_WIPHY | > NL80211_FLAG_NEED_RTNL | > NL80211_FLAG_CLEAR_SKB, > }, > > So the 5.10 version of this driver doesn't need to directly call rtnl_lock() > within the vendor command doit() functions since pre_doit() handles the RTNL > locking. > > It would be nice if nl80211_vendor_cmd() could support taking the RTNL lock if > requested via the vendor flags. That would require moving the wiphy lock to > nl80211_vendor_cmds() so that it could take the RTNL and wiphy lock in the > correct order. Is that something you'd be open to Johannes? > > --Will Thanks for correcting my understanding. I concur that it would be useful for vendor commands to be able to specify that a given command needs the RTNL lock to be held.