Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1549610ybz; Thu, 23 Apr 2020 00:37:07 -0700 (PDT) X-Google-Smtp-Source: APiQypL6ZtQEzXbyK4wAgNmIzcgzf2mrC5GRSzPp20N2zGwUvuZZc29qrjqYoK1yBc5YExjpqQik X-Received: by 2002:a17:906:1603:: with SMTP id m3mr1648690ejd.205.1587627427519; Thu, 23 Apr 2020 00:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587627427; cv=none; d=google.com; s=arc-20160816; b=ZIoEJIeblwEuJo0K+FLYqH6Q7W5WzDKhJWx5Z6z4pqd7Q6X2sENyWAcFA5Q3eSbyyQ gQNNaJIAA8ZHSlqoLQ00ADevZVo8sLPVtqbpgtSJFKXaUqGUcIJzJHLZZsYwmoL807eG axh6fA7JHuYB0qYTrKwXGJUIKc+EMb4SZ993fjoeQfZqyCM7DAZnoQf7YBRsCO96NX7Q t9I4PDDDtqUj74k1vv9bdNHKD4Md8yA4GnqiVWWpECfsmOh/BDHaa0nBcWG9N9sVyiSK G9lGKH7fC8AJHeh81ZBrAs/tsQ2uwNFo2iCQYCNeJehpGsX3NIXli3kKeyPiz9rI2m6c YIyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nH+zYjlvWP3Qo5orh796NHnCHvpiRUmXtBzvtTbcFcE=; b=w5paQjdKNJfx/UQXu3iH+U6gvbzBXFfAj1ak/V0Cs5L2KDWxobuiCPNE5HU/ObJfbO IM8fhv5J7KH1+yCrwFbJ0DIgACodFDI0Wd4KL3jwK+RHss6jV79W+YR5uY3Lb0Wvb6g2 M6L7jwnQwr1ijPEOeLvRfIr6X9L27B70vSaZaVu88phxWnj+FHdT6kGWhoIncLEg2Q34 NVzE+mXcnCQ5ZmsXnqOsNWWQYR/62sbit9X/qdXVjRcYtv2AhqJK0GsU0S4dr0piry9b IYUX/rvc0QiA9hMfJgZeAfN3N4Ia7W566b37FLxCngr1Y8ddhu9MGQuVurhFdDtqAxJ/ rBiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LVsNLptl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq2si773587ejb.426.2020.04.23.00.36.43; Thu, 23 Apr 2020 00:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LVsNLptl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbgDWHek (ORCPT + 99 others); Thu, 23 Apr 2020 03:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgDWHek (ORCPT ); Thu, 23 Apr 2020 03:34:40 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B546C03C1AB for ; Thu, 23 Apr 2020 00:34:39 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id u6so5130482ljl.6 for ; Thu, 23 Apr 2020 00:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nH+zYjlvWP3Qo5orh796NHnCHvpiRUmXtBzvtTbcFcE=; b=LVsNLptl4nB4LOLOaiGrH4RSyUJn61OIsD0obcDL/JRHZooBbLgar/q7RrUBhZUjzK ugGBfY3wsdiTy/UQpgcNMEHuchurnffz3Y48rEVDcJyzh07ypmD61oQ1HxAAKnQXqZUz cRUd8UTc8mjl9uq+v0HnWmXYAgOdUEdT5FQYKBdM/4vLD4d/9h9VaZkDa7GhO6eIHazi rsWYIhV4dQxLofUUYW/BewkevImnHnKe0qD+fCvqio8e7XAjlrnxpoSjnIkioOeZAuPp IM6YMOrYkvx1gxh28IIt2m/XkjuA8sOwimPRjl3J2ncpG/gRKo8uxUFhgQ8/x/K3JUEO TNMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nH+zYjlvWP3Qo5orh796NHnCHvpiRUmXtBzvtTbcFcE=; b=fAGmh9VTkDY8+TArrEDI+HDuqSsfPJBSy7Zq/sLHzA7w3HyElOFyhcj9E5BDRnga2Y L2SndsMzIyxsmnJR8w2tkYFB1WUgxZKB7min3I2fcMEo39CJASkl/ndkc2gUFKev4vO9 qVnatcXZM1in72aqfdJkRFd1zeC5ITvLLiHWlRgPzmT3F8wOKTnEgFYyTUtmceboQS2a //wajqaPk79xXL4hBqSo4M4o61n7w8Uf7cRhss+WGcXUu6TR6f8JYKx1VURskO1SHHBF /3oKfM4uOdlrjeVQdcjiK8LTqJuTpvesNUBojWMIEN1WNYVMC4b+4dffg/OVLhKZ7QMl bKDQ== X-Gm-Message-State: AGi0PubcMtPXsvHIKl78OvUnmF5hm8VXuRaPa4TTL9DMJa0cFF/RLhGd Y5vJZEQASy1dktpWIWHIVuA0LVFrx/4NxJ5byKdmPn2VGyQ= X-Received: by 2002:a05:651c:230:: with SMTP id z16mr1545818ljn.185.1587627277913; Thu, 23 Apr 2020 00:34:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sumit Garg Date: Thu, 23 Apr 2020 13:04:26 +0530 Message-ID: Subject: Re: Commit "mac80211: fix race in ieee80211_register_hw()" breaks mac80211 debugfs To: Hauke Mehrtens Cc: linux-wireless , Felix Fietkau , stable , Johannes Berg Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, 23 Apr 2020 at 02:29, Hauke Mehrtens wrote: > > Hi, > > Since commit 52e04b4ce5d0 ("mac80211: fix race in > ieee80211_register_hw()") the debugfs entries for mac80211 drivers are > broken. > https://git.kernel.org/linus/52e04b4ce5d03775b6a78f3ed1097480faacc9fd > > Felix reported that the file /sys/kernel/debug/ieee80211/phy0/rc is now > located at /sys/kernel/debug/rc. > > Before this commit we had the following flow: > 1. wiphy_register() > -> creates /sys/kernel/debug/ieee80211/phy0/ > -> fill rdev->wiphy.debugfsdir pointer > 2. ieee80211_init_rate_ctrl_alg() > -> call rate_control_alloc() > -> use rdev->wiphy.debugfsdir pointer to > create /sys/kernel/debug/ieee80211/phy0/rc/ > > This works like expected. > > > With the commit the flow in ieee80211_register_hw() is the other way around: > 2. ieee80211_init_rate_ctrl_alg() > -> call rate_control_alloc() > -> use rdev->wiphy.debugfsdir pointer (now NULL) to > create /sys/kernel/debug/rc/ > 2. wiphy_register() > -> creates /sys/kernel/debug/ieee80211/phy0/ > -> fill rdev->wiphy.debugfsdir pointer > Thanks for the detailed report. I missed to notice this hidden debugfs dependency on "wiphy_register()". To address this issue, I think it's reasonable to move creation of wiphy debugfs directory during allocation of wiphy device as per following change (untested though): diff --git a/net/wireless/core.c b/net/wireless/core.c index 341402b..239e9ff 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -473,6 +473,10 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv, } } + /* add to debugfs */ + rdev->wiphy.debugfsdir = debugfs_create_dir(wiphy_name(&rdev->wiphy), + ieee80211_debugfs_dir); + INIT_LIST_HEAD(&rdev->wiphy.wdev_list); INIT_LIST_HEAD(&rdev->beacon_registrations); spin_lock_init(&rdev->beacon_registrations_lock); @@ -903,10 +907,6 @@ int wiphy_register(struct wiphy *wiphy) list_add_rcu(&rdev->list, &cfg80211_rdev_list); cfg80211_rdev_list_generation++; - /* add to debugfs */ - rdev->wiphy.debugfsdir = debugfs_create_dir(wiphy_name(&rdev->wiphy), - ieee80211_debugfs_dir); - cfg80211_debugfs_rdev_add(rdev); nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY); With this change we can remove this hidden debugfs dependency. Please give it a try and let me know if it works for you. -Sumit > > This patch was backported to multiple stable kernel versions: > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.4.y&id=a8ce3412e8a22279e1bdc81c3c2bacd3785c1577 > > Hauke