The quilt patch titled Subject: alloc_tag: fix empty codetag module section handling has been removed from the -mm tree. Its filename was alloc_tag-load-module-tags-into-separate-contiguous-memory-fix.patch This patch was dropped because it was folded into alloc_tag-load-module-tags-into-separate-contiguous-memory.patch ------------------------------------------------------ From: Suren Baghdasaryan <surenb@xxxxxxxxxx> Subject: alloc_tag: fix empty codetag module section handling Date: Thu, 31 Oct 2024 17:00:17 -0700 When a module does not have any allocations, it's allocation tag section is empty and codetag_alloc_module_section() returns NULL. However this condition should never happen because codetag_needs_module_section() will detect an empty section and avoid calling codetag_alloc_module_section(). Change codetag_alloc_module_section() to never return NULL, which should prevent static checker warnings. Add a WARN_ON() and a proper error reporting in case codetag_alloc_module_section() returns NULL, to prevent future codetag type implementations from returning NULL from their cttype->desc.alloc_section_mem() operation. Link: https://lkml.kernel.org/r/20241101000017.3856204-1-surenb@xxxxxxxxxx Fixes: 61c9e58f3a10 ("alloc_tag: load module tags into separate contiguous memory") Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Closes: https://lore.kernel.org/all/50f12fa1-17c1-4940-a6bf-beaf61f6b17a@stanley.mountain/ Cc: Ard Biesheuvel <ardb@xxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Borislav Petkov (AMD) <bp@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Cc: Daniel Gomez <da.gomez@xxxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Kalesh Singh <kaleshsingh@xxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Kent Overstreet <kent.overstreet@xxxxxxxxx> Cc: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Cc: Luis Chamberlain <mcgrof@xxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: Paul E. McKenney <paulmck@xxxxxxxxxx> Cc: Petr Pavlu <petr.pavlu@xxxxxxxx> Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> Cc: Sami Tolvanen <samitolvanen@xxxxxxxxxx> Cc: Sourav Panda <souravpanda@xxxxxxxxxx> Cc: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Thomas Huth <thuth@xxxxxxxxxx> Cc: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Xiongwei Song <xiongwei.song@xxxxxxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/module/main.c | 4 ++++ lib/alloc_tag.c | 2 +- lib/codetag.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) --- a/kernel/module/main.c~alloc_tag-load-module-tags-into-separate-contiguous-memory-fix +++ a/kernel/module/main.c @@ -2316,6 +2316,10 @@ static int move_module(struct module *mo if (codetag_needs_module_section(mod, sname, shdr->sh_size)) { dest = codetag_alloc_module_section(mod, sname, shdr->sh_size, arch_mod_section_prepend(mod, i), shdr->sh_addralign); + if (WARN_ON(!dest)) { + ret = -EINVAL; + goto out_err; + } if (IS_ERR(dest)) { ret = PTR_ERR(dest); goto out_err; --- a/lib/alloc_tag.c~alloc_tag-load-module-tags-into-separate-contiguous-memory-fix +++ a/lib/alloc_tag.c @@ -262,7 +262,7 @@ static void *reserve_module_tags(struct /* If no tags return NULL */ if (size < sizeof(struct alloc_tag)) - return NULL; + return ERR_PTR(-EINVAL); /* * align is always power of 2, so we can use IS_ALIGNED and ALIGN. --- a/lib/codetag.c~alloc_tag-load-module-tags-into-separate-contiguous-memory-fix +++ a/lib/codetag.c @@ -244,7 +244,7 @@ void *codetag_alloc_module_section(struc { const char *type_name = name + strlen(CODETAG_SECTION_PREFIX); struct codetag_type *cttype; - void *ret = NULL; + void *ret = ERR_PTR(-EINVAL); mutex_lock(&codetag_lock); list_for_each_entry(cttype, &codetag_types, link) { _ Patches currently in -mm which might be from surenb@xxxxxxxxxx are maple_tree-add-mas_for_each_rev-helper.patch alloc_tag-introduce-shutdown_mem_profiling-helper-function.patch alloc_tag-load-module-tags-into-separate-contiguous-memory.patch alloc_tag-populate-memory-for-module-tags-as-needed.patch alloc_tag-populate-memory-for-module-tags-as-needed-fix.patch alloc_tag-introduce-pgtag_ref_handle-to-abstract-page-tag-references.patch alloc_tag-support-for-page-allocation-tag-compression.patch mm-codetag-uninline-and-move-pgalloc_tag_copy-and-pgalloc_tag_split.patch mm-convert-mm_lock_seq-to-a-proper-seqcount.patch mm-introduce-mmap_lock_speculation_beginend.patch