Commit 81ad38a6 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Alexander Gordeev
Browse files

s390/sclp: Constify 'struct bin_attribute'



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: default avatarThomas Weißschuh <linux@weissschuh.net>
Acked-by: default avatarAlexander 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: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent ef37c669
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ static int sclp_ofb_send_req(char *ev_data, size_t len)
}

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

+2 −2
Original line number Diff line number Diff line
@@ -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) {