scsi: Constify 'struct bin_attribute'
Subsystems (11)
cover scsi: 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.
---
Thomas Weißschuh (11):
scsi: core: Constify 'struct bin_attribute'
scsi: 3w-sas: Constify 'struct bin_attribute'
scsi: arcmsr: Constify 'struct bin_attribute'
scsi: esas2r: Constify 'struct bin_attribute'
scsi: ibmvfc: Constify 'struct bin_attribute'
scsi: lpfc: Constify 'struct bin_attribute'
scsi: ipr: Constify 'struct bin_attribute'
scsi: qedf: Constify 'struct bin_attribute'
scsi: qedi: Constify 'struct bin_attribute'
scsi: qla2xxx: Constify 'struct bin_attribute'
scsi: qla4xxx: Constify 'struct bin_attribute'
drivers/scsi/3w-sas.c | 12 +++--- drivers/scsi/arcmsr/arcmsr_attr.c | 12 +++--- drivers/scsi/esas2r/esas2r.h | 12 +++--- drivers/scsi/esas2r/esas2r_main.c | 32 ++++++++-------- drivers/scsi/ibmvscsi/ibmvfc.c | 6 +-- drivers/scsi/ipr.c | 26 ++++++------- drivers/scsi/lpfc/lpfc_attr.c | 20 +++++----- drivers/scsi/qedf/qedf_attr.c | 10 ++--- drivers/scsi/qedf/qedf_dbg.h | 2 +- drivers/scsi/qedi/qedi_dbg.h | 2 +- drivers/scsi/qla2xxx/qla_attr.c | 80 +++++++++++++++++++-------------------- drivers/scsi/qla4xxx/ql4_attr.c | 12 +++--- drivers/scsi/scsi_sysfs.c | 16 ++++---- 13 files changed, 121 insertions(+), 121 deletions(-)
---
base-commit: 2d8308bf5b67dff50262d8a9260a50113b3628c6
change-id: 20241215-sysfs-const-bin_attr-scsi-bf43eb2f7f9e
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH 1/11 scsi: core: 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.
--- drivers/scsi/scsi_sysfs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/scsi/scsi_sysfs.c +8 -8
@@ -898,7 +898,7 @@ static DEVICE_ATTR(queue_type, S_IRUGO | S_IWUSR, show_queue_type_field,#define sdev_vpd_pg_attr (_page) \ static ssize_t \ show_vpd_##_page(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) \ { \ struct device *dev = kobj_to_dev(kobj); \
@@ -914,10 +914,10 @@ show_vpd_##_page(struct file *filp, struct kobject *kobj, \rcu_read_unlock (); \return ret; \ } \ -static struct bin_attribute dev_attr_vpd_##_page = { \ +static const struct bin_attribute dev_attr_vpd_##_page = { \ .attr = {.name = __stringify(vpd_##_page), .mode = S_IRUGO }, \ .size =0 , \ - .read = show_vpd_##_page, \ + .read_new = show_vpd_##_page, \ };sdev_vpd_pg_attr (pg83);
@@ -930,7 +930,7 @@ sdev_vpd_pg_attr(pgb7);sdev_vpd_pg_attr (pg0);static ssize_t show_inquiry (struct file *filep,struct kobject *kobj, -struct bin_attribute *bin_attr, +const struct bin_attribute *bin_attr,char *buf,loff_t off,size_t count) {struct device *dev =kobj_to_dev (kobj);
@@ -943,13 +943,13 @@ static ssize_t show_inquiry(struct file *filep, struct kobject *kobj, sdev->inquiry_len); } -static struct bin_attribute dev_attr_inquiry = { +static const struct bin_attribute dev_attr_inquiry = { .attr = { .name ="inquiry" , .mode =S_IRUGO , }, .size =0 , - .read = show_inquiry, + .read_new = show_inquiry, }; static ssize_t
@@ -1348,7 +1348,7 @@ static struct attribute *scsi_sdev_attrs[] = {NULL }; -static struct bin_attribute *scsi_sdev_bin_attrs[] = { +static const struct bin_attribute *const scsi_sdev_bin_attrs[] = { &dev_attr_vpd_pg0, &dev_attr_vpd_pg83, &dev_attr_vpd_pg80,
@@ -1362,7 +1362,7 @@ static struct bin_attribute *scsi_sdev_bin_attrs[] = { };static struct attribute_group scsi_sdev_attr_group = { .attrs = scsi_sdev_attrs, - .bin_attrs = scsi_sdev_bin_attrs, + .bin_attrs_new = scsi_sdev_bin_attrs, .is_visible = scsi_sdev_attr_is_visible, .is_bin_visible = scsi_sdev_bin_attr_is_visible, };
Signature · 1 line
2.47.1
PATCH 2/11 scsi: 3w-sas: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/3w-sas.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/3w-sas.c +6 -6
@@ -96,7 +96,7 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res/* This function returns AENs through sysfs */ static ssize_t twl_sysfs_aen_read (struct file *filp,struct kobject *kobj, -struct bin_attribute *bin_attr, +const struct bin_attribute *bin_attr,char *outbuf,loff_t offset,size_t count) { struct device *dev = container_of(kobj, struct device, kobj);
@@ -116,18 +116,18 @@ static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj, }/* End twl_sysfs_aen_read() */ /* aen_read sysfs attribute initializer */ -static struct bin_attribute twl_sysfs_aen_read_attr = { +static const struct bin_attribute twl_sysfs_aen_read_attr = { .attr = { .name ="3ware_aen_read" , .mode =S_IRUSR , }, .size =0 , - .read = twl_sysfs_aen_read + .read_new = twl_sysfs_aen_read };/* This function returns driver compatibility info through sysfs */ static ssize_t twl_sysfs_compat_info (struct file *filp,struct kobject *kobj, -struct bin_attribute *bin_attr, +const struct bin_attribute *bin_attr,char *outbuf,loff_t offset,size_t count) { struct device *dev = container_of(kobj, struct device, kobj);
@@ -147,13 +147,13 @@ static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj, }/* End twl_sysfs_compat_info() */ /* compat_info sysfs attribute initializer */ -static struct bin_attribute twl_sysfs_compat_info_attr = { +static const struct bin_attribute twl_sysfs_compat_info_attr = { .attr = { .name ="3ware_compat_info" , .mode =S_IRUSR , }, .size =0 , - .read = twl_sysfs_compat_info + .read_new = twl_sysfs_compat_info };/* Show some statistics about the card */
Signature · 1 line
2.47.1
PATCH 3/11 scsi: arcmsr: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/arcmsr/arcmsr_attr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/arcmsr/arcmsr_attr.c +6 -6
@@ -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)
Signature · 1 line
2.47.1
PATCH 4/11 scsi: esas2r: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/esas2r/esas2r.h | 12 ++++++------ drivers/scsi/esas2r/esas2r_main.c | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-)
drivers/scsi/esas2r/esas2r.h +6 -6
@@ -1411,11 +1411,11 @@ static inline void esas2r_comp_list_drain(struct esas2r_adapter *a, }/* sysfs handlers */ -extern struct bin_attribute bin_attr_fw; -extern struct bin_attribute bin_attr_fs; -extern struct bin_attribute bin_attr_vda; -extern struct bin_attribute bin_attr_hw; -extern struct bin_attribute bin_attr_live_nvram; -extern struct bin_attribute bin_attr_default_nvram; +extern const struct bin_attribute bin_attr_fw; +extern const struct bin_attribute bin_attr_fs; +extern const struct bin_attribute bin_attr_vda; +extern const struct bin_attribute bin_attr_hw; +extern const struct bin_attribute bin_attr_live_nvram; +extern const struct bin_attribute bin_attr_default_nvram;#endif /* ESAS2R_H */
drivers/scsi/esas2r/esas2r_main.c +16 -16
@@ -66,7 +66,7 @@ static struct esas2r_adapter *esas2r_adapter_from_kobj(struct kobject *kobj) }static ssize_t read_fw (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -75,7 +75,7 @@ static ssize_t read_fw(struct file *file, struct kobject *kobj, }static ssize_t write_fw (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -84,7 +84,7 @@ static ssize_t write_fw(struct file *file, struct kobject *kobj, }static ssize_t read_fs (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -93,7 +93,7 @@ static ssize_t read_fs(struct file *file, struct kobject *kobj, }static ssize_t write_fs (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -109,7 +109,7 @@ static ssize_t write_fs(struct file *file, struct kobject *kobj, }static ssize_t read_vda (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -118,7 +118,7 @@ static ssize_t read_vda(struct file *file, struct kobject *kobj, }static ssize_t write_vda (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -127,7 +127,7 @@ static ssize_t write_vda(struct file *file, struct kobject *kobj, }static ssize_t read_live_nvram (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -138,7 +138,7 @@ static ssize_t read_live_nvram(struct file *file, struct kobject *kobj, }static ssize_t write_live_nvram (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -158,7 +158,7 @@ static ssize_t write_live_nvram(struct file *file, struct kobject *kobj, }static ssize_t read_default_nvram (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -169,7 +169,7 @@ static ssize_t read_default_nvram(struct file *file, struct kobject *kobj, }static ssize_t read_hw (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -187,7 +187,7 @@ static ssize_t read_hw(struct file *file, struct kobject *kobj, }static ssize_t write_hw (struct file *file,struct kobject *kobj, -struct bin_attribute *attr, +const struct bin_attribute *attr,char *buf,loff_t off,size_t count) {struct esas2r_adapter *a =esas2r_adapter_from_kobj (kobj);
@@ -211,12 +211,12 @@ static ssize_t write_hw(struct file *file, struct kobject *kobj, }#define ESAS2R_RW_BIN_ATTR (_name) \ - struct bin_attribute bin_attr_ ## _name = { \ + const struct bin_attribute bin_attr_ ## _name = { \ .attr = \ { .name = __stringify(_name), .mode = S_IRUSR | S_IWUSR }, \ .size = 0, \ - .read = read_ ## _name, \ - .write = write_ ## _name } + .read_new = read_ ## _name, \ + .write_new = write_ ## _name }ESAS2R_RW_BIN_ATTR (fw);ESAS2R_RW_BIN_ATTR (fs);
@@ -224,10 +224,10 @@ ESAS2R_RW_BIN_ATTR(vda);ESAS2R_RW_BIN_ATTR (hw);ESAS2R_RW_BIN_ATTR (live_nvram); -struct bin_attribute bin_attr_default_nvram = { +const struct bin_attribute bin_attr_default_nvram = { .attr = { .name ="default_nvram" , .mode =S_IRUGO }, .size =0 , - .read = read_default_nvram, + .read_new = read_default_nvram, .write =NULL };
Signature · 1 line
2.47.1
PATCH 5/11 scsi: ibmvfc: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/ibmvscsi/ibmvfc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ibmvscsi/ibmvfc.c +3 -3
@@ -3639,7 +3639,7 @@ static DEVICE_ATTR(nr_scsi_channels, S_IRUGO | S_IWUSR,* number of bytes printed to buffer **/ static ssize_t ibmvfc_read_trace (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) {struct device *dev =kobj_to_dev (kobj);
@@ -3662,13 +3662,13 @@ static ssize_t ibmvfc_read_trace(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute ibmvfc_trace_attr = { +static const struct bin_attribute ibmvfc_trace_attr = { .attr = { .name ="trace" , .mode =S_IRUGO , }, .size =0 , - .read = ibmvfc_read_trace, + .read_new = ibmvfc_read_trace, };#endif
Signature · 1 line
2.47.1
PATCH 6/11 scsi: lpfc: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/lpfc/lpfc_attr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc_attr.c +10 -10
@@ -6185,7 +6185,7 @@ const struct attribute_group *lpfc_vport_groups[] = {**/ static ssize_t sysfs_ctlreg_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) {size_t buf_off;
@@ -6244,7 +6244,7 @@ sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,**/ static ssize_t sysfs_ctlreg_read (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) {size_t buf_off;
@@ -6280,14 +6280,14 @@ sysfs_ctlreg_read(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_ctlreg_attr = { +static const struct bin_attribute sysfs_ctlreg_attr = { .attr = { .name ="ctlreg" , .mode =S_IRUSR |S_IWUSR , }, .size =256 , - .read = sysfs_ctlreg_read, - .write = sysfs_ctlreg_write, + .read_new = sysfs_ctlreg_read, + .write_new = sysfs_ctlreg_write, };/**
@@ -6308,7 +6308,7 @@ static struct bin_attribute sysfs_ctlreg_attr = {**/ static ssize_t sysfs_mbox_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) {return -EPERM ;
@@ -6332,20 +6332,20 @@ sysfs_mbox_write(struct file *filp, struct kobject *kobj,**/ static ssize_t sysfs_mbox_read (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) {return -EPERM ; } -static struct bin_attribute sysfs_mbox_attr = { +static const struct bin_attribute sysfs_mbox_attr = { .attr = { .name ="mbox" , .mode =S_IRUSR |S_IWUSR , }, .size =MAILBOX_SYSFS_MAX , - .read = sysfs_mbox_read, - .write = sysfs_mbox_write, + .read_new = sysfs_mbox_read, + .write_new = sysfs_mbox_write, };/**
Signature · 1 line
2.47.1
PATCH 7/11 scsi: ipr: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/ipr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/scsi/ipr.c +13 -13
@@ -3366,7 +3366,7 @@ static void ipr_worker_thread(struct work_struct *work)* number of bytes printed to buffer **/ static ssize_t ipr_read_trace (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) {struct device *dev =kobj_to_dev (kobj);
@@ -3383,13 +3383,13 @@ static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj, return ret; } -static struct bin_attribute ipr_trace_attr = { +static const struct bin_attribute ipr_trace_attr = { .attr = { .name ="trace" , .mode =S_IRUGO , }, .size =0 , - .read = ipr_read_trace, + .read_new = ipr_read_trace, };#endif
@@ -4087,7 +4087,7 @@ static struct device_attribute ipr_ioa_fw_type_attr = { };static ssize_t ipr_read_async_err_log (struct file *filep,struct kobject *kobj, -struct bin_attribute *bin_attr,char *buf, +const struct bin_attribute *bin_attr,char *buf,loff_t off,size_t count) {struct device *cdev =kobj_to_dev (kobj);
@@ -4111,7 +4111,7 @@ static ssize_t ipr_read_async_err_log(struct file *filep, struct kobject *kobj, }static ssize_t ipr_next_async_err_log (struct file *filep,struct kobject *kobj, -struct bin_attribute *bin_attr,char *buf, +const struct bin_attribute *bin_attr,char *buf,loff_t off,size_t count) {struct device *cdev =kobj_to_dev (kobj);
@@ -4134,14 +4134,14 @@ static ssize_t ipr_next_async_err_log(struct file *filep, struct kobject *kobj,return count; } -static struct bin_attribute ipr_ioa_async_err_log = { +static const struct bin_attribute ipr_ioa_async_err_log = { .attr = { .name ="async_err_log" , .mode =S_IRUGO |S_IWUSR , }, .size =0 , - .read = ipr_read_async_err_log, - .write = ipr_next_async_err_log + .read_new = ipr_read_async_err_log, + .write_new = ipr_next_async_err_log };static struct attribute *ipr_ioa_attrs[] = {
@@ -4172,7 +4172,7 @@ ATTRIBUTE_GROUPS(ipr_ioa);* number of bytes printed to buffer **/ static ssize_t ipr_read_dump (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) {struct device *cdev =kobj_to_dev (kobj);
@@ -4361,7 +4361,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg)* number of bytes printed to buffer **/ static ssize_t ipr_write_dump (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) {struct device *cdev =kobj_to_dev (kobj);
@@ -4385,14 +4385,14 @@ static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute ipr_dump_attr = { +static const struct bin_attribute ipr_dump_attr = { .attr = { .name ="dump" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = ipr_read_dump, - .write = ipr_write_dump + .read_new = ipr_read_dump, + .write_new = ipr_write_dump };#else static int ipr_free_dump (struct ipr_ioa_cfg *ioa_cfg) {return 0 ; };
Signature · 1 line
2.47.1
PATCH 8/11 scsi: qedf: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/qedf/qedf_attr.c | 10 +++++----- drivers/scsi/qedf/qedf_dbg.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/qedf/qedf_attr.c +5 -5
@@ -104,7 +104,7 @@ void qedf_capture_grc_dump(struct qedf_ctx *qedf)static ssize_t qedf_sysfs_read_grcdump (struct file *filep,struct kobject *kobj, -struct bin_attribute *ba,char *buf,loff_t off, +const struct bin_attribute *ba,char *buf,loff_t off,size_t count) {ssize_t ret =0 ;
@@ -124,7 +124,7 @@ qedf_sysfs_read_grcdump(struct file *filep, struct kobject *kobj,static ssize_t qedf_sysfs_write_grcdump (struct file *filep,struct kobject *kobj, -struct bin_attribute *ba,char *buf,loff_t off, +const struct bin_attribute *ba,char *buf,loff_t off,size_t count) {struct fc_lport *lport =NULL ;
@@ -160,14 +160,14 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_grcdump_attr = { +static const struct bin_attribute sysfs_grcdump_attr = { .attr = { .name ="grcdump" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = qedf_sysfs_read_grcdump, - .write = qedf_sysfs_write_grcdump, + .read_new = qedf_sysfs_read_grcdump, + .write_new = qedf_sysfs_write_grcdump, };static struct sysfs_bin_attrs bin_file_entries[] = {
drivers/scsi/qedf/qedf_dbg.h +1 -1
@@ -100,7 +100,7 @@ struct Scsi_Host;struct sysfs_bin_attrs {char *name; -struct bin_attribute *attr; +const struct bin_attribute *attr; };extern int qedf_alloc_grc_dump_buf (uint8_t **buf,uint32_t len);
Signature · 1 line
2.47.1
PATCH 9/11 scsi: qedi: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/qedi/qedi_dbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedi/qedi_dbg.h +1 -1
@@ -91,7 +91,7 @@ struct Scsi_Host;struct sysfs_bin_attrs {char *name; -struct bin_attribute *attr; +const struct bin_attribute *attr; }; int qedi_create_sysfs_attr(struct Scsi_Host *shost,
Signature · 1 line
2.47.1
PATCH 10/11 scsi: qla2xxx: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/qla2xxx/qla_attr.c | 80 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 40 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +40 -40
@@ -17,7 +17,7 @@ static int qla24xx_vport_disable(struct fc_vport *, bool);static ssize_t qla2x00_sysfs_read_fw_dump (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -58,7 +58,7 @@ qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj,static ssize_t qla2x00_sysfs_write_fw_dump (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -168,19 +168,19 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_fw_dump_attr = { +static const struct bin_attribute sysfs_fw_dump_attr = { .attr = { .name ="fw_dump" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = qla2x00_sysfs_read_fw_dump, - .write = qla2x00_sysfs_write_fw_dump, + .read_new = qla2x00_sysfs_read_fw_dump, + .write_new = qla2x00_sysfs_write_fw_dump, };static ssize_t qla2x00_sysfs_read_nvram (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -220,7 +220,7 @@ qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj,static ssize_t qla2x00_sysfs_write_nvram (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -282,19 +282,19 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_nvram_attr = { +static const struct bin_attribute sysfs_nvram_attr = { .attr = { .name ="nvram" , .mode =S_IRUSR |S_IWUSR , }, .size =512 , - .read = qla2x00_sysfs_read_nvram, - .write = qla2x00_sysfs_write_nvram, + .read_new = qla2x00_sysfs_read_nvram, + .write_new = qla2x00_sysfs_write_nvram, };static ssize_t qla2x00_sysfs_read_optrom (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -318,7 +318,7 @@ qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj,static ssize_t qla2x00_sysfs_write_optrom (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -344,19 +344,19 @@ qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_optrom_attr = { +static const struct bin_attribute sysfs_optrom_attr = { .attr = { .name ="optrom" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = qla2x00_sysfs_read_optrom, - .write = qla2x00_sysfs_write_optrom, + .read_new = qla2x00_sysfs_read_optrom, + .write_new = qla2x00_sysfs_write_optrom, };static ssize_t qla2x00_sysfs_write_optrom_ctl (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -529,18 +529,18 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,return rval; } -static struct bin_attribute sysfs_optrom_ctl_attr = { +static const struct bin_attribute sysfs_optrom_ctl_attr = { .attr = { .name ="optrom_ctl" , .mode =S_IWUSR , }, .size =0 , - .write = qla2x00_sysfs_write_optrom_ctl, + .write_new = qla2x00_sysfs_write_optrom_ctl, };static ssize_t qla2x00_sysfs_read_vpd (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -587,7 +587,7 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,static ssize_t qla2x00_sysfs_write_vpd (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -642,19 +642,19 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_vpd_attr = { +static const struct bin_attribute sysfs_vpd_attr = { .attr = { .name ="vpd" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = qla2x00_sysfs_read_vpd, - .write = qla2x00_sysfs_write_vpd, + .read_new = qla2x00_sysfs_read_vpd, + .write_new = qla2x00_sysfs_write_vpd, };static ssize_t qla2x00_sysfs_read_sfp (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -679,18 +679,18 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_sfp_attr = { +static const struct bin_attribute sysfs_sfp_attr = { .attr = { .name ="sfp" , .mode =S_IRUSR |S_IWUSR , }, .size =SFP_DEV_SIZE , - .read = qla2x00_sysfs_read_sfp, + .read_new = qla2x00_sysfs_read_sfp, };static ssize_t qla2x00_sysfs_write_reset (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -823,19 +823,19 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_reset_attr = { +static const struct bin_attribute sysfs_reset_attr = { .attr = { .name ="reset" , .mode =S_IWUSR , }, .size =0 , - .write = qla2x00_sysfs_write_reset, + .write_new = qla2x00_sysfs_write_reset, };static ssize_t qla2x00_issue_logo (struct file *filp,struct kobject *kobj, -struct bin_attribute *bin_attr, -char *buf,loff_t off,size_t count) +const struct bin_attribute *bin_attr, +char *buf,loff_t off,size_t count) {struct scsi_qla_host *vha =shost_priv (dev_to_shost (container_of (kobj, struct device, kobj)));
@@ -866,18 +866,18 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_issue_logo_attr = { +static const struct bin_attribute sysfs_issue_logo_attr = { .attr = { .name ="issue_logo" , .mode =S_IWUSR , }, .size =0 , - .write = qla2x00_issue_logo, + .write_new = qla2x00_issue_logo, };static ssize_t qla2x00_sysfs_read_xgmac_stats (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -929,18 +929,18 @@ qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_xgmac_stats_attr = { +static const struct bin_attribute sysfs_xgmac_stats_attr = { .attr = { .name ="xgmac_stats" , .mode =S_IRUSR , }, .size =0 , - .read = qla2x00_sysfs_read_xgmac_stats, + .read_new = qla2x00_sysfs_read_xgmac_stats, };static ssize_t qla2x00_sysfs_read_dcbx_tlv (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) { struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
@@ -987,18 +987,18 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_dcbx_tlv_attr = { +static const struct bin_attribute sysfs_dcbx_tlv_attr = { .attr = { .name ="dcbx_tlv" , .mode =S_IRUSR , }, .size =0 , - .read = qla2x00_sysfs_read_dcbx_tlv, + .read_new = qla2x00_sysfs_read_dcbx_tlv, };static struct sysfs_entry {char *name; -struct bin_attribute *attr; +const struct bin_attribute *attr;int type; } bin_file_entries[] = { {"fw_dump" , &sysfs_fw_dump_attr, },
Signature · 1 line
2.47.1
PATCH 11/11 scsi: qla4xxx: Constify 'struct bin_attribute'
In reply to Thomas WeißschuhThe 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.
--- drivers/scsi/qla4xxx/ql4_attr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/qla4xxx/ql4_attr.c +6 -6
@@ -10,7 +10,7 @@static ssize_t qla4_8xxx_sysfs_read_fw_dump (struct file *filep,struct kobject *kobj, -struct bin_attribute *ba,char *buf,loff_t off, +const struct bin_attribute *ba,char *buf,loff_t off,size_t count) { struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
@@ -28,7 +28,7 @@ qla4_8xxx_sysfs_read_fw_dump(struct file *filep, struct kobject *kobj,static ssize_t qla4_8xxx_sysfs_write_fw_dump (struct file *filep,struct kobject *kobj, -struct bin_attribute *ba,char *buf,loff_t off, +const struct bin_attribute *ba,char *buf,loff_t off,size_t count) { struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
@@ -104,19 +104,19 @@ qla4_8xxx_sysfs_write_fw_dump(struct file *filep, struct kobject *kobj,return count; } -static struct bin_attribute sysfs_fw_dump_attr = { +static const struct bin_attribute sysfs_fw_dump_attr = { .attr = { .name ="fw_dump" , .mode =S_IRUSR |S_IWUSR , }, .size =0 , - .read = qla4_8xxx_sysfs_read_fw_dump, - .write = qla4_8xxx_sysfs_write_fw_dump, + .read_new = qla4_8xxx_sysfs_read_fw_dump, + .write_new = qla4_8xxx_sysfs_write_fw_dump, };static struct sysfs_entry {char *name; -struct bin_attribute *attr; +const struct bin_attribute *attr; } bin_file_entries[] = { {"fw_dump" , &sysfs_fw_dump_attr }, {NULL },
Signature · 1 line
2.47.1
Martin K. Petersen
AppliedThomas,
Quoted 3 lines
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.
Applied to 6.14/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 5 lines · Thomas Weißschuh
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.
Applied to 6.14/scsi-queue, thanks!
[01/11] scsi: core: Constify 'struct bin_attribute'
https://git.kernel.org/mkp/scsi/c/e4dab5d1ded3 [02/11] scsi: 3w-sas: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/1cf448bd2e6a [03/11] scsi: arcmsr: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/3e72fc051d4c [04/11] scsi: esas2r: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/61e2d41cafc6 [05/11] scsi: ibmvfc: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/af58c759836b [06/11] scsi: lpfc: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/4594a1f827d4 [07/11] scsi: ipr: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/f6af41ff6671 [08/11] scsi: qedf: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/a8116aa2898b [09/11] scsi: qedi: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/f9d0a8450ee3 [10/11] scsi: qla2xxx: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/06a9ceb95f86 [11/11] scsi: qla4xxx: Constify 'struct bin_attribute' https://git.kernel.org/mkp/scsi/c/ea4f2219dd40
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering