Skip to content

Commit 7509c23

Browse files
hsiaoh2mpe
authored andcommitted
powerpc: Constify struct kobj_type
'struct kobj_type' is not modified. It is only used in kobject_init_and_add()/kobject_init() which takes a 'const struct kobj_type *ktype' parameter. Constifying this structure moves some data to a read-only section, so increase over all security. On a x86_64, compiled with ppc64 defconfig: Before: ====== text data bss dec hex filename 7145 606 0 7751 1e47 arch/powerpc/kernel/cacheinfo.o 3663 384 16 4063 fdf arch/powerpc/kernel/secvar-sysfs.o After: ====== text data bss dec hex filename 7193 558 0 7751 1e47 arch/powerpc/kernel/cacheinfo.o 3663 384 16 4063 fdf arch/powerpc/kernel/secvar-sysfs.o Signed-off-by: Huang Xiaojia <huangxiaojia2@huawei.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240826150957.3500237-1-huangxiaojia2@huawei.com
1 parent 02b98ff commit 7509c23

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

arch/powerpc/kernel/cacheinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static const struct sysfs_ops cache_index_ops = {
735735
.show = cache_index_show,
736736
};
737737

738-
static struct kobj_type cache_index_type = {
738+
static const struct kobj_type cache_index_type = {
739739
.release = cache_index_release,
740740
.sysfs_ops = &cache_index_ops,
741741
.default_groups = cache_index_default_groups,

arch/powerpc/kernel/secvar-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static const struct attribute_group secvar_attr_group = {
125125
};
126126
__ATTRIBUTE_GROUPS(secvar_attr);
127127

128-
static struct kobj_type secvar_ktype = {
128+
static const struct kobj_type secvar_ktype = {
129129
.sysfs_ops = &kobj_sysfs_ops,
130130
.default_groups = secvar_attr_groups,
131131
};

0 commit comments

Comments
 (0)