Skip to content

Commit a8116aa

Browse files
t-8chmartinkpetersen
authored andcommitted
scsi: qedf: 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-8-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f6af41f commit a8116aa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/scsi/qedf/qedf_attr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void qedf_capture_grc_dump(struct qedf_ctx *qedf)
104104

105105
static ssize_t
106106
qedf_sysfs_read_grcdump(struct file *filep, struct kobject *kobj,
107-
struct bin_attribute *ba, char *buf, loff_t off,
107+
const struct bin_attribute *ba, char *buf, loff_t off,
108108
size_t count)
109109
{
110110
ssize_t ret = 0;
@@ -124,7 +124,7 @@ qedf_sysfs_read_grcdump(struct file *filep, struct kobject *kobj,
124124

125125
static ssize_t
126126
qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj,
127-
struct bin_attribute *ba, char *buf, loff_t off,
127+
const struct bin_attribute *ba, char *buf, loff_t off,
128128
size_t count)
129129
{
130130
struct fc_lport *lport = NULL;
@@ -160,14 +160,14 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj,
160160
return count;
161161
}
162162

163-
static struct bin_attribute sysfs_grcdump_attr = {
163+
static const struct bin_attribute sysfs_grcdump_attr = {
164164
.attr = {
165165
.name = "grcdump",
166166
.mode = S_IRUSR | S_IWUSR,
167167
},
168168
.size = 0,
169-
.read = qedf_sysfs_read_grcdump,
170-
.write = qedf_sysfs_write_grcdump,
169+
.read_new = qedf_sysfs_read_grcdump,
170+
.write_new = qedf_sysfs_write_grcdump,
171171
};
172172

173173
static struct sysfs_bin_attrs bin_file_entries[] = {

drivers/scsi/qedf/qedf_dbg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct Scsi_Host;
100100

101101
struct sysfs_bin_attrs {
102102
char *name;
103-
struct bin_attribute *attr;
103+
const struct bin_attribute *attr;
104104
};
105105

106106
extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len);

0 commit comments

Comments
 (0)