mirror-linux/include
Hao Ge f5769359c5 mm/alloc_tag: fix the kmemleak false positive issue in the allocation of the percpu variable tag->counters
When loading a module, as long as the module has memory allocation
operations, kmemleak produces a false positive report that resembles the
following:

unreferenced object (percpu) 0x7dfd232a1650 (size 16):
  comm "modprobe", pid 1301, jiffies 4294940249
  hex dump (first 16 bytes on cpu 2):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 0):
    kmemleak_alloc_percpu+0xb4/0xd0
    pcpu_alloc_noprof+0x700/0x1098
    load_module+0xd4/0x348
    codetag_module_init+0x20c/0x450
    codetag_load_module+0x70/0xb8
    load_module+0xef8/0x1608
    init_module_from_file+0xec/0x158
    idempotent_init_module+0x354/0x608
    __arm64_sys_finit_module+0xbc/0x150
    invoke_syscall+0xd4/0x258
    el0_svc_common.constprop.0+0xb4/0x240
    do_el0_svc+0x48/0x68
    el0_svc+0x40/0xf8
    el0t_64_sync_handler+0x10c/0x138
    el0t_64_sync+0x1ac/0x1b0

This is because the module can only indirectly reference
alloc_tag_counters through the alloc_tag section, which misleads kmemleak.

However, we don't have a kmemleak ignore interface for percpu allocations
yet.  So let's create one and invoke it for tag->counters.

[gehao@kylinos.cn: fix build error when CONFIG_DEBUG_KMEMLEAK=n, s/igonore/ignore/]
  Link: https://lkml.kernel.org/r/20250620093102.2416767-1-hao.ge@linux.dev
Link: https://lkml.kernel.org/r/20250619183154.2122608-1-hao.ge@linux.dev
Fixes: 12ca42c237 ("alloc_tag: allocate percpu counters for module tags dynamically")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Suren Baghdasaryan <surenb@google.com>	[lib/alloc_tag.c]
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-06-25 15:55:03 -07:00
..
acpi Merge branches 'acpi-processor' and 'acpi-cppc' 2025-05-26 18:37:38 +02:00
asm-generic hyperv-next for v6.16 2025-06-03 08:39:20 -07:00
clocksource
crypto dm-crypt: Extend state buffer size in crypt_iv_lmk_one 2025-06-23 13:50:02 +02:00
cxl
drm drm for 6.16-rc1 2025-05-28 09:46:39 -07:00
dt-bindings USB/Thunderbolt changes for 6.16-rc1 2025-06-06 12:45:35 -07:00
hyperv hyperv-next for v6.16 2025-06-03 08:39:20 -07:00
keys
kunit I've recently moved computers (among other things) so I'm sending this from a 2025-05-30 09:15:40 -07:00
kvm KVM: arm64: Resolve vLPI by host IRQ in vgic_v4_unset_forwarding() 2025-05-30 09:11:29 +01:00
linux mm/alloc_tag: fix the kmemleak false positive issue in the allocation of the percpu variable tag->counters 2025-06-25 15:55:03 -07:00
math-emu
media
memory
misc
net bluetooth pull request for net: 2025-06-12 08:13:48 -07:00
pcmcia
ras
rdma Linux 6.15 2025-05-26 15:33:52 -03:00
rv
scsi SCSI misc on 20250529 2025-05-29 22:17:52 -07:00
soc - The 3 patch series "hung_task: extend blocking task stacktrace dump to 2025-05-31 19:12:53 -07:00
sound USB/Thunderbolt changes for 6.16-rc1 2025-06-06 12:45:35 -07:00
target
trace erofs: remove unused trace event erofs_destroy_inode 2025-06-18 13:41:16 +08:00
uapi ARM: 2025-06-22 09:58:23 -07:00
ufs
vdso
video fbdev: atyfb: Remove unused PCI vendor ID 2025-05-31 10:24:01 +02:00
xen
Kbuild