mirror of
https://github.com/torvalds/linux.git
synced 2026-05-21 05:18:45 +02:00
platform/x86/intel/sdsi: 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@weissschuh.net> Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-pdx86-v1-3-9ab204c2a814@weissschuh.net Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
fbabd3dbb5
commit
b0034f206f
|
|
@ -398,8 +398,8 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count,
|
|||
}
|
||||
|
||||
static ssize_t provision_akc_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
const struct bin_attribute *attr, char *buf,
|
||||
loff_t off, size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct sdsi_priv *priv = dev_get_drvdata(dev);
|
||||
|
|
@ -409,11 +409,11 @@ static ssize_t provision_akc_write(struct file *filp, struct kobject *kobj,
|
|||
|
||||
return sdsi_provision(priv, buf, count, SDSI_CMD_PROVISION_AKC);
|
||||
}
|
||||
static BIN_ATTR_WO(provision_akc, SDSI_SIZE_WRITE_MSG);
|
||||
static const BIN_ATTR_WO(provision_akc, SDSI_SIZE_WRITE_MSG);
|
||||
|
||||
static ssize_t provision_cap_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
const struct bin_attribute *attr, char *buf,
|
||||
loff_t off, size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct sdsi_priv *priv = dev_get_drvdata(dev);
|
||||
|
|
@ -423,7 +423,7 @@ static ssize_t provision_cap_write(struct file *filp, struct kobject *kobj,
|
|||
|
||||
return sdsi_provision(priv, buf, count, SDSI_CMD_PROVISION_CAP);
|
||||
}
|
||||
static BIN_ATTR_WO(provision_cap, SDSI_SIZE_WRITE_MSG);
|
||||
static const BIN_ATTR_WO(provision_cap, SDSI_SIZE_WRITE_MSG);
|
||||
|
||||
static ssize_t
|
||||
certificate_read(u64 command, u64 control_flags, struct sdsi_priv *priv,
|
||||
|
|
@ -469,7 +469,7 @@ certificate_read(u64 command, u64 control_flags, struct sdsi_priv *priv,
|
|||
|
||||
static ssize_t
|
||||
state_certificate_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
const struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
|
|
@ -477,11 +477,11 @@ state_certificate_read(struct file *filp, struct kobject *kobj,
|
|||
|
||||
return certificate_read(SDSI_CMD_READ_STATE, 0, priv, buf, off, count);
|
||||
}
|
||||
static BIN_ATTR_ADMIN_RO(state_certificate, SDSI_SIZE_READ_MSG);
|
||||
static const BIN_ATTR_ADMIN_RO(state_certificate, SDSI_SIZE_READ_MSG);
|
||||
|
||||
static ssize_t
|
||||
meter_certificate_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
const struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
|
|
@ -489,11 +489,11 @@ meter_certificate_read(struct file *filp, struct kobject *kobj,
|
|||
|
||||
return certificate_read(SDSI_CMD_READ_METER, 0, priv, buf, off, count);
|
||||
}
|
||||
static BIN_ATTR_ADMIN_RO(meter_certificate, SDSI_SIZE_READ_MSG);
|
||||
static const BIN_ATTR_ADMIN_RO(meter_certificate, SDSI_SIZE_READ_MSG);
|
||||
|
||||
static ssize_t
|
||||
meter_current_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
const struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
|
|
@ -502,11 +502,11 @@ meter_current_read(struct file *filp, struct kobject *kobj,
|
|||
return certificate_read(SDSI_CMD_READ_METER, CTRL_METER_ENABLE_DRAM,
|
||||
priv, buf, off, count);
|
||||
}
|
||||
static BIN_ATTR_ADMIN_RO(meter_current, SDSI_SIZE_READ_MSG);
|
||||
static const BIN_ATTR_ADMIN_RO(meter_current, SDSI_SIZE_READ_MSG);
|
||||
|
||||
static ssize_t registers_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf, loff_t off,
|
||||
size_t count)
|
||||
const struct bin_attribute *attr, char *buf,
|
||||
loff_t off, size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct sdsi_priv *priv = dev_get_drvdata(dev);
|
||||
|
|
@ -528,9 +528,9 @@ static ssize_t registers_read(struct file *filp, struct kobject *kobj,
|
|||
|
||||
return count;
|
||||
}
|
||||
static BIN_ATTR_ADMIN_RO(registers, SDSI_SIZE_REGS);
|
||||
static const BIN_ATTR_ADMIN_RO(registers, SDSI_SIZE_REGS);
|
||||
|
||||
static struct bin_attribute *sdsi_bin_attrs[] = {
|
||||
static const struct bin_attribute *const sdsi_bin_attrs[] = {
|
||||
&bin_attr_registers,
|
||||
&bin_attr_state_certificate,
|
||||
&bin_attr_meter_certificate,
|
||||
|
|
@ -576,7 +576,7 @@ static struct attribute *sdsi_attrs[] = {
|
|||
|
||||
static const struct attribute_group sdsi_group = {
|
||||
.attrs = sdsi_attrs,
|
||||
.bin_attrs = sdsi_bin_attrs,
|
||||
.bin_attrs_new = sdsi_bin_attrs,
|
||||
.is_bin_visible = sdsi_battr_is_visible,
|
||||
};
|
||||
__ATTRIBUTE_GROUPS(sdsi);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user