]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
scsi: arcmsr: Constify 'struct bin_attribute'
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 16 Dec 2024 11:29:10 +0000 (12:29 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 2 Jan 2025 20:07:45 +0000 (15:07 -0500)
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>
Link: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-scsi-v1-3-f0a5e54b3437@weissschuh.net
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/arcmsr/arcmsr_attr.c

index baeb5e79569026f1af6612705689219bb4a7052f..8e3d4799ce93c35b0befe8744fd20aa3fe467ad3 100644 (file)
@@ -60,7 +60,7 @@
 
 static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
                                             struct kobject *kobj,
-                                            struct bin_attribute *bin,
+                                            const struct bin_attribute *bin,
                                             char *buf, loff_t off,
                                             size_t count)
 {
@@ -107,7 +107,7 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
 
 static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
                                              struct kobject *kobj,
-                                             struct bin_attribute *bin,
+                                             const struct bin_attribute *bin,
                                              char *buf, loff_t off,
                                              size_t count)
 {
@@ -155,7 +155,7 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
 
 static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
                                              struct kobject *kobj,
-                                             struct bin_attribute *bin,
+                                             const struct bin_attribute *bin,
                                              char *buf, loff_t off,
                                              size_t count)
 {
@@ -194,7 +194,7 @@ static const struct bin_attribute arcmsr_sysfs_message_read_attr = {
                .mode = S_IRUSR ,
        },
        .size = ARCMSR_API_DATA_BUFLEN,
-       .read = arcmsr_sysfs_iop_message_read,
+       .read_new = arcmsr_sysfs_iop_message_read,
 };
 
 static const struct bin_attribute arcmsr_sysfs_message_write_attr = {
@@ -203,7 +203,7 @@ static const struct bin_attribute arcmsr_sysfs_message_write_attr = {
                .mode = S_IWUSR,
        },
        .size = ARCMSR_API_DATA_BUFLEN,
-       .write = arcmsr_sysfs_iop_message_write,
+       .write_new = arcmsr_sysfs_iop_message_write,
 };
 
 static const struct bin_attribute arcmsr_sysfs_message_clear_attr = {
@@ -212,7 +212,7 @@ static const struct bin_attribute arcmsr_sysfs_message_clear_attr = {
                .mode = S_IWUSR,
        },
        .size = 1,
-       .write = arcmsr_sysfs_iop_message_clear,
+       .write_new = arcmsr_sysfs_iop_message_clear,
 };
 
 int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb)