v11
2026-10-09
alloc_tag 标签修复 · v11
修复 alloc_tag 模块 codetag 溢出与生命周期:溢出时关闭 profiling 并返回 -EAGAIN,另查竞态。
原始补丁链接
子 Patch(7)
1/7
alloc_tag: move release_module_tags() above reserve_module_tags()
将 release_module_tags() 前移,使 reserve_module_tags() 在 maple tree 已记录预留后失败时能直接调用它撤销,无需前置声明,纯代码整理。
2/7
mm/vmalloc: undo partial mappings inside the mapping functions
让 __vmap_pages_range_noflush 等映射失败时用 __vunmap_range_noflush 回滚已装 PTE,避免调用方清理不一致导致重映射命中残留并触发 vmap_pte_range BUG。
3/7
alloc_tag: clean up the populate failure path
vm_module_tags_populate() 失败时释放已存入 maple tree 的模块标签预留并回滚 module_tags.size,防止加载失败后并发模块复用空洞、跳过填充而写未映射内存。
4/7
module: introduce SH_ENTSIZE_STANDALONE for separately allocated sections
新增 SH_ENTSIZE_STANDALONE 标记独立分配的模块节,layout_sections()/move_module() 跳过它,apply_relocations() 恢复只看 SHF_ALLOC,并在 sysfs 节属性中跳过 .data..percpu。
5/7
module: allocate codetag sections before the regular module layout
在 layout_sections() 前一次性决定并分配 codetag 节,避免 move_module() 重查时并发关闭 profiling 导致节被复制到偏移 0;标签区溢出返回 -EAGAIN 回退普通数据并释放预留。
6/7
alloc_tag: skip percpu counter allocation when profiling is disabled
profiling 关闭后 load_module() 返回 -EOPNOTSUPP,codetag_module_init() 丢弃 cmod 且不分配 percpu 计数器;codetag_unload_module() 总是 free_section_mem(),避免未入 idr 模块的计数器泄漏。
7/7
alloc_tag: fix the /proc/allocinfo lifecycle
把 remove_proc_entry() 移到工作队列,避免 reserve_module_tags() 持 mod_lock 写锁时与 allocinfo_start() 读锁互等死锁;alloc_tag_init() 改为最后创建 /proc/allocinfo,失败时回滚类型与模块标签内存。