* [PATCH 0/9] misc: constify 'struct bin_attribute'
@ 2024-12-16 11:32 Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 1/9] ocxl: Constify " Thomas Weißschuh
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:32 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
Thomas Weißschuh (9):
ocxl: Constify 'struct bin_attribute'
cxl: Constify 'struct bin_attribute'
misc: sram: constify 'struct bin_attribute'
misc: c2port: Calculate bin_attribute size through group callback
misc: c2port: Constify 'struct bin_attribute'
misc: pch_phub: Constify 'struct bin_attribute'
misc: eeprom/idt_89hpesx: Constify 'struct bin_attribute'
misc: eeprom/max6875: Constify 'struct bin_attribute'
misc: ds1682: Constify 'struct bin_attribute'
drivers/misc/c2port/core.c | 27 +++++++++++++++++++--------
drivers/misc/cxl/sysfs.c | 8 ++++----
drivers/misc/ds1682.c | 8 ++++----
drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
drivers/misc/eeprom/max6875.c | 4 ++--
drivers/misc/ocxl/sysfs.c | 4 ++--
drivers/misc/pch_phub.c | 8 ++++----
drivers/misc/sram.c | 8 ++++----
8 files changed, 42 insertions(+), 31 deletions(-)
---
base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
change-id: 20241215-sysfs-const-bin_attr-misc-drivers-721114a2b3d3
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/9] ocxl: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
@ 2024-12-16 11:32 ` Thomas Weißschuh
2024-12-18 7:21 ` Andrew Donnellan
2024-12-16 11:32 ` [PATCH 2/9] cxl: " Thomas Weißschuh
` (7 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:32 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/ocxl/sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/ocxl/sysfs.c b/drivers/misc/ocxl/sysfs.c
index 07520d6e6dc55702696b8656440914c379e6e27a..e849641687a005fec5eb7a6b2e96bc0e9d04dc05 100644
--- a/drivers/misc/ocxl/sysfs.c
+++ b/drivers/misc/ocxl/sysfs.c
@@ -94,7 +94,7 @@ static struct device_attribute afu_attrs[] = {
};
static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ocxl_afu *afu = to_afu(kobj_to_dev(kobj));
@@ -155,7 +155,7 @@ int ocxl_sysfs_register_afu(struct ocxl_file_info *info)
info->attr_global_mmio.attr.name = "global_mmio_area";
info->attr_global_mmio.attr.mode = 0600;
info->attr_global_mmio.size = info->afu->config.global_mmio_size;
- info->attr_global_mmio.read = global_mmio_read;
+ info->attr_global_mmio.read_new = global_mmio_read;
info->attr_global_mmio.mmap = global_mmio_mmap;
rc = device_create_bin_file(&info->dev, &info->attr_global_mmio);
if (rc) {
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/9] cxl: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 1/9] ocxl: Constify " Thomas Weißschuh
@ 2024-12-16 11:32 ` Thomas Weißschuh
2024-12-18 7:21 ` Andrew Donnellan
2024-12-16 11:32 ` [PATCH 3/9] misc: sram: constify " Thomas Weißschuh
` (6 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:32 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/cxl/sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index 409bd1c39663159a0d11c3ccba2aa5a8451baa34..b1fc6446bd4b7caa2f5c6e23e0aba5934caffd46 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -444,7 +444,7 @@ static ssize_t api_version_compatible_show(struct device *device,
}
static ssize_t afu_eb_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct cxl_afu *afu = to_cxl_afu(kobj_to_dev(kobj));
@@ -538,7 +538,7 @@ static ssize_t class_show(struct kobject *kobj,
}
static ssize_t afu_read_config(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct afu_config_record *cr = to_cr(kobj);
@@ -620,7 +620,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c
cr->config_attr.attr.name = "config";
cr->config_attr.attr.mode = S_IRUSR;
cr->config_attr.size = afu->crs_len;
- cr->config_attr.read = afu_read_config;
+ cr->config_attr.read_new = afu_read_config;
rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type,
&afu->dev.kobj, "cr%i", cr->cr);
@@ -693,7 +693,7 @@ int cxl_sysfs_afu_add(struct cxl_afu *afu)
afu->attr_eb.attr.name = "afu_err_buff";
afu->attr_eb.attr.mode = S_IRUGO;
afu->attr_eb.size = afu->eb_len;
- afu->attr_eb.read = afu_eb_read;
+ afu->attr_eb.read_new = afu_eb_read;
rc = device_create_bin_file(&afu->dev, &afu->attr_eb);
if (rc) {
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/9] misc: sram: constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 1/9] ocxl: Constify " Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 2/9] cxl: " Thomas Weißschuh
@ 2024-12-16 11:32 ` Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 4/9] misc: c2port: Calculate bin_attribute size through group callback Thomas Weißschuh
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:32 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/sram.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index e40b027a88e25209933a20dc9dbd7db29cb81ba5..e5069882457ef6ba5dc084d02994034dc39d24c6 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -23,7 +23,7 @@
#define SRAM_GRANULARITY 32
static ssize_t sram_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t pos, size_t count)
{
struct sram_partition *part;
@@ -38,7 +38,7 @@ static ssize_t sram_read(struct file *filp, struct kobject *kobj,
}
static ssize_t sram_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t pos, size_t count)
{
struct sram_partition *part;
@@ -83,8 +83,8 @@ static int sram_add_export(struct sram_dev *sram, struct sram_reserve *block,
return -ENOMEM;
part->battr.attr.mode = S_IRUSR | S_IWUSR;
- part->battr.read = sram_read;
- part->battr.write = sram_write;
+ part->battr.read_new = sram_read;
+ part->battr.write_new = sram_write;
part->battr.size = block->size;
return device_create_bin_file(sram->dev, &part->battr);
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/9] misc: c2port: Calculate bin_attribute size through group callback
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (2 preceding siblings ...)
2024-12-16 11:32 ` [PATCH 3/9] misc: sram: constify " Thomas Weißschuh
@ 2024-12-16 11:32 ` Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 5/9] misc: c2port: Constify 'struct bin_attribute' Thomas Weißschuh
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:32 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
Modifying the size of the global bin_attribute instance can be racy.
Instead use the new .bin_size callback to do so safely.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/misc/c2port/core.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index 2bb1dd2511f9dd178b8c06baa460bb609f7f8fd7..5d6767b484c998b44a3c90c177d12028db1ea1af 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -874,9 +874,22 @@ static struct bin_attribute *c2port_bin_attrs[] = {
NULL,
};
+static size_t c2port_bin_attr_size(struct kobject *kobj,
+ const struct bin_attribute *attr,
+ int i)
+{
+ struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));
+
+ if (attr == &bin_attr_flash_data)
+ return c2dev->ops->blocks_num * c2dev->ops->block_size;
+
+ return attr->size;
+}
+
static const struct attribute_group c2port_group = {
.attrs = c2port_attrs,
.bin_attrs = c2port_bin_attrs,
+ .bin_size = c2port_bin_attr_size,
};
static const struct attribute_group *c2port_groups[] = {
@@ -913,8 +926,6 @@ struct c2port_device *c2port_device_register(char *name,
goto error_idr_alloc;
c2dev->id = ret;
- bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
-
c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
"c2port%d", c2dev->id);
if (IS_ERR(c2dev->dev)) {
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/9] misc: c2port: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (3 preceding siblings ...)
2024-12-16 11:32 ` [PATCH 4/9] misc: c2port: Calculate bin_attribute size through group callback Thomas Weißschuh
@ 2024-12-16 11:33 ` Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 6/9] misc: pch_phub: " Thomas Weißschuh
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:33 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/c2port/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index 5d6767b484c998b44a3c90c177d12028db1ea1af..eb780e635352f3a815e8d400d71c04b47507cd4b 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -714,7 +714,7 @@ static ssize_t __c2port_read_flash_data(struct c2port_device *dev,
}
static ssize_t c2port_read_flash_data(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buffer, loff_t offset, size_t count)
{
struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));
@@ -829,7 +829,7 @@ static ssize_t __c2port_write_flash_data(struct c2port_device *dev,
}
static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buffer, loff_t offset, size_t count)
{
struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));
@@ -849,8 +849,8 @@ static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj,
return ret;
}
/* size is computed at run-time */
-static BIN_ATTR(flash_data, 0644, c2port_read_flash_data,
- c2port_write_flash_data, 0);
+static const BIN_ATTR(flash_data, 0644, c2port_read_flash_data,
+ c2port_write_flash_data, 0);
/*
* Class attributes
@@ -869,7 +869,7 @@ static struct attribute *c2port_attrs[] = {
NULL,
};
-static struct bin_attribute *c2port_bin_attrs[] = {
+static const struct bin_attribute *const c2port_bin_attrs[] = {
&bin_attr_flash_data,
NULL,
};
@@ -888,7 +888,7 @@ static size_t c2port_bin_attr_size(struct kobject *kobj,
static const struct attribute_group c2port_group = {
.attrs = c2port_attrs,
- .bin_attrs = c2port_bin_attrs,
+ .bin_attrs_new = c2port_bin_attrs,
.bin_size = c2port_bin_attr_size,
};
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/9] misc: pch_phub: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (4 preceding siblings ...)
2024-12-16 11:33 ` [PATCH 5/9] misc: c2port: Constify 'struct bin_attribute' Thomas Weißschuh
@ 2024-12-16 11:33 ` Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 7/9] misc: eeprom/idt_89hpesx: " Thomas Weißschuh
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:33 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/pch_phub.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c
index 8d2b7135738ed5543138f2249d2379a10113b410..6121c0940cd148d48b8d574065c50703b6a301d7 100644
--- a/drivers/misc/pch_phub.c
+++ b/drivers/misc/pch_phub.c
@@ -483,7 +483,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
}
static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr, char *buf,
+ const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
unsigned int rom_signature;
@@ -553,7 +553,7 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
}
static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
int err;
@@ -655,8 +655,8 @@ static const struct bin_attribute pch_bin_attr = {
.mode = S_IRUGO | S_IWUSR,
},
.size = PCH_PHUB_OROM_SIZE + 1,
- .read = pch_phub_bin_read,
- .write = pch_phub_bin_write,
+ .read_new = pch_phub_bin_read,
+ .write_new = pch_phub_bin_write,
};
static int pch_phub_probe(struct pci_dev *pdev,
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/9] misc: eeprom/idt_89hpesx: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (5 preceding siblings ...)
2024-12-16 11:33 ` [PATCH 6/9] misc: pch_phub: " Thomas Weißschuh
@ 2024-12-16 11:33 ` Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 8/9] misc: eeprom/max6875: " Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 9/9] misc: ds1682: " Thomas Weißschuh
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:33 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index 43421fe37d338874ff1c2949497c64ebf0143106..1fc632ebf22f560088084519e5ad8e8b37958368 100644
--- a/drivers/misc/eeprom/idt_89hpesx.c
+++ b/drivers/misc/eeprom/idt_89hpesx.c
@@ -847,7 +847,7 @@ static int idt_csr_read(struct idt_89hpesx_dev *pdev, u16 csraddr, u32 *data)
* @count: Number of bytes to write
*/
static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct idt_89hpesx_dev *pdev;
@@ -871,7 +871,7 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
* @count: Number of bytes to write
*/
static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct idt_89hpesx_dev *pdev;
@@ -1017,7 +1017,7 @@ static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
* NOTE Size will be changed in compliance with OF node. EEPROM attribute will
* be read-only as well if the corresponding flag is specified in OF node.
*/
-static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);
+static const BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);
/*
* csr_dbgfs_ops - CSR debugfs-node read/write operations
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 8/9] misc: eeprom/max6875: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (6 preceding siblings ...)
2024-12-16 11:33 ` [PATCH 7/9] misc: eeprom/idt_89hpesx: " Thomas Weißschuh
@ 2024-12-16 11:33 ` Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 9/9] misc: ds1682: " Thomas Weißschuh
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:33 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/eeprom/max6875.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/eeprom/max6875.c b/drivers/misc/eeprom/max6875.c
index 6fab2ffa736b741593931c413f230d7c43b5b8dd..1c36ad153e783ead6ba2481c64838390f0bb05f4 100644
--- a/drivers/misc/eeprom/max6875.c
+++ b/drivers/misc/eeprom/max6875.c
@@ -104,7 +104,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
}
static ssize_t max6875_read(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 i2c_client *client = kobj_to_i2c_client(kobj);
@@ -127,7 +127,7 @@ static const struct bin_attribute user_eeprom_attr = {
.mode = S_IRUGO,
},
.size = USER_EEPROM_SIZE,
- .read = max6875_read,
+ .read_new = max6875_read,
};
static int max6875_probe(struct i2c_client *client)
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 9/9] misc: ds1682: Constify 'struct bin_attribute'
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
` (7 preceding siblings ...)
2024-12-16 11:33 ` [PATCH 8/9] misc: eeprom/max6875: " Thomas Weißschuh
@ 2024-12-16 11:33 ` Thomas Weißschuh
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Weißschuh @ 2024-12-16 11:33 UTC (permalink / raw)
To: Frederic Barrat, Andrew Donnellan, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel, Thomas Weißschuh
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@weissschuh.net>
---
drivers/misc/ds1682.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/ds1682.c b/drivers/misc/ds1682.c
index 4175df7ef0111f69ed8d4229b7ab50a3c3d7ad12..5d5a70a62e98b6691aac1c0f9142d39555ba4f8c 100644
--- a/drivers/misc/ds1682.c
+++ b/drivers/misc/ds1682.c
@@ -154,7 +154,7 @@ static const struct attribute_group ds1682_group = {
* User data attribute
*/
static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client = kobj_to_i2c_client(kobj);
@@ -172,7 +172,7 @@ static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj,
}
static ssize_t ds1682_eeprom_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
+ const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client = kobj_to_i2c_client(kobj);
@@ -194,8 +194,8 @@ static const struct bin_attribute ds1682_eeprom_attr = {
.mode = S_IRUGO | S_IWUSR,
},
.size = DS1682_EEPROM_SIZE,
- .read = ds1682_eeprom_read,
- .write = ds1682_eeprom_write,
+ .read_new = ds1682_eeprom_read,
+ .write_new = ds1682_eeprom_write,
};
static int ds1682_nvmem_read(void *priv, unsigned int offset, void *val,
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/9] cxl: Constify 'struct bin_attribute'
2024-12-16 11:32 ` [PATCH 2/9] cxl: " Thomas Weißschuh
@ 2024-12-18 7:21 ` Andrew Donnellan
0 siblings, 0 replies; 12+ messages in thread
From: Andrew Donnellan @ 2024-12-18 7:21 UTC (permalink / raw)
To: Thomas Weißschuh, Frederic Barrat, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel
On Mon, 2024-12-16 at 12:32 +0100, Thomas Weißschuh wrote:
> 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@weissschuh.net>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
noting that we're hoping to remove this driver shortly.
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/9] ocxl: Constify 'struct bin_attribute'
2024-12-16 11:32 ` [PATCH 1/9] ocxl: Constify " Thomas Weißschuh
@ 2024-12-18 7:21 ` Andrew Donnellan
0 siblings, 0 replies; 12+ messages in thread
From: Andrew Donnellan @ 2024-12-18 7:21 UTC (permalink / raw)
To: Thomas Weißschuh, Frederic Barrat, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linuxppc-dev, linux-kernel
On Mon, 2024-12-16 at 12:32 +0100, Thomas Weißschuh wrote:
> 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@weissschuh.net>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-12-18 7:21 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-16 11:32 [PATCH 0/9] misc: constify 'struct bin_attribute' Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 1/9] ocxl: Constify " Thomas Weißschuh
2024-12-18 7:21 ` Andrew Donnellan
2024-12-16 11:32 ` [PATCH 2/9] cxl: " Thomas Weißschuh
2024-12-18 7:21 ` Andrew Donnellan
2024-12-16 11:32 ` [PATCH 3/9] misc: sram: constify " Thomas Weißschuh
2024-12-16 11:32 ` [PATCH 4/9] misc: c2port: Calculate bin_attribute size through group callback Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 5/9] misc: c2port: Constify 'struct bin_attribute' Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 6/9] misc: pch_phub: " Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 7/9] misc: eeprom/idt_89hpesx: " Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 8/9] misc: eeprom/max6875: " Thomas Weißschuh
2024-12-16 11:33 ` [PATCH 9/9] misc: ds1682: " Thomas Weißschuh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).