@@ -143,7 +143,7 @@ static struct attribute *pci_instance_attrs[] = {
ATTRIBUTE_GROUPS(pci_instance);
/* the ktype for a pci instance */
-static struct kobj_type ktype_pci_instance = {
+static const struct kobj_type ktype_pci_instance = {
.release = edac_pci_instance_release,
.sysfs_ops = &pci_instance_ops,
.default_groups = pci_instance_groups,
@@ -326,7 +326,7 @@ static void edac_pci_release_main_kobj(struct kobject *kobj)
}
/* ktype struct for the EDAC PCI main kobj */
-static struct kobj_type ktype_edac_pci_main_kobj = {
+static const struct kobj_type ktype_edac_pci_main_kobj = {
.release = edac_pci_release_main_kobj,
.sysfs_ops = &edac_pci_sysfs_ops,
.default_groups = edac_pci_groups,
These 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter. Constifying these structure (ktype_pci_instance and ktype_edac_pci_main_kobj)and moving them to a read-only (text section) section, and can increase over all security. ``` [Before] text data bss dec hex filename 4357 856 32 5245 147d drivers/edac/edac_pci_sysfs.o [After] text data bss dec hex filename 4485 760 32 5277 149d drivers/edac/edac_pci_sysfs.o ``` Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/edac/edac_pci_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)