Skip to content

Commit

Permalink
usbip: vudc: Constify 'struct bin_attribute'
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20241222-sysfs-const-bin_attr-usbip-v1-1-20d611a9bfa4@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Thomas Weißschuh authored and Greg Kroah-Hartman committed Dec 24, 2024
1 parent aa13b9d commit 997a6e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/usb/usbip/vudc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int get_gadget_descs(struct vudc *udc)
* Exposes device descriptor from the gadget driver.
*/
static ssize_t dev_desc_read(struct file *file, struct kobject *kobj,
struct bin_attribute *attr, char *out,
const struct bin_attribute *attr, char *out,
loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
Expand All @@ -88,7 +88,7 @@ static ssize_t dev_desc_read(struct file *file, struct kobject *kobj,
spin_unlock_irqrestore(&udc->lock, flags);
return ret;
}
static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor));
static const BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor));

static ssize_t usbip_sockfd_store(struct device *dev,
struct device_attribute *attr,
Expand Down Expand Up @@ -252,14 +252,14 @@ static struct attribute *dev_attrs[] = {
NULL,
};

static struct bin_attribute *dev_bin_attrs[] = {
static const struct bin_attribute *const dev_bin_attrs[] = {
&bin_attr_dev_desc,
NULL,
};

static const struct attribute_group vudc_attr_group = {
.attrs = dev_attrs,
.bin_attrs = dev_bin_attrs,
.bin_attrs_new = dev_bin_attrs,
};

const struct attribute_group *vudc_groups[] = {
Expand Down

0 comments on commit 997a6e1

Please sign in to comment.