]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
s390/sclp: Constify 'struct bin_attribute'
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 11 Dec 2024 17:54:42 +0000 (18:54 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 7 Jan 2025 09:05:36 +0000 (10:05 +0100)
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: Alexander Gordeev <agordeev@linux.ibm.com>
Link: https://lore.kernel.org/r/20241211-sysfs-const-bin_attr-s390-v1-4-be01f66bfcf7@weissschuh.net
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/char/sclp_config.c
drivers/s390/char/sclp_sd.c

index f56ea9b60e08e817652a9b7d19d420e9977c6552..ae5d289871779cc5cc1f3070c64746ea702eb41d 100644 (file)
@@ -128,7 +128,7 @@ out:
 }
 
 static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj,
-                                   struct bin_attribute *bin_attr,
+                                   const struct bin_attribute *bin_attr,
                                    char *buf, loff_t off, size_t count)
 {
        int rc;
@@ -142,7 +142,7 @@ static const struct bin_attribute ofb_bin_attr = {
                .name = "event_data",
                .mode = S_IWUSR,
        },
-       .write = sysfs_ofb_data_write,
+       .write_new = sysfs_ofb_data_write,
 };
 #endif
 
index c2dc9aadb7d2c213c93c4fb5e4cdf66d18fc1f78..8524c14affed68587cace9c2e8ac1f02f87052de 100644 (file)
@@ -476,7 +476,7 @@ static struct kobj_type sclp_sd_file_ktype = {
  * on EOF.
  */
 static ssize_t data_read(struct file *file, struct kobject *kobj,
-                        struct bin_attribute *attr, char *buffer,
+                        const struct bin_attribute *attr, char *buffer,
                         loff_t off, size_t size)
 {
        struct sclp_sd_file *sd_file = to_sd_file(kobj);
@@ -539,7 +539,7 @@ static __init struct sclp_sd_file *sclp_sd_file_create(const char *name, u8 di)
        sysfs_bin_attr_init(&sd_file->data_attr);
        sd_file->data_attr.attr.name = "data";
        sd_file->data_attr.attr.mode = 0444;
-       sd_file->data_attr.read = data_read;
+       sd_file->data_attr.read_new = data_read;
 
        rc = sysfs_create_bin_file(&sd_file->kobj, &sd_file->data_attr);
        if (rc) {