Skip to content

Commit f629576

Browse files
t-8chgregkh
authored andcommitted
powerpc/powernv/ultravisor: 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-powerpc-v1-3-bbed8906f476@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 982d13d commit f629576

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/powerpc/platforms/powernv/ultravisor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ int __init early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
3232
static struct memcons *uv_memcons;
3333

3434
static ssize_t uv_msglog_read(struct file *file, struct kobject *kobj,
35-
struct bin_attribute *bin_attr, char *to,
35+
const struct bin_attribute *bin_attr, char *to,
3636
loff_t pos, size_t count)
3737
{
3838
return memcons_copy(uv_memcons, to, pos, count);
3939
}
4040

41-
static struct bin_attribute uv_msglog_attr = {
41+
static struct bin_attribute uv_msglog_attr __ro_after_init = {
4242
.attr = {.name = "msglog", .mode = 0400},
43-
.read = uv_msglog_read
43+
.read_new = uv_msglog_read
4444
};
4545

4646
static int __init uv_init(void)

0 commit comments

Comments
 (0)