kmemleak observed after system boots up
Hello
I found this kmemleak after system boots up on the latest linux-block/for-next, please help check it and let me know if you need any testing/info about it, thanks.
# dmesg | grep kmemleak [ 474.750916] kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff88824046a580 (size 96):
comm "swapper/0", pid 1, jiffies 4294727564
hex dump (first 32 bytes):
a0 c2 0d 9b ff ff ff ff 00 00 00 00 00 00 00 00 ................
01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc e7670296):
[<ffffffff9412657c>] __kmalloc+0x37c/0x480
[<ffffffff944cfbf8>] __register_sysctl_table+0x58/0x450
[<ffffffff98680079>] fsverity_init+0x29/0x50
[<ffffffff9360371e>] do_one_initcall+0xfe/0x5a0
[<ffffffff985b70d8>] do_initcalls+0x138/0x1d0
[<ffffffff985b7aac>] kernel_init_freeable+0x8bc/0xbe0
[<ffffffff95dba94b>] kernel_init+0x1b/0x1e0
[<ffffffff936a804d>] ret_from_fork+0x2d/0x70
[<ffffffff93606e4a>] ret_from_fork_asm+0x1a/0x30(gdb) l *(fsverity_init+0x29)0xffffffff86080079 is in fsverity_init (fs/verity/init.c:33). 28
29 static void __init fsverity_init_sysctl(void)
30 {
31 fsverity_sysctl_header = register_sysctl("fs/verity", 32 fsverity_sysctl_table);
33 if (!fsverity_sysctl_header)
34 panic("fsverity sysctl registration failed");
35 }
36 #else /* CONFIG_SYSCTL */
37 static inline void fsverity_init_sysctl(void)
Signature · 2 lines
Best Regards, Yi Zhang
Hi Eric
Seems this issue was introduced from 6.6-rc1, do you have a chance to check it, thanks.
Quoted 44 lines · Yi Zhang
Hello
I found this kmemleak after system boots up on the latest linux-block/for-next, please help check it and let me know if you need any testing/info about it, thanks.# dmesg | grep kmemleak [ 474.750916] kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak)# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff88824046a580 (size 96): comm "swapper/0", pid 1, jiffies 4294727564 hex dump (first 32 bytes): a0 c2 0d 9b ff ff ff ff 00 00 00 00 00 00 00 00 ................ 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc e7670296): [<ffffffff9412657c>] __kmalloc+0x37c/0x480 [<ffffffff944cfbf8>] __register_sysctl_table+0x58/0x450 [<ffffffff98680079>] fsverity_init+0x29/0x50 [<ffffffff9360371e>] do_one_initcall+0xfe/0x5a0 [<ffffffff985b70d8>] do_initcalls+0x138/0x1d0 [<ffffffff985b7aac>] kernel_init_freeable+0x8bc/0xbe0 [<ffffffff95dba94b>] kernel_init+0x1b/0x1e0 [<ffffffff936a804d>] ret_from_fork+0x2d/0x70 [<ffffffff93606e4a>] ret_from_fork_asm+0x1a/0x30(gdb) l *(fsverity_init+0x29)
0xffffffff86080079is infsverity_init(fs/verity/init.c:33). 28
29 static void__initfsverity_init_sysctl(void)
30 {
31fsverity_sysctl_header=register_sysctl("fs/verity", 32 fsverity_sysctl_table);
33 if (!fsverity_sysctl_header)
34panic("fsverity sysctl registration failed");
35 }
36 #else /*CONFIG_SYSCTL*/
37 static inline voidfsverity_init_sysctl(void)--
Best Regards,
Yi Zhang
Signature · 2 lines
Best Regards, Yi Zhang
Eric Biggers
maintainerPATCH 1/1 fsverity: use register_sysctl_init() to avoid kmemleak warning
From: Eric Biggers <[email protected]>
Since the fsverity sysctl registration runs as a builtin initcall, there is no corresponding sysctl deregistration and the resulting struct ctl_table_header is not used. This can cause a kmemleak warning just after the system boots up. (A pointer to the ctl_table_header is stored in the fsverity_sysctl_header static variable, which kmemleak should detect; however, the compiler can optimize out that variable.) Avoid the kmemleak warning by using register_sysctl_init() which is intended for use by builtin initcalls and uses kmemleak_not_leak().
--- fs/verity/init.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
fs/verity/init.c +1 -6
@@ -8,12 +8,10 @@#include "fsverity_private.h" #include <linux/ratelimit.h> #ifdef CONFIG_SYSCTL -static struct ctl_table_header *fsverity_sysctl_header; - static struct ctl_table fsverity_sysctl_table[] = { #ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES { .procname = "require_signatures", .data = &fsverity_require_signatures,
@@ -26,14 +24,11 @@ static struct ctl_table fsverity_sysctl_table[] = {#endif };static void __init fsverity_init_sysctl (void ) { - fsverity_sysctl_header =register_sysctl ("fs/verity" , - fsverity_sysctl_table); -if (!fsverity_sysctl_header) -panic ("fsverity sysctl registration failed" ); +register_sysctl_init ("fs/verity" , fsverity_sysctl_table); }#else /* CONFIG_SYSCTL */ static inline void fsverity_init_sysctl (void ) { }
base-commit: 18daea77cca626f590fb140fc11e3a43c5d41354
Signature · 1 line
2.45.0
Re: [PATCH] fsverity: use register_sysctl_init() to avoid kmemleak warning
Quoted 53 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Since the fsverity sysctl registration runs as a builtin initcall, there is no corresponding sysctl deregistration and the resulting struct
ctl_table_headeris not used. This can cause a kmemleak warning just after the system boots up. (A pointer to thectl_table_headeris stored in thefsverity_sysctl_headerstatic variable, which kmemleak should detect; however, the compiler can optimize out that variable.) Avoid the kmemleak warning by usingregister_sysctl_init()which is intended for use by builtin initcalls and useskmemleak_not_leak().Reported-by Yi Zhang <[email protected]>Closes https://lore.kernel.org/r/CAHj4cs8DTSvR698UE040rs_pX1k-WVe7aR6N2OoXXuhXJPDC-w@mail.gmail.com open hereSigned-off-by Eric Biggers <[email protected]>--- fs/verity/init.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)fs/verity/init.c +1
-6@@ -8,12 +8,10 @@#include "fsverity_private.h" #include <linux/ratelimit.h> #ifdef CONFIG_SYSCTL -static struct ctl_table_header *fsverity_sysctl_header; - static struct ctl_table fsverity_sysctl_table[] = { #ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES { .procname = "require_signatures", .data = &fsverity_require_signatures,@@ -26,14 +24,11 @@ static struct ctl_table fsverity_sysctl_table[] = {#endif };static void __init fsverity_init_sysctl (void ) { - fsverity_sysctl_header =register_sysctl ("fs/verity" , - fsverity_sysctl_table); -if (!fsverity_sysctl_header) -panic ("fsverity sysctl registration failed" ); +register_sysctl_init ("fs/verity" , fsverity_sysctl_table); }#else /* CONFIG_SYSCTL */ static inline void fsverity_init_sysctl (void ) { }
Quoted 4 lines
base-commit:
18daea77cca626f590fb140fc11e3a43c5d41354Signature · 1 line
2.45.0
LGTM
Signature · 1 line
Joel Granados
Re: [PATCH] fsverity: use register_sysctl_init() to avoid kmemleak warning
In reply to Eric BiggersQuoted 11 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Since the fsverity sysctl registration runs as a builtin initcall, there is no corresponding sysctl deregistration and the resulting struct
ctl_table_headeris not used. This can cause a kmemleak warning just after the system boots up. (A pointer to thectl_table_headeris stored in thefsverity_sysctl_headerstatic variable, which kmemleak should detect; however, the compiler can optimize out that variable.) Avoid the kmemleak warning by usingregister_sysctl_init()which is intended for use by builtin initcalls and useskmemleak_not_leak().
Quoted 4 lines
Applied to https://git.kernel.org/pub/scm/fs/fsverity/linux.git/log/?h=for-next
- Eric