lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sat, 06 Nov 2021 00:14:34 +0200
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "Rafael J. Wysocki" <rafael@...nel.org>, reinette.chatre@...el.com,
        tony.luck@...el.com, nathaniel@...fian.com,
        linux-kernel@...r.kernel.org, linux-sgx@...r.kernel.org
Subject: Re: [PATCH v11 2/2] x86/sgx: Add an attribute for the amount of SGX
 memory in a NUMA node

On Thu, 2021-11-04 at 08:25 +0100, Greg Kroah-Hartman wrote:
> > static const struct attribute_group *node_dev_groups[] = {
> >         &node_dev_group,
> > #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
> >         &arch_node_dev_group,
> > #endif
> >         NULL,
> > };
> 
> Yes, that is true for the dev pointer passed to your callback, but what
> about the dev pointers in this random array you are looping over?

Right. I got what you are saying.

I think the most legit place to mark an entry in this array would be
just *before* device_register() in register_node(). It's different from
hugetlb_register_node() because hugetlb code adds its attribute group
with sysfs_create_group().

Similarly, the legit place to unmark an entry would be in
unregister_node(), right after device_unregister().

After writing this I realized something: the device ID is the same
as NUMA node ID. This means that I can rewrite my callback as

static ssize_t sgx_total_bytes_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	unsigned long size = 0;
	int nid = dev->id;

	return sysfs_emit(buf, "%lu\n", sgx_numa_nodes[dev->id].size);
}

I.e no need to maintain a device pointer.

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ