Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-constify-struct-bin_attribute'

Thomas Weißschuh says:

====================
net: 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.
====================

Link: https://patch.msgid.link/20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+17 -17
+10 -10
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
··· 2832 2832 2833 2833 static ssize_t 2834 2834 netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, 2835 - struct bin_attribute *attr, 2835 + const struct bin_attribute *attr, 2836 2836 char *buf, loff_t offset, size_t size) 2837 2837 { 2838 2838 struct device *dev = kobj_to_dev(kobj); ··· 2860 2860 2861 2861 static ssize_t 2862 2862 netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj, 2863 - struct bin_attribute *attr, 2863 + const struct bin_attribute *attr, 2864 2864 char *buf, loff_t offset, size_t size) 2865 2865 { 2866 2866 struct device *dev = kobj_to_dev(kobj); ··· 2901 2901 2902 2902 static ssize_t 2903 2903 netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, 2904 - struct bin_attribute *attr, 2904 + const struct bin_attribute *attr, 2905 2905 char *buf, loff_t offset, size_t size) 2906 2906 { 2907 2907 struct device *dev = kobj_to_dev(kobj); ··· 2922 2922 } 2923 2923 2924 2924 static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, 2925 - struct bin_attribute *attr, char *buf, 2925 + const struct bin_attribute *attr, char *buf, 2926 2926 loff_t offset, size_t size) 2927 2927 { 2928 2928 struct device *dev = kobj_to_dev(kobj); ··· 2946 2946 static const struct bin_attribute bin_attr_crb = { 2947 2947 .attr = { .name = "crb", .mode = 0644 }, 2948 2948 .size = 0, 2949 - .read = netxen_sysfs_read_crb, 2950 - .write = netxen_sysfs_write_crb, 2949 + .read_new = netxen_sysfs_read_crb, 2950 + .write_new = netxen_sysfs_write_crb, 2951 2951 }; 2952 2952 2953 2953 static const struct bin_attribute bin_attr_mem = { 2954 2954 .attr = { .name = "mem", .mode = 0644 }, 2955 2955 .size = 0, 2956 - .read = netxen_sysfs_read_mem, 2957 - .write = netxen_sysfs_write_mem, 2956 + .read_new = netxen_sysfs_read_mem, 2957 + .write_new = netxen_sysfs_write_mem, 2958 2958 }; 2959 2959 2960 2960 static ssize_t 2961 2961 netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj, 2962 - struct bin_attribute *attr, 2962 + const struct bin_attribute *attr, 2963 2963 char *buf, loff_t offset, size_t size) 2964 2964 { 2965 2965 struct device *dev = kobj_to_dev(kobj); ··· 3082 3082 static const struct bin_attribute bin_attr_dimm = { 3083 3083 .attr = { .name = "dimm", .mode = 0644 }, 3084 3084 .size = sizeof(struct netxen_dimm_cfg), 3085 - .read = netxen_sysfs_read_dimm, 3085 + .read_new = netxen_sysfs_read_dimm, 3086 3086 }; 3087 3087 3088 3088
+4 -4
drivers/net/phy/spi_ks8995.c
··· 289 289 } 290 290 291 291 static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, 292 - struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) 292 + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) 293 293 { 294 294 struct device *dev; 295 295 struct ks8995_switch *ks8995; ··· 301 301 } 302 302 303 303 static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj, 304 - struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) 304 + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) 305 305 { 306 306 struct device *dev; 307 307 struct ks8995_switch *ks8995; ··· 401 401 .mode = 0600, 402 402 }, 403 403 .size = KS8995_REGS_SIZE, 404 - .read = ks8995_registers_read, 405 - .write = ks8995_registers_write, 404 + .read_new = ks8995_registers_read, 405 + .write_new = ks8995_registers_write, 406 406 }; 407 407 408 408 /* ------------------------------------------------------------------------ */
+3 -3
net/bridge/br_sysfs_br.c
··· 1002 1002 * Returns the number of bytes read. 1003 1003 */ 1004 1004 static ssize_t brforward_read(struct file *filp, struct kobject *kobj, 1005 - struct bin_attribute *bin_attr, 1005 + const struct bin_attribute *bin_attr, 1006 1006 char *buf, loff_t off, size_t count) 1007 1007 { 1008 1008 struct device *dev = kobj_to_dev(kobj); ··· 1023 1023 return n; 1024 1024 } 1025 1025 1026 - static struct bin_attribute bridge_forward = { 1026 + static const struct bin_attribute bridge_forward = { 1027 1027 .attr = { .name = SYSFS_BRIDGE_FDB, 1028 1028 .mode = 0444, }, 1029 - .read = brforward_read, 1029 + .read_new = brforward_read, 1030 1030 }; 1031 1031 1032 1032 /*