[Devel] [PATCH RHEL10 COMMIT] modules: use kvmalloc for the section attribute pointer array too
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jun 15 13:49:09 MSK 2026
The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.el10
------>
commit ac143f3820be7679ac2aa696735921855d0f2e05
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Thu Jun 11 19:31:49 2026 +0200
modules: use kvmalloc for the section attribute pointer array too
The patch switched the struct module_sect_attrs allocation in
add_sect_attrs() to kvzalloc() so a module with many ELF sections
does not need a high-order allocation.
The RHEL10.2 base carries upstream f47c0bebed44 ("module: sysfs:
Simplify section attribute allocation"), which split the bin_attribute
pointer array out of that struct into its own allocation:
gattr = kcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL);
For a module with many sections this is another nloaded-sized array
that can cross a page and require a high-order allocation - exactly
what the patch set out to avoid. Allocate it with kvcalloc() and free
it with kvfree() in free_sect_attrs().
Fixes: 05fee8af6411 ("modules: use kvmalloc when creating sysfs attributes for ELF sections")
Reported-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
https://virtuozzo.atlassian.net/browse/VSTOR-132310
Feature: mm: avoid high order allocations in all subsystems
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
kernel/module/sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c
index a896022e6186..4d0286559123 100644
--- a/kernel/module/sysfs.c
+++ b/kernel/module/sysfs.c
@@ -59,7 +59,7 @@ static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
for (bin_attr = sect_attrs->grp.bin_attrs_new; *bin_attr; bin_attr++)
kfree((*bin_attr)->attr.name);
- kfree(sect_attrs->grp.bin_attrs_new);
+ kvfree(sect_attrs->grp.bin_attrs_new);
kvfree(sect_attrs);
}
@@ -79,7 +79,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
if (!sect_attrs)
return -ENOMEM;
- gattr = kcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL);
+ gattr = kvcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL);
if (!gattr) {
kvfree(sect_attrs);
return -ENOMEM;
More information about the Devel
mailing list