bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bpf leaking memory
@ 2025-08-01 16:31 Jens Axboe
  2025-08-01 22:41 ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2025-08-01 16:31 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: open list:XDP SOCKETS (AF_XDP), LKML

Hi,

Current -git (any within the last day or two) leaks memory at boot,
as reported by kmemleak, see below. This is running debian unstable
on aarc64.

unreferenced object 0xffff0000c820d000 (size 64):
  comm "systemd", pid 1, jiffies 4294667980
  hex dump (first 32 bytes):
    01 00 00 00 00 00 ff ff 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 84021ac):
    kmemleak_alloc+0x3c/0x50
    __kmalloc_node_track_caller_noprof+0x370/0x500
    krealloc_noprof+0x238/0x300
    kvrealloc_noprof+0x44/0x100
    do_check_common+0x2668/0x2d50
    bpf_check+0x2464/0x2ec0
    bpf_prog_load+0x5c8/0xba8
    __sys_bpf+0x9c0/0x20a0
    __arm64_sys_bpf+0x24/0x60
    invoke_syscall.constprop.0+0x44/0x100
    el0_svc_common.constprop.0+0x3c/0xe0
    do_el0_svc+0x20/0x30
    el0_svc+0x30/0xe0
    el0t_64_sync_handler+0x98/0xe0
    el0t_64_sync+0x170/0x178
unreferenced object 0xffff0000c8ccd900 (size 64):
  comm "systemd", pid 1, jiffies 4294667983
  hex dump (first 32 bytes):
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 8e80d088):
    kmemleak_alloc+0x3c/0x50
    __kmalloc_node_track_caller_noprof+0x370/0x500
    krealloc_noprof+0x238/0x300
    kvrealloc_noprof+0x44/0x100
    do_check_common+0x2668/0x2d50
    bpf_check+0x2464/0x2ec0
    bpf_prog_load+0x5c8/0xba8
    __sys_bpf+0x9c0/0x20a0
    __arm64_sys_bpf+0x24/0x60
    invoke_syscall.constprop.0+0x44/0x100
    el0_svc_common.constprop.0+0x3c/0xe0
    do_el0_svc+0x20/0x30
    el0_svc+0x30/0xe0
    el0t_64_sync_handler+0x98/0xe0
    el0t_64_sync+0x170/0x178
unreferenced object 0xffff0000c8fc0300 (size 64):
  comm "systemd", pid 1, jiffies 4294668000
  hex dump (first 32 bytes):
    01 00 00 00 29 00 00 20 00 00 00 00 00 00 00 00  ....).. ........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 335bd269):
    kmemleak_alloc+0x3c/0x50
    __kmalloc_node_track_caller_noprof+0x370/0x500
    krealloc_noprof+0x238/0x300
    kvrealloc_noprof+0x44/0x100
    do_check_common+0x2668/0x2d50
    bpf_check+0x2464/0x2ec0
    bpf_prog_load+0x5c8/0xba8
    __sys_bpf+0x9c0/0x20a0
    __arm64_sys_bpf+0x24/0x60
    invoke_syscall.constprop.0+0x44/0x100
    el0_svc_common.constprop.0+0x3c/0xe0
    do_el0_svc+0x20/0x30
    el0_svc+0x30/0xe0
    el0t_64_sync_handler+0x98/0xe0
    el0t_64_sync+0x170/0x178
unreferenced object 0xffff0000c8c84980 (size 64):
  comm "systemd", pid 1, jiffies 4294668003
  hex dump (first 32 bytes):
    01 00 00 00 23 00 00 00 00 00 00 00 00 00 00 00  ....#...........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 3cc2e52e):
    kmemleak_alloc+0x3c/0x50
    __kmalloc_node_track_caller_noprof+0x370/0x500
    krealloc_noprof+0x238/0x300
    kvrealloc_noprof+0x44/0x100
    do_check_common+0x2668/0x2d50
    bpf_check+0x2464/0x2ec0
    bpf_prog_load+0x5c8/0xba8
    __sys_bpf+0x9c0/0x20a0
    __arm64_sys_bpf+0x24/0x60
    invoke_syscall.constprop.0+0x44/0x100
    el0_svc_common.constprop.0+0x3c/0xe0
    do_el0_svc+0x20/0x30
    el0_svc+0x30/0xe0
    el0t_64_sync_handler+0x98/0xe0
    el0t_64_sync+0x170/0x178

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bpf leaking memory
  2025-08-01 16:31 bpf leaking memory Jens Axboe
@ 2025-08-01 22:41 ` Alexei Starovoitov
  2025-08-01 23:26   ` Eduard Zingerman
  0 siblings, 1 reply; 3+ messages in thread
From: Alexei Starovoitov @ 2025-08-01 22:41 UTC (permalink / raw)
  To: Jens Axboe, Eduard
  Cc: Alexei Starovoitov, Daniel Borkmann,
	open list:XDP SOCKETS (AF_XDP), LKML

On Fri, Aug 1, 2025 at 9:31 AM Jens Axboe <axboe@kernel.dk> wrote:
>
> Hi,
>
> Current -git (any within the last day or two) leaks memory at boot,
> as reported by kmemleak, see below. This is running debian unstable
> on aarc64.
>
> unreferenced object 0xffff0000c820d000 (size 64):
>   comm "systemd", pid 1, jiffies 4294667980
>   hex dump (first 32 bytes):
>     01 00 00 00 00 00 ff ff 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace (crc 84021ac):
>     kmemleak_alloc+0x3c/0x50
>     __kmalloc_node_track_caller_noprof+0x370/0x500
>     krealloc_noprof+0x238/0x300
>     kvrealloc_noprof+0x44/0x100
>     do_check_common+0x2668/0x2d50
>     bpf_check+0x2464/0x2ec0
>     bpf_prog_load+0x5c8/0xba8

Thanks for the report.
Reproed on x86 with just boot and
# echo scan > /sys/kernel/debug/kmemleak
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xff1100010174d000 (size 64):
  comm "systemd", pid 1, jiffies 4294669288
  hex dump (first 32 bytes):
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 8c5ed7af):
    __kmalloc_node_track_caller_noprof+0x338/0x490
    krealloc_noprof+0x1db/0x2a0
    kvrealloc_noprof+0x36/0xb0
    do_check_common+0x2462/0x3290
    bpf_check+0x2c29/0x3770


Eduard,
please take a look.

        for (i = 0; i < env->scc_cnt; ++i) {
                info = env->scc_info[i];

loop is wrong. Nothing updates scc_cnt.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bpf leaking memory
  2025-08-01 22:41 ` Alexei Starovoitov
@ 2025-08-01 23:26   ` Eduard Zingerman
  0 siblings, 0 replies; 3+ messages in thread
From: Eduard Zingerman @ 2025-08-01 23:26 UTC (permalink / raw)
  To: Alexei Starovoitov, Jens Axboe
  Cc: Alexei Starovoitov, Daniel Borkmann,
	open list:XDP SOCKETS (AF_XDP), LKML

Hi Jens, Alexei,

Thank you for the report, I've reproduced the issue and sent a fix:
https://lore.kernel.org/bpf/20250801232330.1800436-1-eddyz87@gmail.com/T/
This is an embarrassing bug :(

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-01 23:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01 16:31 bpf leaking memory Jens Axboe
2025-08-01 22:41 ` Alexei Starovoitov
2025-08-01 23:26   ` Eduard Zingerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).