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]
Message-ID: <20250102180713.p2qwdby75qxr6pol@4VRSMR2-DT.corp.robot.car>
Date: Thu, 2 Jan 2025 10:07:13 -0800
From: Russ Weight <russ.weight@...ux.dev>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: Luis Chamberlain <mcgrof@...nel.org>,
	Danilo Krummrich <dakr@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] firmware_loader: Constify 'struct bin_attribute'

On Sun, Dec 22, 2024 at 09:20:50PM +0100, Thomas Weißschuh wrote:
> The sysfs core now allows instances of 'struct bin_attribute' to be
> moved into read-only memory. Make use of that to protect them against
> accidental or malicious modifications.
> 
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>

Reviewed-by: Russ Weight <russ.weight@...ux.dev>

> ---
>  drivers/base/firmware_loader/sysfs.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
> index c9c93b47d9a519aa2e32e368e4b930dd05d16f0c..d254ceb56d8434e80085dcb4fdef2752582cdab8 100644
> --- a/drivers/base/firmware_loader/sysfs.c
> +++ b/drivers/base/firmware_loader/sysfs.c
> @@ -259,7 +259,7 @@ static void firmware_rw(struct fw_priv *fw_priv, char *buffer,
>  }
>  
>  static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,
> -				  struct bin_attribute *bin_attr,
> +				  const struct bin_attribute *bin_attr,
>  				  char *buffer, loff_t offset, size_t count)
>  {
>  	struct device *dev = kobj_to_dev(kobj);
> @@ -316,7 +316,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
>   *	the driver as a firmware image.
>   **/
>  static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
> -				   struct bin_attribute *bin_attr,
> +				   const struct bin_attribute *bin_attr,
>  				   char *buffer, loff_t offset, size_t count)
>  {
>  	struct device *dev = kobj_to_dev(kobj);
> @@ -356,11 +356,11 @@ static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
>  	return retval;
>  }
>  
> -static struct bin_attribute firmware_attr_data = {
> +static const struct bin_attribute firmware_attr_data = {
>  	.attr = { .name = "data", .mode = 0644 },
>  	.size = 0,
> -	.read = firmware_data_read,
> -	.write = firmware_data_write,
> +	.read_new = firmware_data_read,
> +	.write_new = firmware_data_write,
>  };
>  
>  static struct attribute *fw_dev_attrs[] = {
> @@ -374,14 +374,14 @@ static struct attribute *fw_dev_attrs[] = {
>  	NULL
>  };
>  
> -static struct bin_attribute *fw_dev_bin_attrs[] = {
> +static const struct bin_attribute *const fw_dev_bin_attrs[] = {
>  	&firmware_attr_data,
>  	NULL
>  };
>  
>  static const struct attribute_group fw_dev_attr_group = {
>  	.attrs = fw_dev_attrs,
> -	.bin_attrs = fw_dev_bin_attrs,
> +	.bin_attrs_new = fw_dev_bin_attrs,
>  #ifdef CONFIG_FW_UPLOAD
>  	.is_visible = fw_upload_is_visible,
>  #endif
> 
> ---
> base-commit: bcde95ce32b666478d6737219caa4f8005a8f201
> change-id: 20241222-sysfs-const-bin_attr-firmware-cc0a23036ace
> 
> Best regards,
> -- 
> Thomas Weißschuh <linux@...ssschuh.net>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ