[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241216-sysfs-const-bin_attr-rapidio-v1-1-0f47f4719683@weissschuh.net>
Date: Mon, 16 Dec 2024 13:22:54 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Matt Porter <mporter@...nel.crashing.org>,
Alexandre Bounine <alex.bou9@...il.com>
Cc: linux-kernel@...r.kernel.org,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH] 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 <linux@...ssschuh.net>
---
drivers/rapidio/rio-sysfs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 90d3912105338233b5f1cafc01fd499a77b66427..6f89b232f1d5d10a4dccf51422a57d4355ccf0c2 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -114,7 +114,7 @@ static struct attribute *rio_dev_attrs[] = {
static ssize_t
rio_read_config(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
+ const struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj));
@@ -185,7 +185,7 @@ rio_read_config(struct file *filp, struct kobject *kobj,
static ssize_t
rio_write_config(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
+ const struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj));
@@ -241,17 +241,17 @@ rio_write_config(struct file *filp, struct kobject *kobj,
return count;
}
-static struct bin_attribute rio_config_attr = {
+static const struct bin_attribute rio_config_attr = {
.attr = {
.name = "config",
.mode = S_IRUGO | S_IWUSR,
},
.size = RIO_MAINT_SPACE_SZ,
- .read = rio_read_config,
- .write = rio_write_config,
+ .read_new = rio_read_config,
+ .write_new = rio_write_config,
};
-static struct bin_attribute *rio_dev_bin_attrs[] = {
+static const struct bin_attribute *const rio_dev_bin_attrs[] = {
&rio_config_attr,
NULL,
};
@@ -278,7 +278,7 @@ static umode_t rio_dev_is_attr_visible(struct kobject *kobj,
static const struct attribute_group rio_dev_group = {
.attrs = rio_dev_attrs,
.is_visible = rio_dev_is_attr_visible,
- .bin_attrs = rio_dev_bin_attrs,
+ .bin_attrs_new = rio_dev_bin_attrs,
};
const struct attribute_group *rio_dev_groups[] = {
---
base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
change-id: 20241216-sysfs-const-bin_attr-rapidio-46c94caf2a28
Best regards,
--
Thomas Weißschuh <linux@...ssschuh.net>
Powered by blists - more mailing lists