From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH v2 6/6] module: sysfs: Use const 'struct bin_attribute'
Date: Fri, 27 Dec 2024 14:23:25 +0100 [thread overview]
Message-ID: <20241227-sysfs-const-bin_attr-module-v2-6-e267275f0f37@weissschuh.net> (raw)
In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net>
The sysfs core is switching to 'const struct bin_attribute's.
Prepare for that.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index d04cb12eac7be63dd0bb65bd55e97280e7875e4e..853745e353381204161541c6f29bf97c42ec6df3 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -26,7 +26,7 @@ struct module_sect_attrs {
#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4))
static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
- struct bin_attribute *battr,
+ const struct bin_attribute *battr,
char *buf, loff_t pos, size_t count)
{
char bounce[MODULE_SECT_READ_SIZE + 1];
@@ -54,18 +54,18 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
{
- struct bin_attribute **bin_attr;
+ const struct bin_attribute *const *bin_attr;
- for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++)
+ for (bin_attr = sect_attrs->grp.bin_attrs_new; *bin_attr; bin_attr++)
kfree((*bin_attr)->attr.name);
- kfree(sect_attrs->grp.bin_attrs);
+ kfree(sect_attrs->grp.bin_attrs_new);
kfree(sect_attrs);
}
static int add_sect_attrs(struct module *mod, const struct load_info *info)
{
struct module_sect_attrs *sect_attrs;
- struct bin_attribute **gattr;
+ const struct bin_attribute **gattr;
struct bin_attribute *sattr;
unsigned int nloaded = 0, i;
int ret;
@@ -86,7 +86,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
/* Setup section attributes. */
sect_attrs->grp.name = "sections";
- sect_attrs->grp.bin_attrs = gattr;
+ sect_attrs->grp.bin_attrs_new = gattr;
sattr = §_attrs->attrs[0];
for (i = 0; i < info->hdr->e_shnum; i++) {
@@ -101,7 +101,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
ret = -ENOMEM;
goto out;
}
- sattr->read = module_sect_read;
+ sattr->read_new = module_sect_read;
sattr->private = (void *)sec->sh_addr;
sattr->size = MODULE_SECT_READ_SIZE;
sattr->attr.mode = 0400;
@@ -144,7 +144,7 @@ struct module_notes_attrs {
static void free_notes_attrs(struct module_notes_attrs *notes_attrs)
{
- kfree(notes_attrs->grp.bin_attrs);
+ kfree(notes_attrs->grp.bin_attrs_new);
kfree(notes_attrs);
}
@@ -152,7 +152,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
{
unsigned int notes, loaded, i;
struct module_notes_attrs *notes_attrs;
- struct bin_attribute **gattr;
+ const struct bin_attribute **gattr;
struct bin_attribute *nattr;
int ret;
@@ -178,7 +178,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
}
notes_attrs->grp.name = "notes";
- notes_attrs->grp.bin_attrs = gattr;
+ notes_attrs->grp.bin_attrs_new = gattr;
nattr = ¬es_attrs->attrs[0];
for (loaded = i = 0; i < info->hdr->e_shnum; ++i) {
--
2.47.1
next prev parent reply other threads:[~2024-12-27 13:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-27 13:23 [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 1/6] module: sysfs: Drop member 'module_sect_attrs::nsections' Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 2/6] module: sysfs: Drop member 'module_sect_attr::address' Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 3/6] module: sysfs: Drop 'struct module_sect_attr' Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 4/6] module: sysfs: Simplify section attribute allocation Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 5/6] module: sysfs: Add notes attributes through attribute_group Thomas Weißschuh
2024-12-27 13:23 ` Thomas Weißschuh [this message]
2024-12-31 15:07 ` [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Petr Pavlu
2025-01-07 16:52 ` Greg KH
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=20241227-sysfs-const-bin_attr-module-v2-6-e267275f0f37@weissschuh.net \
--to=linux@weissschuh.net \
--cc=da.gomez@samsung.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.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