From: Roman Gushchin <roman.gushchin@linux.dev>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Roman Gushchin <roman.gushchin@linux.dev>,
Leon Romanovsky <leon@kernel.org>,
Maher Sanalla <msanalla@nvidia.com>,
Parav Pandit <parav@mellanox.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] net: RDMA: don't expose hw_stats into non-init net namespaces
Date: Wed, 26 Feb 2025 03:35:26 +0000 [thread overview]
Message-ID: <20250226033526.2769817-2-roman.gushchin@linux.dev> (raw)
In-Reply-To: <20250226033526.2769817-1-roman.gushchin@linux.dev>
Commit 467f432a521a ("RDMA/core: Split port and device counter sysfs attributes")
accidentally exposed hw_counters to non-init net namespaces.
Fix this by hiding the IB_ATTR_GROUP_HW_STATS group when initializing
a non-init rdma device.
Fixes: 467f432a521a ("RDMA/core: Split port and device counter sysfs attributes")
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Maher Sanalla <msanalla@nvidia.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: linux-rdma@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/infiniband/core/device.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 8dea307addf1..bf4a016ccb9d 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -528,6 +528,8 @@ static struct class ib_class = {
static void rdma_init_coredev(struct ib_core_device *coredev,
struct ib_device *dev, struct net *net)
{
+ bool is_full_dev = net_eq(net, &init_net);
+
/* This BUILD_BUG_ON is intended to catch layout change
* of union of ib_core_device and device.
* dev must be the first element as ib_core and providers
@@ -539,6 +541,10 @@ static void rdma_init_coredev(struct ib_core_device *coredev,
coredev->dev.class = &ib_class;
coredev->dev.groups = dev->groups;
+
+ if (!is_full_dev)
+ coredev->dev.groups[IB_ATTR_GROUP_HW_STATS] = NULL;
+
device_initialize(&coredev->dev);
coredev->owner = dev;
INIT_LIST_HEAD(&coredev->port_list);
--
2.48.1.658.g4767266eb4-goog
next prev parent reply other threads:[~2025-02-26 3:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 3:35 [PATCH 1/2] net: RDMA: explicitly enumerate ib_device attribute groups Roman Gushchin
2025-02-26 3:35 ` Roman Gushchin [this message]
2025-02-26 3:55 ` [PATCH 2/2] net: RDMA: don't expose hw_stats into non-init net namespaces Parav Pandit
2025-02-26 3:43 ` [PATCH 1/2] net: RDMA: explicitly enumerate ib_device attribute groups Parav Pandit
2025-02-26 14:50 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250226033526.2769817-2-roman.gushchin@linux.dev \
--to=roman.gushchin@linux.dev \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=msanalla@nvidia.com \
--cc=parav@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.