> From: Jason Gunthorpe <jgg@xxxxxxxxxx> > Sent: Friday, February 21, 2025 11:14 PM > > On Fri, Feb 21, 2025 at 04:34:25AM +0000, Parav Pandit wrote: > > > I just tried reproducing now on 6.12+ kernel manually. > > It appears impossible to reach flow to me as intended in the commit I > > listed. > > It looks to me like this: > > static void rdma_init_coredev(struct ib_core_device *coredev, > struct ib_device *dev, struct net *net) { > coredev->dev.groups = dev->groups; > ^^^^^^^^^^^^^^^^^^^^^ > > Copies the sysfs groups from the normal ib_dev which includes the hw_* stuff > to the per-NS device? > I dig deeper. Yes, the source commit was not what Roman listed. The source is commit b7066b32a14fd. > Everything in that groups list must use rdma_device_to_ibdev() > > int ib_setup_device_attrs(struct ib_device *ibdev) { [..] > attr->attr.show = hw_stat_device_show; > attr->show = show_hw_stats; > data->group.attrs[pos] = &attr->attr.attr; [..] > ibdev->groups[i] = &data->group; > > Which means the sysfs reported here is in that list? > > Maybe this was misses when the sysfs was shut off? > The original commit eb15c78b05bd9 and others, never introduced device level counters in the net ns in shared mode. Commit eb15c78b05bd9 by design didn't introduce device global port level and device level counters in non init net ns as it may lead to unwanted side talk via counters and to avoid RW lifespan file. And we should continue that way to not take up more burden to maintain the counters in shared mode for non init net. Roman's crash report validates that device level counters are never used in non init net. So suggest, lets fix it rather than adding the proposed change which opens the doors. ib_setup_device_attrs() should be merged to ib_setup_port_attrs() by renaming ib_setup_port_attrs() to be generic. To utilize the group initialization ib_setup_port_attrs() needs to move up before device_add(). Roman, Will you please modify the fix to avoid hw_stats exposure in non init net using above proposal? Please let me know in case if you need my help to revise the patch. > Jason