From: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Stuart Hayes" <stuart.w.hayes@gmail.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"David E. Box" <david.e.box@linux.intel.com>,
"Naveen Krishna Chatradhi" <naveenkrishna.chatradhi@amd.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] platform/x86/amd/hsmp: Constify 'struct bin_attribute'
Date: Thu, 2 Jan 2025 15:36:01 -0600 [thread overview]
Message-ID: <ae2a0dfd-1b84-4b3d-ae25-5f1992c2a71a@gmail.com> (raw)
In-Reply-To: <20241202-sysfs-const-bin_attr-pdx86-v1-5-9ab204c2a814@weissschuh.net>
On 12/2/24 13:38, 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/platform/x86/amd/hsmp/acpi.c | 12 ++++++------
> drivers/platform/x86/amd/hsmp/plat.c | 12 ++++++------
> 2 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
> index dd5b5773328a9aff376a389cbd0109cb8cf0e385..7d802bfe206c73a4570dcd3752faee853bb81485 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -226,7 +226,7 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind)
> }
>
> static ssize_t hsmp_metric_tbl_acpi_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 device *dev = container_of(kobj, struct device, kobj);
> @@ -285,19 +285,19 @@ static int init_acpi(struct device *dev)
> return ret;
> }
>
> -static struct bin_attribute hsmp_metric_tbl_attr = {
> +static const struct bin_attribute hsmp_metric_tbl_attr = {
> .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444},
> - .read = hsmp_metric_tbl_acpi_read,
> + .read_new = hsmp_metric_tbl_acpi_read,
> .size = sizeof(struct hsmp_metric_table),
> };
>
> -static struct bin_attribute *hsmp_attr_list[] = {
> +static const struct bin_attribute *hsmp_attr_list[] = {
> &hsmp_metric_tbl_attr,
> NULL
> };
>
> -static struct attribute_group hsmp_attr_grp = {
> - .bin_attrs = hsmp_attr_list,
> +static const struct attribute_group hsmp_attr_grp = {
> + .bin_attrs_new = hsmp_attr_list,
> .is_bin_visible = hsmp_is_sock_attr_visible,
> };
>
> diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c
> index 748bbc35648474370275a80daf2c26e5d732f6ad..1fdcd65d398e6ceca154b804074cbba083f4b7f1 100644
> --- a/drivers/platform/x86/amd/hsmp/plat.c
> +++ b/drivers/platform/x86/amd/hsmp/plat.c
> @@ -59,7 +59,7 @@ static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset,
> }
>
> static ssize_t hsmp_metric_tbl_plat_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 hsmp_socket *sock;
> @@ -97,13 +97,13 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
> * is_bin_visible function is used to show / hide the necessary groups.
> */
> #define HSMP_BIN_ATTR(index, _list) \
> -static struct bin_attribute attr##index = { \
> +static const struct bin_attribute attr##index = { \
> .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444}, \
> .private = (void *)index, \
> - .read = hsmp_metric_tbl_plat_read, \
> + .read_new = hsmp_metric_tbl_plat_read, \
> .size = sizeof(struct hsmp_metric_table), \
> }; \
> -static struct bin_attribute _list[] = { \
> +static const struct bin_attribute _list[] = { \
> &attr##index, \
> NULL \
> }
> @@ -118,8 +118,8 @@ HSMP_BIN_ATTR(6, *sock6_attr_list);
> HSMP_BIN_ATTR(7, *sock7_attr_list);
>
> #define HSMP_BIN_ATTR_GRP(index, _list, _name) \
> -static struct attribute_group sock##index##_attr_grp = { \
> - .bin_attrs = _list, \
> +static const struct attribute_group sock##index##_attr_grp = { \
> + .bin_attrs_new = _list, \
> .is_bin_visible = hsmp_is_sock_attr_visible, \
> .name = #_name, \
> }
Acked-by: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
>
next prev parent reply other threads:[~2025-01-02 21:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 19:38 [PATCH 0/5] platform/x86: " Thomas Weißschuh
2024-12-02 19:38 ` [PATCH 1/5] platform/x86: dell: dcdbas: " Thomas Weißschuh
2024-12-02 19:38 ` [PATCH 2/5] platform/x86: dell_rbu: " Thomas Weißschuh
2024-12-02 19:38 ` [PATCH 3/5] platform/x86/intel/sdsi: " Thomas Weißschuh
2024-12-02 19:38 ` [PATCH 4/5] platform/x86/intel/pmt: " Thomas Weißschuh
2024-12-02 19:38 ` [PATCH 5/5] platform/x86/amd/hsmp: " Thomas Weißschuh
2024-12-19 14:59 ` Chatradhi, Naveen Krishna
2025-01-02 21:36 ` Carlos Bilbao [this message]
2024-12-12 14:47 ` [PATCH 0/5] platform/x86: " Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae2a0dfd-1b84-4b3d-ae25-5f1992c2a71a@gmail.com \
--to=carlos.bilbao.osdev@gmail.com \
--cc=david.e.box@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stuart.w.hayes@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome