* [PATCH] block/rnbd: Constify struct kobj_type
@ 2024-07-08 18:11 Christophe JAILLET
2024-07-09 0:54 ` Chaitanya Kulkarni
2024-07-09 17:52 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-07-08 18:11 UTC (permalink / raw)
To: Md. Haris Iqbal, Jack Wang, Jens Axboe
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-block
'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 <christophe.jaillet@wanadoo.fr>
---
Compile tested-only
---
drivers/block/rnbd/rnbd-clt-sysfs.c | 2 +-
drivers/block/rnbd/rnbd-srv-sysfs.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index 39887556cf95..6ea7c12e3a87 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -475,7 +475,7 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
}
}
-static struct kobj_type rnbd_dev_ktype = {
+static const struct kobj_type rnbd_dev_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
.default_groups = rnbd_dev_groups,
};
diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c
index cba6ba43c2c2..64780094442c 100644
--- a/drivers/block/rnbd/rnbd-srv-sysfs.c
+++ b/drivers/block/rnbd/rnbd-srv-sysfs.c
@@ -33,7 +33,7 @@ static void rnbd_srv_dev_release(struct kobject *kobj)
kfree(dev);
}
-static struct kobj_type dev_ktype = {
+static const struct kobj_type dev_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
.release = rnbd_srv_dev_release
};
@@ -184,7 +184,7 @@ static void rnbd_srv_sess_dev_release(struct kobject *kobj)
rnbd_destroy_sess_dev(sess_dev, sess_dev->keep_id);
}
-static struct kobj_type rnbd_srv_sess_dev_ktype = {
+static const struct kobj_type rnbd_srv_sess_dev_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
.release = rnbd_srv_sess_dev_release,
};
--
2.45.2
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] block/rnbd: Constify struct kobj_type
2024-07-08 18:11 [PATCH] block/rnbd: Constify struct kobj_type Christophe JAILLET
@ 2024-07-09 0:54 ` Chaitanya Kulkarni
2024-07-09 17:52 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-07-09 0:54 UTC (permalink / raw)
To: Christophe JAILLET, Md. Haris Iqbal, Jack Wang, Jens Axboe
Cc: linux-kernel, kernel-janitors, linux-block
On 7/8/2024 11:11 AM, Christophe JAILLET wrote:
> '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<christophe.jaillet@wanadoo.fr>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block/rnbd: Constify struct kobj_type
2024-07-08 18:11 [PATCH] block/rnbd: Constify struct kobj_type Christophe JAILLET
2024-07-09 0:54 ` Chaitanya Kulkarni
@ 2024-07-09 17:52 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2024-07-09 17:52 UTC (permalink / raw)
To: Md. Haris Iqbal, Jack Wang, Christophe JAILLET
Cc: linux-kernel, kernel-janitors, linux-block
On Mon, 08 Jul 2024 20:11:30 +0200, Christophe JAILLET wrote:
> '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
>
> [...]
Applied, thanks!
[1/1] block/rnbd: Constify struct kobj_type
commit: e4eaca5e30c55c83c547974188afc2b2d02d4f0c
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-09 17:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-08 18:11 [PATCH] block/rnbd: Constify struct kobj_type Christophe JAILLET
2024-07-09 0:54 ` Chaitanya Kulkarni
2024-07-09 17:52 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®