Skip to content

Commit ef37c66

Browse files
t-8chAlexander Gordeev
authored andcommitted
s390/pci: 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]> Acked-by: Alexander Gordeev <[email protected]> Link: https://lore.kernel.org/r/20241211-sysfs-const-bin_attr-s390-v1-3-be01f66bfcf7@weissschuh.net Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 77977da commit ef37c66

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/s390/pci/pci_sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static ssize_t recover_store(struct device *dev, struct device_attribute *attr,
135135
static DEVICE_ATTR_WO(recover);
136136

137137
static ssize_t util_string_read(struct file *filp, struct kobject *kobj,
138-
struct bin_attribute *attr, char *buf,
138+
const struct bin_attribute *attr, char *buf,
139139
loff_t off, size_t count)
140140
{
141141
struct device *dev = kobj_to_dev(kobj);
@@ -145,10 +145,10 @@ static ssize_t util_string_read(struct file *filp, struct kobject *kobj,
145145
return memory_read_from_buffer(buf, count, &off, zdev->util_str,
146146
sizeof(zdev->util_str));
147147
}
148-
static BIN_ATTR_RO(util_string, CLP_UTIL_STR_LEN);
148+
static const BIN_ATTR_RO(util_string, CLP_UTIL_STR_LEN);
149149

150150
static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
151-
struct bin_attribute *attr, char *buf,
151+
const struct bin_attribute *attr, char *buf,
152152
loff_t off, size_t count)
153153
{
154154
struct zpci_report_error_header *report = (void *) buf;
@@ -164,7 +164,7 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
164164

165165
return ret ? ret : count;
166166
}
167-
static BIN_ATTR(report_error, S_IWUSR, NULL, report_error_write, PAGE_SIZE);
167+
static const BIN_ATTR(report_error, S_IWUSR, NULL, report_error_write, PAGE_SIZE);
168168

169169
static ssize_t uid_is_unique_show(struct device *dev,
170170
struct device_attribute *attr, char *buf)
@@ -203,7 +203,7 @@ const struct attribute_group zpci_ident_attr_group = {
203203
.is_visible = zpci_index_is_visible,
204204
};
205205

206-
static struct bin_attribute *zpci_bin_attrs[] = {
206+
static const struct bin_attribute *const zpci_bin_attrs[] = {
207207
&bin_attr_util_string,
208208
&bin_attr_report_error,
209209
NULL,
@@ -227,7 +227,7 @@ static struct attribute *zpci_dev_attrs[] = {
227227

228228
const struct attribute_group zpci_attr_group = {
229229
.attrs = zpci_dev_attrs,
230-
.bin_attrs = zpci_bin_attrs,
230+
.bin_attrs_new = zpci_bin_attrs,
231231
};
232232

233233
static struct attribute *pfip_attrs[] = {

0 commit comments

Comments
 (0)