Skip to content

Commit 5d0fbf5

Browse files
t-8chgregkh
authored andcommitted
rapidio: 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-rapidio-v1-1-0f47f4719683@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 80f756c commit 5d0fbf5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/rapidio/rio-sysfs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static struct attribute *rio_dev_attrs[] = {
114114

115115
static ssize_t
116116
rio_read_config(struct file *filp, struct kobject *kobj,
117-
struct bin_attribute *bin_attr,
117+
const struct bin_attribute *bin_attr,
118118
char *buf, loff_t off, size_t count)
119119
{
120120
struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj));
@@ -185,7 +185,7 @@ rio_read_config(struct file *filp, struct kobject *kobj,
185185

186186
static ssize_t
187187
rio_write_config(struct file *filp, struct kobject *kobj,
188-
struct bin_attribute *bin_attr,
188+
const struct bin_attribute *bin_attr,
189189
char *buf, loff_t off, size_t count)
190190
{
191191
struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj));
@@ -241,17 +241,17 @@ rio_write_config(struct file *filp, struct kobject *kobj,
241241
return count;
242242
}
243243

244-
static struct bin_attribute rio_config_attr = {
244+
static const struct bin_attribute rio_config_attr = {
245245
.attr = {
246246
.name = "config",
247247
.mode = S_IRUGO | S_IWUSR,
248248
},
249249
.size = RIO_MAINT_SPACE_SZ,
250-
.read = rio_read_config,
251-
.write = rio_write_config,
250+
.read_new = rio_read_config,
251+
.write_new = rio_write_config,
252252
};
253253

254-
static struct bin_attribute *rio_dev_bin_attrs[] = {
254+
static const struct bin_attribute *const rio_dev_bin_attrs[] = {
255255
&rio_config_attr,
256256
NULL,
257257
};
@@ -278,7 +278,7 @@ static umode_t rio_dev_is_attr_visible(struct kobject *kobj,
278278
static const struct attribute_group rio_dev_group = {
279279
.attrs = rio_dev_attrs,
280280
.is_visible = rio_dev_is_attr_visible,
281-
.bin_attrs = rio_dev_bin_attrs,
281+
.bin_attrs_new = rio_dev_bin_attrs,
282282
};
283283

284284
const struct attribute_group *rio_dev_groups[] = {

0 commit comments

Comments
 (0)