Subject: kmemleak in flowtable xdp

From: Pablo Neira Ayuso <[email-masked]>
Date: Wed, 9 Oct 2024 11:39:51 +0200

Hi Lorenzo,

kmemleak is not happy here when running tests:

    [<00000000be65a589>] __kmalloc_cache_noprof+0x280/0x310
    [<00000000c6569ad4>] nf_flow_offload_xdp_setup+0x70/0x8d0 [nf_flow_table]
    [<000000001efe6e35>] nf_flow_table_offload_setup+0x324/0x610 [nf_flow_table]
    [<000000005d9c9ad6>] nft_register_flowtable_net_hooks+0x3f4/0x890 [nf_tables]
    [<00000000de9071ee>] nf_tables_newflowtable+0xf61/0x18c0 [nf_tables]
    [<00000000924f5d86>] nfnetlink_rcv_batch+0x12c1/0x1c50 [nfnetlink]
    [<000000003fa07104>] nfnetlink_rcv+0x2a3/0x320 [nfnetlink]
    [<000000009fd1c990>] netlink_unicast+0x588/0x7f0
    [<00000000ee126795>] netlink_sendmsg+0x702/0xba0
    [<000000000ddf29fb>] ____sys_sendmsg+0x7cd/0x9a0
    [<0000000027b80416>] ___sys_sendmsg+0xd6/0x140
    [<00000000edfe1eb5>] __sys_sendmsg+0xba/0x150
    [<000000009d5eb571>] do_syscall_64+0x47/0x110
    [<0000000077c3a21e>] entry_SYSCALL_64_after_hwframe+0x76/0x7e

nf_flow_offload_xdp_setup+0x70

56
57              ft_elem = kzalloc(sizeof(*ft_elem), GFP_KERNEL_ACCOUNT);
58              if (!ft_elem)
59                      return -ENOMEM;
60
61              ft_elem->ft = ft; <--- HERE
62
63              mutex_lock(&nf_xdp_hashtable_lock);
64
65              hash_for_each_possible(nf_xdp_hashtable,

Thanks.