Reviewed-by: Pavel Tikhomirov <[email protected]> On 6/11/26 22:42, Konstantin Khorenko wrote: > 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: 8b230b0af770 ("modules: use kvmalloc when creating sysfs attributes > for ELF sections") > > Reported-by: Pavel Tikhomirov <[email protected]> > https://virtuozzo.atlassian.net/browse/VSTOR-132310 > Signed-off-by: Konstantin Khorenko <[email protected]> > --- > 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;
-- Best regards, Pavel Tikhomirov Senior Software Developer, Virtuozzo. _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
