Skip to content

Commit 2485f8e

Browse files
t-8chgregkh
authored andcommitted
devcoredump: 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/20250114-sysfs-const-bin_attr-devcoredump-v1-2-fa93be30efae@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bf1ad6c commit 2485f8e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/base/devcoredump.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static void devcd_del(struct work_struct *wk)
106106
}
107107

108108
static ssize_t devcd_data_read(struct file *filp, struct kobject *kobj,
109-
struct bin_attribute *bin_attr,
109+
const struct bin_attribute *bin_attr,
110110
char *buffer, loff_t offset, size_t count)
111111
{
112112
struct device *dev = kobj_to_dev(kobj);
@@ -116,7 +116,7 @@ static ssize_t devcd_data_read(struct file *filp, struct kobject *kobj,
116116
}
117117

118118
static ssize_t devcd_data_write(struct file *filp, struct kobject *kobj,
119-
struct bin_attribute *bin_attr,
119+
const struct bin_attribute *bin_attr,
120120
char *buffer, loff_t offset, size_t count)
121121
{
122122
struct device *dev = kobj_to_dev(kobj);
@@ -132,15 +132,15 @@ static ssize_t devcd_data_write(struct file *filp, struct kobject *kobj,
132132
return count;
133133
}
134134

135-
static struct bin_attribute devcd_attr_data =
135+
static const struct bin_attribute devcd_attr_data =
136136
__BIN_ATTR(data, 0600, devcd_data_read, devcd_data_write, 0);
137137

138-
static struct bin_attribute *devcd_dev_bin_attrs[] = {
138+
static const struct bin_attribute *const devcd_dev_bin_attrs[] = {
139139
&devcd_attr_data, NULL,
140140
};
141141

142142
static const struct attribute_group devcd_dev_group = {
143-
.bin_attrs = devcd_dev_bin_attrs,
143+
.bin_attrs_new = devcd_dev_bin_attrs,
144144
};
145145

146146
static const struct attribute_group *devcd_dev_groups[] = {

0 commit comments

Comments
 (0)