mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
s390/crypto/cpacf: 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> Tested-by: Finn Callies <fcallies@linux.ibm.com> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Link: https://lore.kernel.org/r/20241211-sysfs-const-bin_attr-s390-v1-1-be01f66bfcf7@weissschuh.net Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
This commit is contained in:
parent
30e037ad7e
commit
221ce94b1a
1 changed files with 18 additions and 18 deletions
|
|
@ -14,7 +14,7 @@
|
||||||
#define CPACF_QUERY(name, instruction) \
|
#define CPACF_QUERY(name, instruction) \
|
||||||
static ssize_t name##_query_raw_read(struct file *fp, \
|
static ssize_t name##_query_raw_read(struct file *fp, \
|
||||||
struct kobject *kobj, \
|
struct kobject *kobj, \
|
||||||
struct bin_attribute *attr, \
|
const struct bin_attribute *attr, \
|
||||||
char *buf, loff_t offs, \
|
char *buf, loff_t offs, \
|
||||||
size_t count) \
|
size_t count) \
|
||||||
{ \
|
{ \
|
||||||
|
|
@ -24,7 +24,7 @@ static ssize_t name##_query_raw_read(struct file *fp, \
|
||||||
return -EOPNOTSUPP; \
|
return -EOPNOTSUPP; \
|
||||||
return memory_read_from_buffer(buf, count, &offs, &mask, sizeof(mask)); \
|
return memory_read_from_buffer(buf, count, &offs, &mask, sizeof(mask)); \
|
||||||
} \
|
} \
|
||||||
static BIN_ATTR_RO(name##_query_raw, sizeof(cpacf_mask_t))
|
static const BIN_ATTR_RO(name##_query_raw, sizeof(cpacf_mask_t))
|
||||||
|
|
||||||
CPACF_QUERY(km, KM);
|
CPACF_QUERY(km, KM);
|
||||||
CPACF_QUERY(kmc, KMC);
|
CPACF_QUERY(kmc, KMC);
|
||||||
|
|
@ -40,20 +40,20 @@ CPACF_QUERY(prno, PRNO);
|
||||||
CPACF_QUERY(kma, KMA);
|
CPACF_QUERY(kma, KMA);
|
||||||
CPACF_QUERY(kdsa, KDSA);
|
CPACF_QUERY(kdsa, KDSA);
|
||||||
|
|
||||||
#define CPACF_QAI(name, instruction) \
|
#define CPACF_QAI(name, instruction) \
|
||||||
static ssize_t name##_query_auth_info_raw_read( \
|
static ssize_t name##_query_auth_info_raw_read( \
|
||||||
struct file *fp, struct kobject *kobj, \
|
struct file *fp, struct kobject *kobj, \
|
||||||
struct bin_attribute *attr, char *buf, loff_t offs, \
|
const struct bin_attribute *attr, char *buf, loff_t offs, \
|
||||||
size_t count) \
|
size_t count) \
|
||||||
{ \
|
{ \
|
||||||
cpacf_qai_t qai; \
|
cpacf_qai_t qai; \
|
||||||
\
|
\
|
||||||
if (!cpacf_qai(CPACF_##instruction, &qai)) \
|
if (!cpacf_qai(CPACF_##instruction, &qai)) \
|
||||||
return -EOPNOTSUPP; \
|
return -EOPNOTSUPP; \
|
||||||
return memory_read_from_buffer(buf, count, &offs, &qai, \
|
return memory_read_from_buffer(buf, count, &offs, &qai, \
|
||||||
sizeof(qai)); \
|
sizeof(qai)); \
|
||||||
} \
|
} \
|
||||||
static BIN_ATTR_RO(name##_query_auth_info_raw, sizeof(cpacf_qai_t))
|
static const BIN_ATTR_RO(name##_query_auth_info_raw, sizeof(cpacf_qai_t))
|
||||||
|
|
||||||
CPACF_QAI(km, KM);
|
CPACF_QAI(km, KM);
|
||||||
CPACF_QAI(kmc, KMC);
|
CPACF_QAI(kmc, KMC);
|
||||||
|
|
@ -69,7 +69,7 @@ CPACF_QAI(prno, PRNO);
|
||||||
CPACF_QAI(kma, KMA);
|
CPACF_QAI(kma, KMA);
|
||||||
CPACF_QAI(kdsa, KDSA);
|
CPACF_QAI(kdsa, KDSA);
|
||||||
|
|
||||||
static struct bin_attribute *cpacf_attrs[] = {
|
static const struct bin_attribute *const cpacf_attrs[] = {
|
||||||
&bin_attr_km_query_raw,
|
&bin_attr_km_query_raw,
|
||||||
&bin_attr_kmc_query_raw,
|
&bin_attr_kmc_query_raw,
|
||||||
&bin_attr_kimd_query_raw,
|
&bin_attr_kimd_query_raw,
|
||||||
|
|
@ -101,7 +101,7 @@ static struct bin_attribute *cpacf_attrs[] = {
|
||||||
|
|
||||||
static const struct attribute_group cpacf_attr_grp = {
|
static const struct attribute_group cpacf_attr_grp = {
|
||||||
.name = "cpacf",
|
.name = "cpacf",
|
||||||
.bin_attrs = cpacf_attrs,
|
.bin_attrs_new = cpacf_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init cpacf_init(void)
|
static int __init cpacf_init(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue