Skip to content

Commit 4aad348

Browse files
t-8chgregkh
authored andcommitted
powerpc/perf/hv-24x7: 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-5-bbed8906f476@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f2b62c0 commit 4aad348

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/powerpc/perf/hv-24x7.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ static int create_events_from_catalog(struct attribute ***events_,
998998
}
999999

10001000
static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
1001-
struct bin_attribute *bin_attr, char *buf,
1001+
const struct bin_attribute *bin_attr, char *buf,
10021002
loff_t offset, size_t count)
10031003
{
10041004
long hret;
@@ -1108,14 +1108,14 @@ PAGE_0_ATTR(catalog_version, "%lld\n",
11081108
(unsigned long long)be64_to_cpu(page_0->version));
11091109
PAGE_0_ATTR(catalog_len, "%lld\n",
11101110
(unsigned long long)be32_to_cpu(page_0->length) * 4096);
1111-
static BIN_ATTR_RO(catalog, 0/* real length varies */);
1111+
static const BIN_ATTR_RO(catalog, 0/* real length varies */);
11121112
static DEVICE_ATTR_RO(domains);
11131113
static DEVICE_ATTR_RO(sockets);
11141114
static DEVICE_ATTR_RO(chipspersocket);
11151115
static DEVICE_ATTR_RO(coresperchip);
11161116
static DEVICE_ATTR_RO(cpumask);
11171117

1118-
static struct bin_attribute *if_bin_attrs[] = {
1118+
static const struct bin_attribute *const if_bin_attrs[] = {
11191119
&bin_attr_catalog,
11201120
NULL,
11211121
};
@@ -1141,7 +1141,7 @@ static struct attribute *if_attrs[] = {
11411141

11421142
static const struct attribute_group if_group = {
11431143
.name = "interface",
1144-
.bin_attrs = if_bin_attrs,
1144+
.bin_attrs_new = if_bin_attrs,
11451145
.attrs = if_attrs,
11461146
};
11471147

0 commit comments

Comments
 (0)