From patchwork Mon Jul 22 11:33:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 11052191 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-2.web.codeaurora.org (Postfix) with ESMTP id 91D0A112C for ; Mon, 22 Jul 2019 11:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80AFC2766D for ; Mon, 22 Jul 2019 11:33:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7475027F90; Mon, 22 Jul 2019 11:33:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 260AA2766D for ; Mon, 22 Jul 2019 11:33:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbfGVLdU (ORCPT ); Mon, 22 Jul 2019 07:33:20 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35478 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728823AbfGVLdU (ORCPT ); Mon, 22 Jul 2019 07:33:20 -0400 Received: by mail-lj1-f194.google.com with SMTP id x25so37293154ljh.2 for ; Mon, 22 Jul 2019 04:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4oSm58XeL4FQu1bXAGeTHMv1Ur+zZszwec54kzqlsXg=; b=jG6xRVIBcul9uZ9Rbz1vKDw/a25lNSrU/3iTTJg3hKmnsWHYsOjO4JbjRXSLnaS8Sz 2Y5CLkiFgt1hUAZglFCMQrvtqs9zr1xFYsR8BWV+vymezLszpIjJgarIN5sxaW4qe8gN 08encqy8goJ+rVKLzYPHI0C1UdVnWyeip06JEJrdRqhlISXA3VM5whHsAorqdq6/1Xnq Mn0en1yQlMmF8AowNs/z37IVVe8hIUaaCNKzYfLZozbcAgxtPdfUh4V6hmYUpnioG5xj YLGlWXqIoPDLtP/VWmDSwwykDjRN7yLJ7oTeHZD0Pj7ly56yvhG8RqAY9RZb/enzPu3v YzWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4oSm58XeL4FQu1bXAGeTHMv1Ur+zZszwec54kzqlsXg=; b=aVA8smNaAouhBO+b1G4PT2xtXPrY/NLcrx6hTGwsG5AprwVSlW6DNe3SXxZ1G0kh4w lLv4KkGXXNPe2pg1Z1Vz8PR9ETK69Uu1qtts+/AbmVp0Hg1GGPt1u05sR37tixXoj+IN P2VWTO/o8L3SZoUU0HlRQZjxt8T51JJiwIM+a2+uz1EsROfcvhnuj+yJQ7UGqzcBXLQl jqOy9EHo/Wn/MWuBKglFOt1g+31ocmravt/mNSWcoa1I4FGwRuwU41iL+muLoQGYIgpY rAYNu4JqlEu3kWXLDoH4mbtsATR90OxnYWDY2qMRZ37XpogKKM6HsrkNwmvn8cqBQap3 OKHQ== X-Gm-Message-State: APjAAAWzifAeQEOROC52DSnE8HqaaZZfIYhpaPmIDzLX8RPg5fOobZ53 O9ecV3BmftBITSIBz23XjcE= X-Google-Smtp-Source: APXvYqzLPBJX/FTLUGT7e49NpCClJhXA0nJR3ecPEXN8MV+j7r/7Vb2U2MPcYp6TlTfa+hV5sOTW2Q== X-Received: by 2002:a2e:9dd7:: with SMTP id x23mr37199987ljj.160.1563795198394; Mon, 22 Jul 2019 04:33:18 -0700 (PDT) Received: from localhost.localdomain (109-252-54-73.nat.spd-mgts.ru. [109.252.54.73]) by smtp.gmail.com with ESMTPSA id u18sm5940336lfe.65.2019.07.22.04.33.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jul 2019 04:33:17 -0700 (PDT) From: Denis Kenzior To: johannes@sipsolutions.net, linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [PATCH v4 1/3] nl80211: Update uapi for CMD_FRAME_WAIT_CANCEL Date: Mon, 22 Jul 2019 06:33:10 -0500 Message-Id: <20190722113312.14031-1-denkenz@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 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 Commit 1c38c7f22068 ("nl80211: send event when CMD_FRAME duration expires") added the possibility of NL80211_CMD_FRAME_WAIT_CANCEL being sent whenever the off-channel wait time associated with a CMD_FRAME completes. Document this in the uapi/linux/nl80211.h file. Signed-off-by: Denis Kenzior --- include/uapi/linux/nl80211.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Changes in v4: - None Changes in v3: - None Changes in v2: - update commit formatting diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 8fc3a43cac75..0d9aad98c983 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -657,7 +657,9 @@ * is used during CSA period. * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this * command may be used with the corresponding cookie to cancel the wait - * time if it is known that it is no longer necessary. + * time if it is known that it is no longer necessary. This command is + * also sent as an event whenever the driver has completed the off-channel + * wait time. * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility. * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies From patchwork Mon Jul 22 11:33:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 11052193 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-2.web.codeaurora.org (Postfix) with ESMTP id 382AF112C for ; Mon, 22 Jul 2019 11:33:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2610B2766D for ; Mon, 22 Jul 2019 11:33:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A0AD27F90; Mon, 22 Jul 2019 11:33:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 4E3862766D for ; Mon, 22 Jul 2019 11:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729843AbfGVLdW (ORCPT ); Mon, 22 Jul 2019 07:33:22 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40452 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728843AbfGVLdW (ORCPT ); Mon, 22 Jul 2019 07:33:22 -0400 Received: by mail-lf1-f65.google.com with SMTP id b17so26385265lff.7 for ; Mon, 22 Jul 2019 04:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DKSgdE7NkWvMe5bN8DVq6fNelBXU7jD8Qf+VtFitSRs=; b=U7scbrI5gMNGd1+m0MVKUGDzhS0ydjrfFBDwdbGtRlOkFRqg9Ddsx9tKNZ4FGzyHwa qpt6DM/4AcyIiLWnK1NF2hAd7UZnlX7i3lIzRs9z1CQ8Z/752PGtziGXbXS/K3vyA209 c3FCRfwIOmfmV0yTZ2gM+2RwfSIEY0MlkWPxzIDlwQsQeae2P6PQ7bglteLJygM3FNOX b7BLkx7fqExePqODbF+EgjqPzVl5ehXq8BDXFYG3wu4rBk7i+SGaTG1GcJz7L/la1M7L cbNHwD484kvO6DH1FW//CnRgDwKK9SFURbldGFS8qTfmwqIDjKzVZASW4YpSMlgWLvSs bp7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DKSgdE7NkWvMe5bN8DVq6fNelBXU7jD8Qf+VtFitSRs=; b=caxqXiiqPBRHb962awqSfYKn4iUu/UsJKxR4ADj2WCcZh3Rh/21BxJ/XDi3Mz7FLKv zgGZbJZNo2ZLzGq2QzqtfOcswoFEa69KrfPxXOIh2DGCxxSUb2X/NOZVNFQ1bsU8sjhy EOvGSFWWAIPFyz0r5y1hFw3CoU265vywYuqO45OY/Ed36KJW0MbEYUokn4s2x5Wx4fT9 f95jQWU6P77IsWxcmZ/wwUkDcSgDFTmK1Kq0+DcFcNS701HNaOKHUJpLRZbLTi+D9HX7 6amHz7Df0ZNxM76XKi5bootzvQzkcC761saEeRo/NvnmMK4nBQNjLmJrNX6C8I10LsVJ 2/7w== X-Gm-Message-State: APjAAAXJifDt9rcMlSMNSw3Fzv2g+0U33W6sM0VBDEvJvLvfaeM7jYQJ WUogaipw1xqD6z1n72fk4tIhBhtA X-Google-Smtp-Source: APXvYqwqHQPAYrrUAVyjrWAQkgagDy0kbaA3I9Oy4SqDGzBKuRdtwC43QGyYV4B7ZumENZIWQaZYkw== X-Received: by 2002:ac2:596c:: with SMTP id h12mr32298130lfp.101.1563795199668; Mon, 22 Jul 2019 04:33:19 -0700 (PDT) Received: from localhost.localdomain (109-252-54-73.nat.spd-mgts.ru. [109.252.54.73]) by smtp.gmail.com with ESMTPSA id u18sm5940336lfe.65.2019.07.22.04.33.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jul 2019 04:33:19 -0700 (PDT) From: Denis Kenzior To: johannes@sipsolutions.net, linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [PATCH v4 2/3] nl80211: Limit certain commands to interface owner Date: Mon, 22 Jul 2019 06:33:11 -0500 Message-Id: <20190722113312.14031-2-denkenz@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722113312.14031-1-denkenz@gmail.com> References: <20190722113312.14031-1-denkenz@gmail.com> MIME-Version: 1.0 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 If the wdev object has been created (via NEW_INTERFACE) with SOCKET_OWNER attribute set, then limit certain commands only to the process that created that wdev. This can be used to make sure no other process on the system interferes by sending unwanted scans, action frames or any other funny business. This patch introduces a new internal flag, and checks that flag in the pre_doit hook. Signed-off-by: Denis Kenzior --- net/wireless/nl80211.c | 78 ++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 18 deletions(-) Changes in v4: - Minor restructuring suggested by Arend Changes in v3: - Fix minor locking mistake reported by kernel test robot Changes in v2: - None diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index fc83dd179c1a..a075d86a52f6 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -13602,6 +13602,7 @@ static int nl80211_probe_mesh_link(struct sk_buff *skb, struct genl_info *info) #define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ NL80211_FLAG_CHECK_NETDEV_UP) #define NL80211_FLAG_CLEAR_SKB 0x20 +#define NL80211_FLAG_OWNER_ONLY 0x40 static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, struct genl_info *info) @@ -13610,6 +13611,7 @@ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, struct wireless_dev *wdev; struct net_device *dev; bool rtnl = ops->internal_flags & NL80211_FLAG_NEED_RTNL; + int ret; if (rtnl) rtnl_lock(); @@ -13617,10 +13619,10 @@ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, if (ops->internal_flags & NL80211_FLAG_NEED_WIPHY) { rdev = cfg80211_get_dev_from_info(genl_info_net(info), info); if (IS_ERR(rdev)) { - if (rtnl) - rtnl_unlock(); - return PTR_ERR(rdev); + ret = PTR_ERR(rdev); + goto fail; } + info->user_ptr[0] = rdev; } else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV || ops->internal_flags & NL80211_FLAG_NEED_WDEV) { @@ -13629,32 +13631,33 @@ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, wdev = __cfg80211_wdev_from_attrs(genl_info_net(info), info->attrs); if (IS_ERR(wdev)) { - if (rtnl) - rtnl_unlock(); - return PTR_ERR(wdev); + ret = PTR_ERR(wdev); + goto fail; } dev = wdev->netdev; rdev = wiphy_to_rdev(wdev->wiphy); + ret = -EINVAL; if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) { - if (!dev) { - if (rtnl) - rtnl_unlock(); - return -EINVAL; - } + if (!dev) + goto fail; info->user_ptr[1] = dev; } else { info->user_ptr[1] = wdev; } + ret = -ENETDOWN; if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP && - !wdev_running(wdev)) { - if (rtnl) - rtnl_unlock(); - return -ENETDOWN; - } + !wdev_running(wdev)) + goto fail; + + ret = -EPERM; + if (ops->internal_flags & NL80211_FLAG_OWNER_ONLY && + wdev->owner_nlportid && + wdev->owner_nlportid != info->snd_portid) + goto fail; if (dev) dev_hold(dev); @@ -13663,6 +13666,12 @@ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, } return 0; + +fail: + if (rtnl) + rtnl_unlock(); + + return ret; } static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, @@ -13727,7 +13736,8 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_set_interface, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV | - NL80211_FLAG_NEED_RTNL, + NL80211_FLAG_NEED_RTNL | + NL80211_FLAG_OWNER_ONLY, }, { .cmd = NL80211_CMD_NEW_INTERFACE, @@ -13743,7 +13753,8 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_del_interface, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV | - NL80211_FLAG_NEED_RTNL, + NL80211_FLAG_NEED_RTNL | + NL80211_FLAG_OWNER_ONLY, }, { .cmd = NL80211_CMD_GET_KEY, @@ -13760,6 +13771,7 @@ static const struct genl_ops nl80211_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | NL80211_FLAG_NEED_RTNL | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_CLEAR_SKB, }, { @@ -13769,6 +13781,7 @@ static const struct genl_ops nl80211_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | NL80211_FLAG_NEED_RTNL | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_CLEAR_SKB, }, { @@ -13777,6 +13790,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_del_key, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13793,6 +13807,7 @@ static const struct genl_ops nl80211_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .doit = nl80211_start_ap, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13801,6 +13816,7 @@ static const struct genl_ops nl80211_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .doit = nl80211_stop_ap, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13817,6 +13833,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_set_station, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13825,6 +13842,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_new_station, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13833,6 +13851,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_del_station, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13936,6 +13955,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_trigger_scan, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13944,6 +13964,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_abort_scan, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13957,6 +13978,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_start_sched_scan, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13965,6 +13987,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_stop_sched_scan, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13973,6 +13996,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_authenticate, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL | NL80211_FLAG_CLEAR_SKB, }, @@ -13982,6 +14006,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_associate, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL | NL80211_FLAG_CLEAR_SKB, }, @@ -13991,6 +14016,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_deauthenticate, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -13999,6 +14025,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_disassociate, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14007,6 +14034,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_join_ibss, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14015,6 +14043,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_leave_ibss, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, #ifdef CONFIG_NL80211_TESTMODE @@ -14034,6 +14063,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_connect, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL | NL80211_FLAG_CLEAR_SKB, }, @@ -14043,6 +14073,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_update_connect_params, .flags = GENL_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL | NL80211_FLAG_CLEAR_SKB, }, @@ -14052,6 +14083,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_disconnect, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14098,6 +14130,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_remain_on_channel, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14106,6 +14139,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_cancel_remain_on_channel, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14130,6 +14164,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_tx_mgmt, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14138,6 +14173,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_tx_mgmt_cancel_wait, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14162,6 +14198,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_set_cqm, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14236,6 +14273,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_set_rekey_data, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL | NL80211_FLAG_CLEAR_SKB, }, @@ -14293,6 +14331,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_start_p2p_device, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14301,6 +14340,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_stop_p2p_device, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14386,6 +14426,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_crit_protocol_start, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { @@ -14394,6 +14435,7 @@ static const struct genl_ops nl80211_ops[] = { .doit = nl80211_crit_protocol_stop, .flags = GENL_UNS_ADMIN_PERM, .internal_flags = NL80211_FLAG_NEED_WDEV_UP | + NL80211_FLAG_OWNER_ONLY | NL80211_FLAG_NEED_RTNL, }, { From patchwork Mon Jul 22 11:33:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 11052195 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-2.web.codeaurora.org (Postfix) with ESMTP id A58C213B1 for ; Mon, 22 Jul 2019 11:33:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9568D2766D for ; Mon, 22 Jul 2019 11:33:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89FC127F90; Mon, 22 Jul 2019 11:33:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 3C1AB2766D for ; Mon, 22 Jul 2019 11:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729859AbfGVLdX (ORCPT ); Mon, 22 Jul 2019 07:33:23 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46383 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728823AbfGVLdW (ORCPT ); Mon, 22 Jul 2019 07:33:22 -0400 Received: by mail-lj1-f196.google.com with SMTP id v24so37301657ljg.13 for ; Mon, 22 Jul 2019 04:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N1UMEskMWgDwWIPBIZqRQp7UCGQ+/1yqMEhKr6tJRDg=; b=mE9W9C2H7td8C2H+77Nv03z9hAIlOip1PrjPuhJcAlHrKeMr8hrV/PlNI8/uWSzwa9 BwrXTTlXKR90M6OOMmdbpeq+6XiJLT3f449VT6a+8MlssSJ5zGmKfJGk2MzYbWcFPxdv Fl8WfriDQSEl7yzw2AXFrE86SSk2k+7CNVCX6gHsYc/awoooKCGtnZahMX2K0Me9eBMp 0u85C15WIFsWFZEgtYaIwTS6bYtXVkcW++eI1YBPDXL3Q7/ldOZKblZiSTK7vnnEZnCL vPoAQUJI1sOt821ZP0Qrrh+QUANMnaTaTfRzZcml17b4BOkPhsr9PDdSiiVHwatm2VHh xwig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N1UMEskMWgDwWIPBIZqRQp7UCGQ+/1yqMEhKr6tJRDg=; b=UGTO8TE2olYuWWxtThbH9UpNl1PffteYhuZDCMFe6jjSXg4cHHfaxwk/4I9Kviya1x GrfOgm1807uYpJz5K49qWeSRChZebJiiQm/QOgJMGhminVYZ4yALeOByqml5L/Q4k1zF bYrRre4739kaT/uF+3i1smS92kNsRp8anSUkTX6radyEIIsddre3SGSRwYoFY7ep9h3c dyE3FVyeKruttgoA6C2XV76lbSd6vNxpQgYNi8IWtJ9v4ViLOtASymyEFCP+1RJD+9TS aJAaBgFuxYfVcTVjJhgi1LCxJbjtYCSaoijb2v9SgioswZ1+n162Z1+C4nobLJZI60R4 G9Mw== X-Gm-Message-State: APjAAAXRntDfnVbRLcw/PfEFLLi9iQZphL9kbIY4Xn2iNvLOfoHP1Psf 4kPteJED5z7oSrhfsoS1q08= X-Google-Smtp-Source: APXvYqzi7UmCSfCefMkMGvLeR3TXEWK3O+Hgw49SSbfEXwWheveF2ZuhyKUxXq1FETKk9cHF+DgGyg== X-Received: by 2002:a2e:8602:: with SMTP id a2mr34340627lji.206.1563795200855; Mon, 22 Jul 2019 04:33:20 -0700 (PDT) Received: from localhost.localdomain (109-252-54-73.nat.spd-mgts.ru. [109.252.54.73]) by smtp.gmail.com with ESMTPSA id u18sm5940336lfe.65.2019.07.22.04.33.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jul 2019 04:33:19 -0700 (PDT) From: Denis Kenzior To: johannes@sipsolutions.net, linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [PATCH v4 3/3] nl80211: Include wiphy address setup in NEW_WIPHY Date: Mon, 22 Jul 2019 06:33:12 -0500 Message-Id: <20190722113312.14031-3-denkenz@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722113312.14031-1-denkenz@gmail.com> References: <20190722113312.14031-1-denkenz@gmail.com> MIME-Version: 1.0 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 Include wiphy address setup in wiphy dumps and new wiphy events. The wiphy permanent address is exposed as ATTR_MAC. If addr_mask is setup, then it is included as ATTR_MAC_MASK attribute. If multiple addresses are available, then their are exposed in a nested ATTR_MAC_ADDRS array. This information is already exposed via sysfs, but it makes sense to include it in the wiphy dump as well. Signed-off-by: Denis Kenzior --- net/wireless/nl80211.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) Changes in v4: - None Changes in v3: - None Changes in v2: - Move from case 0 to 9 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a075d86a52f6..3fc4a9006155 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2172,6 +2172,31 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, rdev->wiphy.vht_capa_mod_mask)) goto nla_put_failure; + if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, + rdev->wiphy.perm_addr)) + goto nla_put_failure; + + if (!is_zero_ether_addr(rdev->wiphy.addr_mask) && + nla_put(msg, NL80211_ATTR_MAC_MASK, ETH_ALEN, + rdev->wiphy.addr_mask)) + goto nla_put_failure; + + if (rdev->wiphy.n_addresses > 1) { + void *attr; + + attr = nla_nest_start_noflag(msg, + NL80211_ATTR_MAC_ADDRS); + if (!attr) + goto nla_put_failure; + + for (i = 0; i < rdev->wiphy.n_addresses; i++) + if (nla_put(msg, i + 1, ETH_ALEN, + rdev->wiphy.addresses[i].addr)) + goto nla_put_failure; + + nla_nest_end(msg, attr); + } + state->split_start++; break; case 10: