]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, sockmap: Add locking annotations to iterator
authorLorenz Bauer <lmb@cloudflare.com>
Mon, 12 Oct 2020 09:18:50 +0000 (11:18 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 15 Oct 2020 18:49:56 +0000 (20:49 +0200)
commitb6d1a2b16036fe87b1f30dd11a4881cebb59280b
treeeb606d94e8041a53fea006c6db698f0d1788c1b3
parent336dc8f6c26e7883888d0a2accefba70611e4bf0
bpf, sockmap: Add locking annotations to iterator

The sparse checker currently outputs the following warnings:

    include/linux/rcupdate.h:632:9: sparse: sparse: context imbalance in 'sock_hash_seq_start' - wrong count at exit
    include/linux/rcupdate.h:632:9: sparse: sparse: context imbalance in 'sock_map_seq_start' - wrong count at exit

Add the necessary __acquires and __release annotations to make the
iterator locking schema palatable to sparse. Also add __must_hold
for good measure.

The kernel codebase uses both __acquires(rcu) and __acquires(RCU).
I couldn't find any guidance which one is preferred, so I used
what is easier to type out.

Fixes: c5e362908802 ("net: Allow iterating sockmap and sockhash")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20201012091850.67452-1-lmb@cloudflare.com
net/core/sock_map.c