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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230529121226.4a74a3bb@xps-13>
Date:   Mon, 29 May 2023 12:12:26 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Luka Perkov <luka.perkov@...tura.hr>,
        Robert Marko <robert.marko@...tura.hr>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] nvmem: core: Expose cells through sysfs

Hi Greg,

miquel.raynal@...tlin.com wrote on Tue, 23 May 2023 19:14:02 +0200:

> Hi Greg,
> 
> gregkh@...uxfoundation.org wrote on Tue, 23 May 2023 17:58:51 +0100:
> 
> > On Tue, May 23, 2023 at 12:02:39PM +0200, Miquel Raynal wrote:  
> > > +/* Cell attributes will be dynamically allocated */
> > > +static struct attribute_group nvmem_cells_group = {
> > > +	.name		= "cells",
> > > +};
> > > +
> > >  static const struct attribute_group *nvmem_dev_groups[] = {
> > >  	&nvmem_bin_group,
> > > +	NULL, /* Reserved for exposing cells, if any */    
> > 
> > Please don't do this, but rather use the is_visible callback to
> > determine if it should be shown or not.  
> 
> Ah, excellent point. Don't know why I overlooked that member.

Actually, the .is_visible callback only acts on the files and
not the directories (created based on the group name). This
means whether they are visible or not, the attributes must be
valid, the nvmem core cannot just toggle a boolean value with
.is_visible because the sysfs core makes a number of checks
regarding the content of the attributes, without checking if
they are visible at all.

I can however expose the "cells" bin group by default by having
it listed in the static bin_attribute list and discard it by
overwriting the list member with NULL (ie. the opposite of the current
solution). This implies two things: I need to provide an empty list of
files (otherwise the core warns) and if no list is provided then the
"cells" folder will always appear, no matter if there are cells or not
exposed by this nvmem device. So the folder can be empty.

If this is fine, I can:

* Expose the "cells" bin group, 
* Provide an empty .bin_attrs list (otherwise I get a complain from
  the sysfs core when the nvmem device does not expose any cell)
* Overwrite the dummy .bin_attrs member when the device expose cells,
  keep it empty otherwise.

Otherwise if we prefer avoiding empty folders, I can as well hide the
"cells" bin group by writing NULL to the relevant member of the
attribute_group list.

Let me know what is your preference.

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ