* [PATCH net-next] ptp: ocp: constify 'struct bin_attribute'
@ 2024-12-22 20:08 Thomas Weißschuh
2024-12-24 11:17 ` Vadim Fedorenko
2025-01-03 1:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2024-12-22 20:08 UTC (permalink / raw)
To: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, 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/ptp/ptp_ocp.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 5feecaadde8e05a2a2bb462094434e47e5336400..7f08c70d81230530fda459eefa9b7098dcbba79f 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -3692,7 +3692,7 @@ DEVICE_FREQ_GROUP(freq4, 3);
static ssize_t
disciplining_config_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3727,7 +3727,7 @@ disciplining_config_read(struct file *filp, struct kobject *kobj,
static ssize_t
disciplining_config_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3750,11 +3750,11 @@ disciplining_config_write(struct file *filp, struct kobject *kobj,
return err;
}
-static BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
+static const BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
static ssize_t
temperature_table_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3789,7 +3789,7 @@ temperature_table_read(struct file *filp, struct kobject *kobj,
static ssize_t
temperature_table_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf,
+ const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3812,7 +3812,7 @@ temperature_table_write(struct file *filp, struct kobject *kobj,
return err;
}
-static BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
+static const BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
static struct attribute *fb_timecard_attrs[] = {
&dev_attr_serialnum.attr,
@@ -3867,7 +3867,7 @@ static struct attribute *art_timecard_attrs[] = {
NULL,
};
-static struct bin_attribute *bin_art_timecard_attrs[] = {
+static const struct bin_attribute *const bin_art_timecard_attrs[] = {
&bin_attr_disciplining_config,
&bin_attr_temperature_table,
NULL,
@@ -3875,7 +3875,7 @@ static struct bin_attribute *bin_art_timecard_attrs[] = {
static const struct attribute_group art_timecard_group = {
.attrs = art_timecard_attrs,
- .bin_attrs = bin_art_timecard_attrs,
+ .bin_attrs_new = bin_art_timecard_attrs,
};
static const struct ocp_attr_group art_timecard_groups[] = {
---
base-commit: bcde95ce32b666478d6737219caa4f8005a8f201
change-id: 20241222-sysfs-const-bin_attr-ptp-7aec7d5332a8
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ptp: ocp: constify 'struct bin_attribute'
2024-12-22 20:08 [PATCH net-next] ptp: ocp: constify 'struct bin_attribute' Thomas Weißschuh
@ 2024-12-24 11:17 ` Vadim Fedorenko
2025-01-03 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2024-12-24 11:17 UTC (permalink / raw)
To: Thomas Weißschuh, Richard Cochran, Jonathan Lemon,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-kernel
On 22/12/2024 20:08, 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>
Thanks!
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
> drivers/ptp/ptp_ocp.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 5feecaadde8e05a2a2bb462094434e47e5336400..7f08c70d81230530fda459eefa9b7098dcbba79f 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -3692,7 +3692,7 @@ DEVICE_FREQ_GROUP(freq4, 3);
>
> static ssize_t
> disciplining_config_read(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr, char *buf,
> + const struct bin_attribute *bin_attr, char *buf,
> loff_t off, size_t count)
> {
> struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
> @@ -3727,7 +3727,7 @@ disciplining_config_read(struct file *filp, struct kobject *kobj,
>
> static ssize_t
> disciplining_config_write(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr, char *buf,
> + const struct bin_attribute *bin_attr, char *buf,
> loff_t off, size_t count)
> {
> struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
> @@ -3750,11 +3750,11 @@ disciplining_config_write(struct file *filp, struct kobject *kobj,
>
> return err;
> }
> -static BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
> +static const BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
>
> static ssize_t
> temperature_table_read(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr, char *buf,
> + const struct bin_attribute *bin_attr, char *buf,
> loff_t off, size_t count)
> {
> struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
> @@ -3789,7 +3789,7 @@ temperature_table_read(struct file *filp, struct kobject *kobj,
>
> static ssize_t
> temperature_table_write(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr, char *buf,
> + const struct bin_attribute *bin_attr, char *buf,
> loff_t off, size_t count)
> {
> struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
> @@ -3812,7 +3812,7 @@ temperature_table_write(struct file *filp, struct kobject *kobj,
>
> return err;
> }
> -static BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
> +static const BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
>
> static struct attribute *fb_timecard_attrs[] = {
> &dev_attr_serialnum.attr,
> @@ -3867,7 +3867,7 @@ static struct attribute *art_timecard_attrs[] = {
> NULL,
> };
>
> -static struct bin_attribute *bin_art_timecard_attrs[] = {
> +static const struct bin_attribute *const bin_art_timecard_attrs[] = {
> &bin_attr_disciplining_config,
> &bin_attr_temperature_table,
> NULL,
> @@ -3875,7 +3875,7 @@ static struct bin_attribute *bin_art_timecard_attrs[] = {
>
> static const struct attribute_group art_timecard_group = {
> .attrs = art_timecard_attrs,
> - .bin_attrs = bin_art_timecard_attrs,
> + .bin_attrs_new = bin_art_timecard_attrs,
> };
>
> static const struct ocp_attr_group art_timecard_groups[] = {
>
> ---
> base-commit: bcde95ce32b666478d6737219caa4f8005a8f201
> change-id: 20241222-sysfs-const-bin_attr-ptp-7aec7d5332a8
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ptp: ocp: constify 'struct bin_attribute'
2024-12-22 20:08 [PATCH net-next] ptp: ocp: constify 'struct bin_attribute' Thomas Weißschuh
2024-12-24 11:17 ` Vadim Fedorenko
@ 2025-01-03 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-03 1:20 UTC (permalink / raw)
To: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=3Clinux=40weissschuh=2Enet=3E?=
Cc: richardcochran, jonathan.lemon, vadim.fedorenko, andrew+netdev,
davem, edumazet, kuba, pabeni, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 22 Dec 2024 21:08:20 +0100 you 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/ptp/ptp_ocp.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> [...]
Here is the summary with links:
- [net-next] ptp: ocp: constify 'struct bin_attribute'
https://git.kernel.org/netdev/net-next/c/be16b46f9ebd
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-03 1:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-22 20:08 [PATCH net-next] ptp: ocp: constify 'struct bin_attribute' Thomas Weißschuh
2024-12-24 11:17 ` Vadim Fedorenko
2025-01-03 1:20 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.