Skip to content

Commit 4594a1f

Browse files
t-8chmartinkpetersen
authored andcommitted
scsi: lpfc: 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: Thomas Weißschuh <[email protected]> Link: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-scsi-v1-6-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <[email protected]>
1 parent af58c75 commit 4594a1f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/scsi/lpfc/lpfc_attr.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6185,7 +6185,7 @@ const struct attribute_group *lpfc_vport_groups[] = {
61856185
**/
61866186
static ssize_t
61876187
sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
6188-
struct bin_attribute *bin_attr,
6188+
const struct bin_attribute *bin_attr,
61896189
char *buf, loff_t off, size_t count)
61906190
{
61916191
size_t buf_off;
@@ -6244,7 +6244,7 @@ sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
62446244
**/
62456245
static ssize_t
62466246
sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,
6247-
struct bin_attribute *bin_attr,
6247+
const struct bin_attribute *bin_attr,
62486248
char *buf, loff_t off, size_t count)
62496249
{
62506250
size_t buf_off;
@@ -6280,14 +6280,14 @@ sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,
62806280
return count;
62816281
}
62826282

6283-
static struct bin_attribute sysfs_ctlreg_attr = {
6283+
static const struct bin_attribute sysfs_ctlreg_attr = {
62846284
.attr = {
62856285
.name = "ctlreg",
62866286
.mode = S_IRUSR | S_IWUSR,
62876287
},
62886288
.size = 256,
6289-
.read = sysfs_ctlreg_read,
6290-
.write = sysfs_ctlreg_write,
6289+
.read_new = sysfs_ctlreg_read,
6290+
.write_new = sysfs_ctlreg_write,
62916291
};
62926292

62936293
/**
@@ -6308,7 +6308,7 @@ static struct bin_attribute sysfs_ctlreg_attr = {
63086308
**/
63096309
static ssize_t
63106310
sysfs_mbox_write(struct file *filp, struct kobject *kobj,
6311-
struct bin_attribute *bin_attr,
6311+
const struct bin_attribute *bin_attr,
63126312
char *buf, loff_t off, size_t count)
63136313
{
63146314
return -EPERM;
@@ -6332,20 +6332,20 @@ sysfs_mbox_write(struct file *filp, struct kobject *kobj,
63326332
**/
63336333
static ssize_t
63346334
sysfs_mbox_read(struct file *filp, struct kobject *kobj,
6335-
struct bin_attribute *bin_attr,
6335+
const struct bin_attribute *bin_attr,
63366336
char *buf, loff_t off, size_t count)
63376337
{
63386338
return -EPERM;
63396339
}
63406340

6341-
static struct bin_attribute sysfs_mbox_attr = {
6341+
static const struct bin_attribute sysfs_mbox_attr = {
63426342
.attr = {
63436343
.name = "mbox",
63446344
.mode = S_IRUSR | S_IWUSR,
63456345
},
63466346
.size = MAILBOX_SYSFS_MAX,
6347-
.read = sysfs_mbox_read,
6348-
.write = sysfs_mbox_write,
6347+
.read_new = sysfs_mbox_read,
6348+
.write_new = sysfs_mbox_write,
63496349
};
63506350

63516351
/**

0 commit comments

Comments
 (0)