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: <PSXP216MB04380BBC9B7488DEC47ACB6A80F10@PSXP216MB0438.KORP216.PROD.OUTLOOK.COM>
Date:   Tue, 24 Mar 2020 23:05:07 +0000
From:   Nicholas Johnson <nicholas.johnson-opensource@...look.com.au>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
CC:     "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions

On Tue, Mar 24, 2020 at 05:16:00PM +0000, Srinivas Kandagatla wrote:
> By using is_bin_visible callback to set permissions will remove a large list
> of attribute groups. These group permissions can be dynamically derived in
> the callback.
> 
> Suggested-by: Greg KH <gregkh@...uxfoundation.org>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
> ---
>  drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
>  1 file changed, 18 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
> index 8759c4470012..1ff1801048f6 100644
> --- a/drivers/nvmem/nvmem-sysfs.c
> +++ b/drivers/nvmem/nvmem-sysfs.c
> @@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
>  
>  	return count;
>  }
> +static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> +					 struct bin_attribute *attr, int i)
> +{
> +	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct nvmem_device *nvmem = to_nvmem_device(dev);
> +
> +	if (nvmem->root_only)
> +		return nvmem->read_only ? 0400 : 0600;
> +
> +	return nvmem->read_only ? 0444 : 0644;
> +}
Looks like I did a pretty good job as I arrived at a similar result 
independently. Even added root_only to nvmem_device. You beat me to it. 
:)

>  const struct attribute_group **nvmem_sysfs_get_groups(
>  					struct nvmem_device *nvmem,
>  					const struct nvmem_config *config)
>  {
> -	if (config->root_only)
> -		return nvmem->read_only ?
> -			nvmem_ro_root_dev_groups :
> -			nvmem_rw_root_dev_groups;
> -
> -	return nvmem->read_only ? nvmem_ro_dev_groups : nvmem_rw_dev_groups;
> +	return nvmem_dev_groups;
>  }
I was wondering if we can export nvmem_dev_group instead of this 
nvmem_sysfs_get_groups() to fetch it.

Also, we need some logic in nvmem_register() to abort if bad combination 
is given (i.e. root_only set but no reg_read), as returning 0 in 
is_bin_visible callback does not abort. I can do that in my patch if you 
want.

Regards,
Nicholas
>  
>  /*
> -- 
> 2.21.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ