Skip to content

Commit e4eaca5

Browse files
tititiou36axboe
authored andcommitted
block/rnbd: Constify struct kobj_type
'struct kobj_type' is not modified in this driver. It is only used with kobject_init_and_add() which takes a "const struct kobj_type *" parameter. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 4082 792 8 4882 1312 drivers/block/rnbd/rnbd-srv-sysfs.o After: ===== text data bss dec hex filename 4210 672 8 4890 131a drivers/block/rnbd/rnbd-srv-sysfs.o Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/e3d454173ffad30726c9351810d3aa7b75122711.1720462252.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jens Axboe <[email protected]>
1 parent 61353a6 commit e4eaca5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/block/rnbd/rnbd-clt-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
475475
}
476476
}
477477

478-
static struct kobj_type rnbd_dev_ktype = {
478+
static const struct kobj_type rnbd_dev_ktype = {
479479
.sysfs_ops = &kobj_sysfs_ops,
480480
.default_groups = rnbd_dev_groups,
481481
};

drivers/block/rnbd/rnbd-srv-sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void rnbd_srv_dev_release(struct kobject *kobj)
3333
kfree(dev);
3434
}
3535

36-
static struct kobj_type dev_ktype = {
36+
static const struct kobj_type dev_ktype = {
3737
.sysfs_ops = &kobj_sysfs_ops,
3838
.release = rnbd_srv_dev_release
3939
};
@@ -184,7 +184,7 @@ static void rnbd_srv_sess_dev_release(struct kobject *kobj)
184184
rnbd_destroy_sess_dev(sess_dev, sess_dev->keep_id);
185185
}
186186

187-
static struct kobj_type rnbd_srv_sess_dev_ktype = {
187+
static const struct kobj_type rnbd_srv_sess_dev_ktype = {
188188
.sysfs_ops = &kobj_sysfs_ops,
189189
.release = rnbd_srv_sess_dev_release,
190190
};

0 commit comments

Comments
 (0)