mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
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 <linux@weissschuh.net> Link: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-scsi-v1-7-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
4594a1f827
commit
f6af41ff66
|
|
@ -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; };
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user