Skip to content

Commit 27a8204

Browse files
Hongbo Liawilliam
authored andcommitted
vfio/mdev: Constify struct kobj_type
This 'struct kobj_type' is not modified. It is only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter. Constifying this structure and moving it to a read-only section, and this can increase over all security. ``` [Before] text data bss dec hex filename 2372 600 0 2972 b9c drivers/vfio/mdev/mdev_sysfs.o [After] text data bss dec hex filename 2436 568 0 3004 bbc drivers/vfio/mdev/mdev_sysfs.o ``` Signed-off-by: Hongbo Li <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 7555c7d commit 27a8204

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vfio/mdev/mdev_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void mdev_type_release(struct kobject *kobj)
160160
put_device(type->parent->dev);
161161
}
162162

163-
static struct kobj_type mdev_type_ktype = {
163+
static const struct kobj_type mdev_type_ktype = {
164164
.sysfs_ops = &mdev_type_sysfs_ops,
165165
.release = mdev_type_release,
166166
.default_groups = mdev_type_groups,

0 commit comments

Comments
 (0)