* [PATCH v2 1/6] module: sysfs: Drop member 'module_sect_attrs::nsections'
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 ` Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 2/6] module: sysfs: Drop member 'module_sect_attr::address' Thomas Weißschuh
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
The member is only used to iterate over all attributes in
free_sect_attrs(). However the attribute group can already be used for
that. Use the group and drop 'nsections'.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index 456358e1fdc43e6b5b24f383bbefa37812971174..b7841f76a933114e6dbd0fc2d32a60b66b7966b6 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -26,7 +26,6 @@ struct module_sect_attr {
struct module_sect_attrs {
struct attribute_group grp;
- unsigned int nsections;
struct module_sect_attr attrs[];
};
@@ -62,10 +61,10 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
{
- unsigned int section;
+ struct bin_attribute **bin_attr;
- for (section = 0; section < sect_attrs->nsections; section++)
- kfree(sect_attrs->attrs[section].battr.attr.name);
+ for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++)
+ kfree((*bin_attr)->attr.name);
kfree(sect_attrs);
}
@@ -92,7 +91,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
sect_attrs->grp.name = "sections";
sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0];
- sect_attrs->nsections = 0;
sattr = §_attrs->attrs[0];
gattr = §_attrs->grp.bin_attrs[0];
for (i = 0; i < info->hdr->e_shnum; i++) {
@@ -108,7 +106,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
ret = -ENOMEM;
goto out;
}
- sect_attrs->nsections++;
sattr->battr.read = module_sect_read;
sattr->battr.size = MODULE_SECT_READ_SIZE;
sattr->battr.attr.mode = 0400;
--
2.47.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 2/6] module: sysfs: Drop member 'module_sect_attr::address'
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 ` Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 3/6] module: sysfs: Drop 'struct module_sect_attr' Thomas Weißschuh
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
'struct bin_attribute' already contains the member 'private' to pass
custom data to the attribute handlers.
Use that instead of the custom 'address' member.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index b7841f76a933114e6dbd0fc2d32a60b66b7966b6..8955b3da1b499881256670418d41c5d52d9e5a5e 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -21,7 +21,6 @@
#ifdef CONFIG_KALLSYMS
struct module_sect_attr {
struct bin_attribute battr;
- unsigned long address;
};
struct module_sect_attrs {
@@ -34,8 +33,6 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
struct bin_attribute *battr,
char *buf, loff_t pos, size_t count)
{
- struct module_sect_attr *sattr =
- container_of(battr, struct module_sect_attr, battr);
char bounce[MODULE_SECT_READ_SIZE + 1];
size_t wrote;
@@ -52,7 +49,7 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
*/
wrote = scnprintf(bounce, sizeof(bounce), "0x%px\n",
kallsyms_show_value(file->f_cred)
- ? (void *)sattr->address : NULL);
+ ? battr->private : NULL);
count = min(count, wrote);
memcpy(buf, bounce, count);
@@ -99,7 +96,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
if (sect_empty(sec))
continue;
sysfs_bin_attr_init(&sattr->battr);
- sattr->address = sec->sh_addr;
sattr->battr.attr.name =
kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
if (!sattr->battr.attr.name) {
@@ -107,6 +103,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
goto out;
}
sattr->battr.read = module_sect_read;
+ sattr->battr.private = (void *)sec->sh_addr;
sattr->battr.size = MODULE_SECT_READ_SIZE;
sattr->battr.attr.mode = 0400;
*(gattr++) = &(sattr++)->battr;
--
2.47.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 3/6] module: sysfs: Drop 'struct module_sect_attr'
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 ` Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 4/6] module: sysfs: Simplify section attribute allocation Thomas Weißschuh
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
This is now an otherwise empty wrapper around a 'struct bin_attribute',
not providing any functionality. Remove it.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index 8955b3da1b499881256670418d41c5d52d9e5a5e..3d507005d7111b8328c04d35476a73193f73db1c 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -19,13 +19,9 @@
* J. Corbet <corbet@lwn.net>
*/
#ifdef CONFIG_KALLSYMS
-struct module_sect_attr {
- struct bin_attribute battr;
-};
-
struct module_sect_attrs {
struct attribute_group grp;
- struct module_sect_attr attrs[];
+ struct bin_attribute attrs[];
};
#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4))
@@ -69,8 +65,8 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
{
unsigned int nloaded = 0, i, size[2];
struct module_sect_attrs *sect_attrs;
- struct module_sect_attr *sattr;
struct bin_attribute **gattr;
+ struct bin_attribute *sattr;
int ret;
/* Count loaded sections and allocate structures */
@@ -95,18 +91,18 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
if (sect_empty(sec))
continue;
- sysfs_bin_attr_init(&sattr->battr);
- sattr->battr.attr.name =
+ sysfs_bin_attr_init(sattr);
+ sattr->attr.name =
kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
- if (!sattr->battr.attr.name) {
+ if (!sattr->attr.name) {
ret = -ENOMEM;
goto out;
}
- sattr->battr.read = module_sect_read;
- sattr->battr.private = (void *)sec->sh_addr;
- sattr->battr.size = MODULE_SECT_READ_SIZE;
- sattr->battr.attr.mode = 0400;
- *(gattr++) = &(sattr++)->battr;
+ sattr->read = module_sect_read;
+ sattr->private = (void *)sec->sh_addr;
+ sattr->size = MODULE_SECT_READ_SIZE;
+ sattr->attr.mode = 0400;
+ *(gattr++) = sattr++;
}
*gattr = NULL;
@@ -186,7 +182,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
continue;
if (info->sechdrs[i].sh_type == SHT_NOTE) {
sysfs_bin_attr_init(nattr);
- nattr->attr.name = mod->sect_attrs->attrs[loaded].battr.attr.name;
+ nattr->attr.name = mod->sect_attrs->attrs[loaded].attr.name;
nattr->attr.mode = 0444;
nattr->size = info->sechdrs[i].sh_size;
nattr->private = (void *)info->sechdrs[i].sh_addr;
--
2.47.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 4/6] module: sysfs: Simplify section attribute allocation
2024-12-27 13:23 [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Thomas Weißschuh
` (2 preceding siblings ...)
2024-12-27 13:23 ` [PATCH v2 3/6] module: sysfs: Drop 'struct module_sect_attr' Thomas Weißschuh
@ 2024-12-27 13:23 ` Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 5/6] module: sysfs: Add notes attributes through attribute_group Thomas Weißschuh
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
The existing allocation logic manually stuffs two allocations into one.
This is hard to understand and of limited value, given that all the
section names are allocated on their own anyways.
Une one allocation per datastructure.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index 3d507005d7111b8328c04d35476a73193f73db1c..4b1a963b712b609cde1c4375e789a6ee7f359c7a 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -58,34 +58,37 @@ static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++)
kfree((*bin_attr)->attr.name);
+ kfree(sect_attrs->grp.bin_attrs);
kfree(sect_attrs);
}
static int add_sect_attrs(struct module *mod, const struct load_info *info)
{
- unsigned int nloaded = 0, i, size[2];
struct module_sect_attrs *sect_attrs;
struct bin_attribute **gattr;
struct bin_attribute *sattr;
+ unsigned int nloaded = 0, i;
int ret;
/* Count loaded sections and allocate structures */
for (i = 0; i < info->hdr->e_shnum; i++)
if (!sect_empty(&info->sechdrs[i]))
nloaded++;
- size[0] = ALIGN(struct_size(sect_attrs, attrs, nloaded),
- sizeof(sect_attrs->grp.bin_attrs[0]));
- size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]);
- sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL);
+ sect_attrs = kzalloc(struct_size(sect_attrs, attrs, nloaded), GFP_KERNEL);
if (!sect_attrs)
return -ENOMEM;
+ gattr = kcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL);
+ if (!gattr) {
+ kfree(sect_attrs);
+ return -ENOMEM;
+ }
+
/* Setup section attributes. */
sect_attrs->grp.name = "sections";
- sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0];
+ sect_attrs->grp.bin_attrs = gattr;
sattr = §_attrs->attrs[0];
- gattr = §_attrs->grp.bin_attrs[0];
for (i = 0; i < info->hdr->e_shnum; i++) {
Elf_Shdr *sec = &info->sechdrs[i];
@@ -104,7 +107,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
sattr->attr.mode = 0400;
*(gattr++) = sattr++;
}
- *gattr = NULL;
ret = sysfs_create_group(&mod->mkobj.kobj, §_attrs->grp);
if (ret)
--
2.47.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 5/6] module: sysfs: Add notes attributes through attribute_group
2024-12-27 13:23 [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Thomas Weißschuh
` (3 preceding siblings ...)
2024-12-27 13:23 ` [PATCH v2 4/6] module: sysfs: Simplify section attribute allocation Thomas Weißschuh
@ 2024-12-27 13:23 ` Thomas Weißschuh
2024-12-27 13:23 ` [PATCH v2 6/6] module: sysfs: Use const 'struct bin_attribute' Thomas Weißschuh
2024-12-31 15:07 ` [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Petr Pavlu
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
A kobject is meant to manage the lifecycle of some resource.
However the module sysfs code only creates a kobject to get a
"notes" subdirectory in sysfs.
This can be achieved easier and cheaper by using a sysfs group.
Switch the notes attribute code to such a group, similar to how the
section allocation in the same file already works.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/module/sysfs.c | 54 ++++++++++++++++++++++++++-------------------------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index 4b1a963b712b609cde1c4375e789a6ee7f359c7a..d04cb12eac7be63dd0bb65bd55e97280e7875e4e 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -138,20 +138,13 @@ static void remove_sect_attrs(struct module *mod)
*/
struct module_notes_attrs {
- struct kobject *dir;
- unsigned int notes;
- struct bin_attribute attrs[] __counted_by(notes);
+ struct attribute_group grp;
+ struct bin_attribute attrs[];
};
-static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
- unsigned int i)
+static void free_notes_attrs(struct module_notes_attrs *notes_attrs)
{
- if (notes_attrs->dir) {
- while (i-- > 0)
- sysfs_remove_bin_file(notes_attrs->dir,
- ¬es_attrs->attrs[i]);
- kobject_put(notes_attrs->dir);
- }
+ kfree(notes_attrs->grp.bin_attrs);
kfree(notes_attrs);
}
@@ -159,6 +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;
struct bin_attribute *nattr;
int ret;
@@ -177,7 +171,15 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
if (!notes_attrs)
return -ENOMEM;
- notes_attrs->notes = notes;
+ gattr = kcalloc(notes + 1, sizeof(*gattr), GFP_KERNEL);
+ if (!gattr) {
+ kfree(notes_attrs);
+ return -ENOMEM;
+ }
+
+ notes_attrs->grp.name = "notes";
+ notes_attrs->grp.bin_attrs = gattr;
+
nattr = ¬es_attrs->attrs[0];
for (loaded = i = 0; i < info->hdr->e_shnum; ++i) {
if (sect_empty(&info->sechdrs[i]))
@@ -189,35 +191,35 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
nattr->size = info->sechdrs[i].sh_size;
nattr->private = (void *)info->sechdrs[i].sh_addr;
nattr->read = sysfs_bin_attr_simple_read;
- ++nattr;
+ *(gattr++) = nattr++;
}
++loaded;
}
- notes_attrs->dir = kobject_create_and_add("notes", &mod->mkobj.kobj);
- if (!notes_attrs->dir) {
- ret = -ENOMEM;
+ ret = sysfs_create_group(&mod->mkobj.kobj, ¬es_attrs->grp);
+ if (ret)
goto out;
- }
-
- for (i = 0; i < notes; ++i) {
- ret = sysfs_create_bin_file(notes_attrs->dir, ¬es_attrs->attrs[i]);
- if (ret)
- goto out;
- }
mod->notes_attrs = notes_attrs;
return 0;
out:
- free_notes_attrs(notes_attrs, i);
+ free_notes_attrs(notes_attrs);
return ret;
}
static void remove_notes_attrs(struct module *mod)
{
- if (mod->notes_attrs)
- free_notes_attrs(mod->notes_attrs, mod->notes_attrs->notes);
+ if (mod->notes_attrs) {
+ sysfs_remove_group(&mod->mkobj.kobj,
+ &mod->notes_attrs->grp);
+ /*
+ * We are positive that no one is using any notes attrs
+ * at this point. Deallocate immediately.
+ */
+ free_notes_attrs(mod->notes_attrs);
+ mod->notes_attrs = NULL;
+ }
}
#else /* !CONFIG_KALLSYMS */
--
2.47.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 6/6] module: sysfs: Use const 'struct bin_attribute'
2024-12-27 13:23 [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Thomas Weißschuh
` (4 preceding siblings ...)
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
2024-12-31 15:07 ` [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Petr Pavlu
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2024-12-27 13:23 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Gustavo A. R. Silva
Cc: linux-modules, linux-kernel, linux-hardening,
Thomas Weißschuh
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute
2024-12-27 13:23 [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute Thomas Weißschuh
` (5 preceding siblings ...)
2024-12-27 13:23 ` [PATCH v2 6/6] module: sysfs: Use const 'struct bin_attribute' Thomas Weißschuh
@ 2024-12-31 15:07 ` Petr Pavlu
2025-01-07 16:52 ` Greg KH
6 siblings, 1 reply; 9+ messages in thread
From: Petr Pavlu @ 2024-12-31 15:07 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Luis Chamberlain, Sami Tolvanen, Daniel Gomez, Kees Cook,
Gustavo A. R. Silva, linux-modules, linux-kernel, linux-hardening
On 12/27/24 14:23, Thomas Weißschuh wrote:
> The sysfs core is switching to 'const struct bin_attribute's.
> Prepare for that.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> Changes in v2:
> - Avoid NULL-deref in free_sect_attrs()
> - Avoid double-free and NULL-deref in free_notes_attrs()
> - Also drop 'struct module_sect_attr'
> - Link to v1: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-module-v1-0-f81e49e54ce4@weissschuh.net
>
> ---
> Thomas Weißschuh (6):
> module: sysfs: Drop member 'module_sect_attrs::nsections'
> module: sysfs: Drop member 'module_sect_attr::address'
> module: sysfs: Drop 'struct module_sect_attr'
> module: sysfs: Simplify section attribute allocation
> module: sysfs: Add notes attributes through attribute_group
> module: sysfs: Use const 'struct bin_attribute'
>
> kernel/module/sysfs.c | 116 ++++++++++++++++++++++++--------------------------
> 1 file changed, 55 insertions(+), 61 deletions(-)
> ---
> base-commit: d6ef8b40d075c425f548002d2f35ae3f06e9cf96
> change-id: 20241215-sysfs-const-bin_attr-module-be05346937a6
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
I'm going to wait for a few days if others want to comment and then plan
to queue this on the modules tree for the 6.14 merge window.
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/6] module: sysfs: Cleanups and preparation for const struct bin_attribute
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
0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2025-01-07 16:52 UTC (permalink / raw)
To: Petr Pavlu
Cc: Thomas Weißschuh, Luis Chamberlain, Sami Tolvanen,
Daniel Gomez, Kees Cook, Gustavo A. R. Silva, linux-modules,
linux-kernel, linux-hardening
On Tue, Dec 31, 2024 at 04:07:40PM +0100, Petr Pavlu wrote:
> On 12/27/24 14:23, Thomas Weißschuh wrote:
> > The sysfs core is switching to 'const struct bin_attribute's.
> > Prepare for that.
> >
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> > Changes in v2:
> > - Avoid NULL-deref in free_sect_attrs()
> > - Avoid double-free and NULL-deref in free_notes_attrs()
> > - Also drop 'struct module_sect_attr'
> > - Link to v1: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-module-v1-0-f81e49e54ce4@weissschuh.net
> >
> > ---
> > Thomas Weißschuh (6):
> > module: sysfs: Drop member 'module_sect_attrs::nsections'
> > module: sysfs: Drop member 'module_sect_attr::address'
> > module: sysfs: Drop 'struct module_sect_attr'
> > module: sysfs: Simplify section attribute allocation
> > module: sysfs: Add notes attributes through attribute_group
> > module: sysfs: Use const 'struct bin_attribute'
> >
> > kernel/module/sysfs.c | 116 ++++++++++++++++++++++++--------------------------
> > 1 file changed, 55 insertions(+), 61 deletions(-)
> > ---
> > base-commit: d6ef8b40d075c425f548002d2f35ae3f06e9cf96
> > change-id: 20241215-sysfs-const-bin_attr-module-be05346937a6
>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
>
> I'm going to wait for a few days if others want to comment and then plan
> to queue this on the modules tree for the 6.14 merge window.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 9+ messages in thread