]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix memlock accounting for sock_hash
authorAndrey Ignatov <rdna@fb.com>
Fri, 12 Jun 2020 00:08:57 +0000 (17:08 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Jun 2020 22:21:29 +0000 (15:21 -0700)
commitecb2c3fae9664f01018cee05de50b5f8d5b3c8c1
tree2ea585b365400086452e0f5352bf893fb693777f
parent1d79e18424e790e9e5501e73450981d8918447c3
bpf: Fix memlock accounting for sock_hash

Add missed bpf_map_charge_init() in sock_hash_alloc() and
correspondingly bpf_map_charge_finish() on ENOMEM.

It was found accidentally while working on unrelated selftest that
checks "map->memory.pages > 0" is true for all map types.

Before:
# bpftool m l
...
3692: sockhash  name m_sockhash  flags 0x0
key 4B  value 4B  max_entries 8  memlock 0B

After:
# bpftool m l
...
84: sockmap  name m_sockmap  flags 0x0
key 4B  value 4B  max_entries 8  memlock 4096B

Fixes: eaf66302e456 ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200612000857.2881453-1-rdna@fb.com
net/core/sock_map.c