* [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id
@ 2024-09-08 6:52 Christophe JAILLET
2024-09-09 18:54 ` Andi Shyti
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2024-09-08 6:52 UTC (permalink / raw)
To: Viresh Kumar, Chen, Jian Jun, Andi Shyti
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-i2c,
virtualization
'struct i2c_algorithm' and 'struct virtio_device_id' are not modified in
this driver.
Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers, which is the case for struct i2c_algorithm.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
6663 568 16 7247 1c4f drivers/i2c/busses/i2c-virtio.o
After:
=====
text data bss dec hex filename
6735 472 16 7223 1c37 drivers/i2c/busses/i2c-virtio.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
--
Compile tested only
---
drivers/i2c/busses/i2c-virtio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c
index 52ba1e0845ca..2a351f961b89 100644
--- a/drivers/i2c/busses/i2c-virtio.c
+++ b/drivers/i2c/busses/i2c-virtio.c
@@ -182,7 +182,7 @@ static u32 virtio_i2c_func(struct i2c_adapter *adap)
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
}
-static struct i2c_algorithm virtio_algorithm = {
+static const struct i2c_algorithm virtio_algorithm = {
.xfer = virtio_i2c_xfer,
.functionality = virtio_i2c_func,
};
@@ -237,7 +237,7 @@ static void virtio_i2c_remove(struct virtio_device *vdev)
virtio_i2c_del_vqs(vdev);
}
-static struct virtio_device_id id_table[] = {
+static const struct virtio_device_id id_table[] = {
{ VIRTIO_ID_I2C_ADAPTER, VIRTIO_DEV_ANY_ID },
{}
};
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id
2024-09-08 6:52 [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id Christophe JAILLET
@ 2024-09-09 18:54 ` Andi Shyti
2024-09-09 19:38 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Andi Shyti @ 2024-09-09 18:54 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Viresh Kumar, Chen, Jian Jun, linux-kernel, kernel-janitors,
linux-i2c, virtualization
Hi Christophe,
On Sun, Sep 08, 2024 at 08:52:07AM GMT, Christophe JAILLET wrote:
> 'struct i2c_algorithm' and 'struct virtio_device_id' are not modified in
> this driver.
>
> Constifying this structure moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers, which is the case for struct i2c_algorithm.
>
> On a x86_64, with allmodconfig:
> Before:
> ======
> text data bss dec hex filename
> 6663 568 16 7247 1c4f drivers/i2c/busses/i2c-virtio.o
>
> After:
> =====
> text data bss dec hex filename
> 6735 472 16 7223 1c37 drivers/i2c/busses/i2c-virtio.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> --
> Compile tested only
Makes sense to me... if this works, you could pioneer a sequence
of simiar changes :-)
Merged to i2c/i2c-host.
Thanks,
Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id
2024-09-09 18:54 ` Andi Shyti
@ 2024-09-09 19:38 ` Christophe JAILLET
0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-09-09 19:38 UTC (permalink / raw)
To: Andi Shyti
Cc: Viresh Kumar, Chen, Jian Jun, linux-kernel, kernel-janitors,
linux-i2c, virtualization
Le 09/09/2024 à 20:54, Andi Shyti a écrit :
> Hi Christophe,
>
> On Sun, Sep 08, 2024 at 08:52:07AM GMT, Christophe JAILLET wrote:
>> 'struct i2c_algorithm' and 'struct virtio_device_id' are not modified in
>> this driver.
>>
>> Constifying this structure moves some data to a read-only section, so
>> increase overall security, especially when the structure holds some
>> function pointers, which is the case for struct i2c_algorithm.
>>
>> On a x86_64, with allmodconfig:
>> Before:
>> ======
>> text data bss dec hex filename
>> 6663 568 16 7247 1c4f drivers/i2c/busses/i2c-virtio.o
>>
>> After:
>> =====
>> text data bss dec hex filename
>> 6735 472 16 7223 1c37 drivers/i2c/busses/i2c-virtio.o
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> --
>> Compile tested only
>
> Makes sense to me... if this works, you could pioneer a sequence
> of simiar changes :-)
Hi,
I already did some other ones [1]. A few more still need to be checked.
I'll finish it after ending struct regulator_desc that I'm currently
looking at. [2]
[1]: https://lore.kernel.org/all/?q=%22Constify+struct+i2c_algorithm%22
[2]: https://lore.kernel.org/all/?q=%22Constify+struct+regulator_desc%22
>
> Merged to i2c/i2c-host.
Thanks.
CJ
>
> Thanks,
> Andi
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-09 19:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-08 6:52 [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id Christophe JAILLET
2024-09-09 18:54 ` Andi Shyti
2024-09-09 19:38 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox