[Devel] [PATCH vz10 29/32] ms/pcmcia: cistpl: Constify 'struct bin_attribute'

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 21 19:37:15 MSK 2026


From: Thomas Weißschuh <linux at weissschuh.net>

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 at weissschuh.net>
Link: https://lore.kernel.org/r/20241215-sysfs-const-bin_attr-pcmcia-v1-1-ebb82e47d834@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from commit 05a9896fa9e15466456a1b1dc9d2eacdf3551b79)

Needed here because the RHEL10.2 base carries the sysfs side of the
conversion but not the pcmcia one, so the initializer of pccard_cis_attr
does not compile at all:

  drivers/pcmcia/cistpl.c:1608:17: error: initialization of
    'ssize_t (*)(struct file *, struct kobject *,
                 const struct bin_attribute *, char *, loff_t, size_t)'
    from incompatible pointer type [-Wincompatible-pointer-types]

Our shipped configs have CONFIG_PCCARD=n so it goes unnoticed there,
while plain x86_64 defconfig - which we now want to keep building for
KUnit - enables it.  Applies as is: this tree's struct bin_attribute has
both the ::read/::write and the ::read_new/::write_new members, and
sysfs_kf_bin_read() prefers the latter.

https://virtuozzo.atlassian.net/browse/VSTOR-134732
Feature: fix ms/pcmcia
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 drivers/pcmcia/cistpl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index d018f36f3a89..0c801e4ccc6c 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -1540,7 +1540,7 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf,
 
 
 static ssize_t pccard_show_cis(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)
 {
 	unsigned int size = 0x200;
@@ -1571,7 +1571,7 @@ static ssize_t pccard_show_cis(struct file *filp, struct kobject *kobj,
 
 
 static ssize_t pccard_store_cis(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 pcmcia_socket *s;
@@ -1605,6 +1605,6 @@ static ssize_t pccard_store_cis(struct file *filp, struct kobject *kobj,
 const struct bin_attribute pccard_cis_attr = {
 	.attr = { .name = "cis", .mode = S_IRUGO | S_IWUSR },
 	.size = 0x200,
-	.read = pccard_show_cis,
-	.write = pccard_store_cis,
+	.read_new = pccard_show_cis,
+	.write_new = pccard_store_cis,
 };
-- 
2.47.1



More information about the Devel mailing list