Skip to content

Commit f6af41f

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

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/scsi/ipr.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,7 +3366,7 @@ static void ipr_worker_thread(struct work_struct *work)
33663366
* number of bytes printed to buffer
33673367
**/
33683368
static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj,
3369-
struct bin_attribute *bin_attr,
3369+
const struct bin_attribute *bin_attr,
33703370
char *buf, loff_t off, size_t count)
33713371
{
33723372
struct device *dev = kobj_to_dev(kobj);
@@ -3383,13 +3383,13 @@ static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj,
33833383
return ret;
33843384
}
33853385

3386-
static struct bin_attribute ipr_trace_attr = {
3386+
static const struct bin_attribute ipr_trace_attr = {
33873387
.attr = {
33883388
.name = "trace",
33893389
.mode = S_IRUGO,
33903390
},
33913391
.size = 0,
3392-
.read = ipr_read_trace,
3392+
.read_new = ipr_read_trace,
33933393
};
33943394
#endif
33953395

@@ -4087,7 +4087,7 @@ static struct device_attribute ipr_ioa_fw_type_attr = {
40874087
};
40884088

40894089
static ssize_t ipr_read_async_err_log(struct file *filep, struct kobject *kobj,
4090-
struct bin_attribute *bin_attr, char *buf,
4090+
const struct bin_attribute *bin_attr, char *buf,
40914091
loff_t off, size_t count)
40924092
{
40934093
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,
41114111
}
41124112

41134113
static ssize_t ipr_next_async_err_log(struct file *filep, struct kobject *kobj,
4114-
struct bin_attribute *bin_attr, char *buf,
4114+
const struct bin_attribute *bin_attr, char *buf,
41154115
loff_t off, size_t count)
41164116
{
41174117
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,
41344134
return count;
41354135
}
41364136

4137-
static struct bin_attribute ipr_ioa_async_err_log = {
4137+
static const struct bin_attribute ipr_ioa_async_err_log = {
41384138
.attr = {
41394139
.name = "async_err_log",
41404140
.mode = S_IRUGO | S_IWUSR,
41414141
},
41424142
.size = 0,
4143-
.read = ipr_read_async_err_log,
4144-
.write = ipr_next_async_err_log
4143+
.read_new = ipr_read_async_err_log,
4144+
.write_new = ipr_next_async_err_log
41454145
};
41464146

41474147
static struct attribute *ipr_ioa_attrs[] = {
@@ -4172,7 +4172,7 @@ ATTRIBUTE_GROUPS(ipr_ioa);
41724172
* number of bytes printed to buffer
41734173
**/
41744174
static ssize_t ipr_read_dump(struct file *filp, struct kobject *kobj,
4175-
struct bin_attribute *bin_attr,
4175+
const struct bin_attribute *bin_attr,
41764176
char *buf, loff_t off, size_t count)
41774177
{
41784178
struct device *cdev = kobj_to_dev(kobj);
@@ -4361,7 +4361,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg)
43614361
* number of bytes printed to buffer
43624362
**/
43634363
static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj,
4364-
struct bin_attribute *bin_attr,
4364+
const struct bin_attribute *bin_attr,
43654365
char *buf, loff_t off, size_t count)
43664366
{
43674367
struct device *cdev = kobj_to_dev(kobj);
@@ -4385,14 +4385,14 @@ static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj,
43854385
return count;
43864386
}
43874387

4388-
static struct bin_attribute ipr_dump_attr = {
4388+
static const struct bin_attribute ipr_dump_attr = {
43894389
.attr = {
43904390
.name = "dump",
43914391
.mode = S_IRUSR | S_IWUSR,
43924392
},
43934393
.size = 0,
4394-
.read = ipr_read_dump,
4395-
.write = ipr_write_dump
4394+
.read_new = ipr_read_dump,
4395+
.write_new = ipr_write_dump
43964396
};
43974397
#else
43984398
static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg) { return 0; };

0 commit comments

Comments
 (0)