* [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
@ 2024-09-04 1:15 Hongbo Li
2024-09-04 10:09 ` Naman Jain
2024-09-05 7:33 ` Wei Liu
0 siblings, 2 replies; 6+ messages in thread
From: Hongbo Li @ 2024-09-04 1:15 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv, lihongbo22
The `struct attribute_group` and `struct kobj_type` are not
modified, and they are only used in the helpers which take a
const type parameter.
Constifying these structure and moving them to a read-only section,
and this can increase over all security.
```
[Before]
text data bss dec hex filename
20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
[After]
text data bss dec hex filename
20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
```
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
drivers/hv/vmbus_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 7242c4920427..71fd8b97df33 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1831,12 +1831,12 @@ static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj,
return attr->mode;
}
-static struct attribute_group vmbus_chan_group = {
+static const struct attribute_group vmbus_chan_group = {
.attrs = vmbus_chan_attrs,
.is_visible = vmbus_chan_attr_is_visible
};
-static struct kobj_type vmbus_chan_ktype = {
+static const struct kobj_type vmbus_chan_ktype = {
.sysfs_ops = &vmbus_chan_sysfs_ops,
.release = vmbus_chan_release,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
2024-09-04 1:15 [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group Hongbo Li
@ 2024-09-04 10:09 ` Naman Jain
2024-09-04 10:18 ` Hongbo Li
2024-09-05 7:33 ` Wei Liu
1 sibling, 1 reply; 6+ messages in thread
From: Naman Jain @ 2024-09-04 10:09 UTC (permalink / raw)
To: Hongbo Li, kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv
On 9/4/2024 6:45 AM, Hongbo Li wrote:
> The `struct attribute_group` and `struct kobj_type` are not
> modified, and they are only used in the helpers which take a
> const type parameter.
>
> Constifying these structure and moving them to a read-only section,
> and this can increase over all security.
>
> ```
> [Before]
> text data bss dec hex filename
> 20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
>
> [After]
> text data bss dec hex filename
> 20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
> ```
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> drivers/hv/vmbus_drv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 7242c4920427..71fd8b97df33 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1831,12 +1831,12 @@ static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj,
> return attr->mode;
> }
>
> -static struct attribute_group vmbus_chan_group = {
> +static const struct attribute_group vmbus_chan_group = {
> .attrs = vmbus_chan_attrs,
> .is_visible = vmbus_chan_attr_is_visible
> };
>
> -static struct kobj_type vmbus_chan_ktype = {
> +static const struct kobj_type vmbus_chan_ktype = {
> .sysfs_ops = &vmbus_chan_sysfs_ops,
> .release = vmbus_chan_release,
> };
Small thing, I hope you included before and after logs in commit msg to
show that some of the data section moved to text as you made these
variables constant. If not, please move these after ---.
Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
Regards,
Naman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
2024-09-04 10:09 ` Naman Jain
@ 2024-09-04 10:18 ` Hongbo Li
2024-09-04 11:10 ` Naman Jain
0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-09-04 10:18 UTC (permalink / raw)
To: Naman Jain, kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv
On 2024/9/4 18:09, Naman Jain wrote:
>
>
> On 9/4/2024 6:45 AM, Hongbo Li wrote:
>> The `struct attribute_group` and `struct kobj_type` are not
>> modified, and they are only used in the helpers which take a
>> const type parameter.
>>
>> Constifying these structure and moving them to a read-only section,
>> and this can increase over all security.
>>
>> ```
>> [Before]
>> text data bss dec hex filename
>> 20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
>>
>> [After]
>> text data bss dec hex filename
>> 20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
>> ```
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>> drivers/hv/vmbus_drv.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
>> index 7242c4920427..71fd8b97df33 100644
>> --- a/drivers/hv/vmbus_drv.c
>> +++ b/drivers/hv/vmbus_drv.c
>> @@ -1831,12 +1831,12 @@ static umode_t
>> vmbus_chan_attr_is_visible(struct kobject *kobj,
>> return attr->mode;
>> }
>> -static struct attribute_group vmbus_chan_group = {
>> +static const struct attribute_group vmbus_chan_group = {
>> .attrs = vmbus_chan_attrs,
>> .is_visible = vmbus_chan_attr_is_visible
>> };
>> -static struct kobj_type vmbus_chan_ktype = {
>> +static const struct kobj_type vmbus_chan_ktype = {
>> .sysfs_ops = &vmbus_chan_sysfs_ops,
>> .release = vmbus_chan_release,
>> };
>
>
> Small thing, I hope you included before and after logs in commit msg to
> show that some of the data section moved to text as you made these
> variables constant. If not, please move these after ---.
>
You mean remove the '```' or move the whole part after --- ?
Thanks,
Hongbo
>
> Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
>
> Regards,
> Naman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
2024-09-04 10:18 ` Hongbo Li
@ 2024-09-04 11:10 ` Naman Jain
2024-09-05 1:14 ` Hongbo Li
0 siblings, 1 reply; 6+ messages in thread
From: Naman Jain @ 2024-09-04 11:10 UTC (permalink / raw)
To: Hongbo Li, kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv
On 9/4/2024 3:48 PM, Hongbo Li wrote:
>
>
> On 2024/9/4 18:09, Naman Jain wrote:
>>
>>
>> On 9/4/2024 6:45 AM, Hongbo Li wrote:
>>> The `struct attribute_group` and `struct kobj_type` are not
>>> modified, and they are only used in the helpers which take a
>>> const type parameter.
>>>
>>> Constifying these structure and moving them to a read-only section,
>>> and this can increase over all security.
>>>
>>> ```
>>> [Before]
>>> text data bss dec hex filename
>>> 20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
>>>
>>> [After]
>>> text data bss dec hex filename
>>> 20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
>>> ```
>>>
...
>>
>> Small thing, I hope you included before and after logs in commit msg to
>> show that some of the data section moved to text as you made these
>> variables constant. If not, please move these after ---.
>>
> You mean remove the '```' or move the whole part after --- ?
Never mind. IMO, mentioning these stats was really optional since we are
not saving any memory here. This could have been moved to the section
after --- so that it does not get captured in git log. However there's
no harm in keeping it where it is. So your call.
Regards,
Naman
>
> Thanks,
> Hongbo
>
>>
>> Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
>>
>> Regards,
>> Naman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
2024-09-04 11:10 ` Naman Jain
@ 2024-09-05 1:14 ` Hongbo Li
0 siblings, 0 replies; 6+ messages in thread
From: Hongbo Li @ 2024-09-05 1:14 UTC (permalink / raw)
To: Naman Jain, kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv
On 2024/9/4 19:10, Naman Jain wrote:
>
>
> On 9/4/2024 3:48 PM, Hongbo Li wrote:
>>
>>
>> On 2024/9/4 18:09, Naman Jain wrote:
>>>
>>>
>>> On 9/4/2024 6:45 AM, Hongbo Li wrote:
>>>> The `struct attribute_group` and `struct kobj_type` are not
>>>> modified, and they are only used in the helpers which take a
>>>> const type parameter.
>>>>
>>>> Constifying these structure and moving them to a read-only section,
>>>> and this can increase over all security.
>>>>
>>>> ```
>>>> [Before]
>>>> text data bss dec hex filename
>>>> 20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
>>>>
>>>> [After]
>>>> text data bss dec hex filename
>>>> 20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
>>>> ```
>>>>
>
> ...
>
>>>
>>> Small thing, I hope you included before and after logs in commit msg to
>>> show that some of the data section moved to text as you made these
>>> variables constant. If not, please move these after ---.
>>>
>> You mean remove the '```' or move the whole part after --- ?
>
> Never mind. IMO, mentioning these stats was really optional since we are
> not saving any memory here. This could have been moved to the section
> after --- so that it does not get captured in git log.
Thank you, I got it and have learned something.
Thanks,
Hongbo
However there's
> no harm in keeping it where it is. So your call.
>
>
> Regards,
> Naman
>
>>
>> Thanks,
>> Hongbo
>>
>>>
>>> Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
>>>
>>> Regards,
>>> Naman
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group
2024-09-04 1:15 [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group Hongbo Li
2024-09-04 10:09 ` Naman Jain
@ 2024-09-05 7:33 ` Wei Liu
1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2024-09-05 7:33 UTC (permalink / raw)
To: Hongbo Li; +Cc: kys, haiyangz, wei.liu, decui, linux-hyperv
On Wed, Sep 04, 2024 at 09:15:53AM +0800, Hongbo Li wrote:
> The `struct attribute_group` and `struct kobj_type` are not
> modified, and they are only used in the helpers which take a
> const type parameter.
>
> Constifying these structure and moving them to a read-only section,
> and this can increase over all security.
>
> ```
> [Before]
> text data bss dec hex filename
> 20568 4699 48 25315 62e3 drivers/hv/vmbus_drv.o
>
> [After]
> text data bss dec hex filename
> 20696 4571 48 25315 62e3 drivers/hv/vmbus_drv.o
> ```
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Applied to hyprev-fixes, thanks.
I massage the commit message a bit to make it more readable.
> ---
> drivers/hv/vmbus_drv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 7242c4920427..71fd8b97df33 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1831,12 +1831,12 @@ static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj,
> return attr->mode;
> }
>
> -static struct attribute_group vmbus_chan_group = {
> +static const struct attribute_group vmbus_chan_group = {
> .attrs = vmbus_chan_attrs,
> .is_visible = vmbus_chan_attr_is_visible
> };
>
> -static struct kobj_type vmbus_chan_ktype = {
> +static const struct kobj_type vmbus_chan_ktype = {
> .sysfs_ops = &vmbus_chan_sysfs_ops,
> .release = vmbus_chan_release,
> };
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-05 7:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 1:15 [PATCH -next] hv: vmbus: Constify struct kobj_type and struct attribute_group Hongbo Li
2024-09-04 10:09 ` Naman Jain
2024-09-04 10:18 ` Hongbo Li
2024-09-04 11:10 ` Naman Jain
2024-09-05 1:14 ` Hongbo Li
2024-09-05 7:33 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).