public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: hv: Constify 'struct bin_attribute'
@ 2025-06-09 11:05 Thomas Weißschuh
  2025-06-09 13:12 ` Naman Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2025-06-09 11:05 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui
  Cc: linux-hyperv, linux-kernel, Thomas Weißschuh

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 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 33b524b4eb5ef89d0111442a34d39874f02f0b70..38d2775dbe8730fd223d21188519b5f2b72e0804 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1845,7 +1845,7 @@ static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj,
 	return channel->mmap_ring_buffer(channel, vma);
 }
 
-static struct bin_attribute chan_attr_ring_buffer = {
+static const struct bin_attribute chan_attr_ring_buffer = {
 	.attr = {
 		.name = "ring",
 		.mode = 0600,
@@ -1871,7 +1871,7 @@ static struct attribute *vmbus_chan_attrs[] = {
 	NULL
 };
 
-static const struct bin_attribute *vmbus_chan_bin_attrs[] = {
+static const struct bin_attribute *const vmbus_chan_bin_attrs[] = {
 	&chan_attr_ring_buffer,
 	NULL
 };

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250609-sysfs-const-bin_attr-hv-135c9e53b325

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers: hv: Constify 'struct bin_attribute'
  2025-06-09 11:05 [PATCH] drivers: hv: Constify 'struct bin_attribute' Thomas Weißschuh
@ 2025-06-09 13:12 ` Naman Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Naman Jain @ 2025-06-09 13:12 UTC (permalink / raw)
  To: Thomas Weißschuh, K. Y. Srinivasan, Haiyang Zhang, Wei Liu,
	Dexuan Cui
  Cc: linux-hyperv, linux-kernel



On 6/9/2025 4:35 PM, Thomas Weißschuh wrote:
> The sysfs core now allows instances of 'struct bin_attribute' to be
> moved into read-only memory. Make use of that to protect them against
> accidental or malicious modifications.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>   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 33b524b4eb5ef89d0111442a34d39874f02f0b70..38d2775dbe8730fd223d21188519b5f2b72e0804 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1845,7 +1845,7 @@ static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj,
>   	return channel->mmap_ring_buffer(channel, vma);
>   }
>   
> -static struct bin_attribute chan_attr_ring_buffer = {
> +static const struct bin_attribute chan_attr_ring_buffer = {
>   	.attr = {
>   		.name = "ring",
>   		.mode = 0600,
> @@ -1871,7 +1871,7 @@ static struct attribute *vmbus_chan_attrs[] = {
>   	NULL
>   };
>   
> -static const struct bin_attribute *vmbus_chan_bin_attrs[] = {
> +static const struct bin_attribute *const vmbus_chan_bin_attrs[] = {
>   	&chan_attr_ring_buffer,
>   	NULL
>   };
> 
> ---
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
> change-id: 20250609-sysfs-const-bin_attr-hv-135c9e53b325
> 
> Best regards,

Hello Thomas,
There is a recent change which leads to a conflict with your change
on latest linux-next tip as it brings half of the functionality
from your patch.

"drivers: hv: fix up const issue with vmbus_chan_bin_attrs"

Can you please rebase this.

The other part LGTM, considering you recently got this change
merged: "sysfs: constify attribute_group::bin_attrs"

Regards,
Naman

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-09 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 11:05 [PATCH] drivers: hv: Constify 'struct bin_attribute' Thomas Weißschuh
2025-06-09 13:12 ` Naman Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox