diff mbox series

[4/4] PCI/ACPI: Constify 'struct bin_attribute'

Message ID 20241202-sysfs-const-bin_attr-pci-v1-4-c32360f495a7@weissschuh.net
State New
Headers show
Series PCI: Constify 'struct bin_attribute' | expand

Commit Message

Thomas Weißschuh Dec. 2, 2024, 7:03 p.m. UTC
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@weissschuh.net>
---
 drivers/pci/hotplug/acpiphp_ibm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Rafael J. Wysocki Dec. 10, 2024, 6:23 p.m. UTC | #1
On Mon, Dec 2, 2024 at 8:03 PM Thomas Weißschuh <linux@weissschuh.net> 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@weissschuh.net>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/pci/hotplug/acpiphp_ibm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
> index 8f3a0a33f362bc60ba012419b865b8821c075531..b3aa34e3a4a29417bd694273779dc356be284f1d 100644
> --- a/drivers/pci/hotplug/acpiphp_ibm.c
> +++ b/drivers/pci/hotplug/acpiphp_ibm.c
> @@ -84,7 +84,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
>  static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
>  static int ibm_get_table_from_acpi(char **bufp);
>  static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
> -                                  struct bin_attribute *bin_attr,
> +                                  const struct bin_attribute *bin_attr,
>                                    char *buffer, loff_t pos, size_t size);
>  static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
>                 u32 lvl, void *context, void **rv);
> @@ -98,7 +98,7 @@ static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
>                     .name = "apci_table",
>                     .mode = S_IRUGO,
>             },
> -           .read = ibm_read_apci_table,
> +           .read_new = ibm_read_apci_table,
>             .write = NULL,
>  };
>  static struct acpiphp_attention_info ibm_attention_info =
> @@ -353,7 +353,7 @@ static int ibm_get_table_from_acpi(char **bufp)
>   * our solution is to only allow reading the table in all at once.
>   */
>  static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
> -                                  struct bin_attribute *bin_attr,
> +                                  const struct bin_attribute *bin_attr,
>                                    char *buffer, loff_t pos, size_t size)
>  {
>         int bytes_read = -EINVAL;
>
> --
> 2.47.1
>
diff mbox series

Patch

diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 8f3a0a33f362bc60ba012419b865b8821c075531..b3aa34e3a4a29417bd694273779dc356be284f1d 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -84,7 +84,7 @@  static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
 static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
 static int ibm_get_table_from_acpi(char **bufp);
 static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
-				   struct bin_attribute *bin_attr,
+				   const struct bin_attribute *bin_attr,
 				   char *buffer, loff_t pos, size_t size);
 static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
 		u32 lvl, void *context, void **rv);
@@ -98,7 +98,7 @@  static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
 		    .name = "apci_table",
 		    .mode = S_IRUGO,
 	    },
-	    .read = ibm_read_apci_table,
+	    .read_new = ibm_read_apci_table,
 	    .write = NULL,
 };
 static struct acpiphp_attention_info ibm_attention_info =
@@ -353,7 +353,7 @@  static int ibm_get_table_from_acpi(char **bufp)
  * our solution is to only allow reading the table in all at once.
  */
 static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
-				   struct bin_attribute *bin_attr,
+				   const struct bin_attribute *bin_attr,
 				   char *buffer, loff_t pos, size_t size)
 {
 	int bytes_read = -EINVAL;