Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage

The intention of the current check is to avoid using bpf_sk_storage
in irq and nmi. Jakub pointed out that the current check cannot
do that. For example, in_serving_softirq() returns true
if the softirq handling is interrupted by hard irq.

Fixes: 8e4597c627fb ("bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201116200113.2868539-1-kafai@fb.com

authored by

Martin KaFai Lau and committed by
Alexei Starovoitov
b93ef089 024cd2cb

+2 -2
+2 -2
net/core/bpf_sk_storage.c
··· 415 415 BPF_CALL_4(bpf_sk_storage_get_tracing, struct bpf_map *, map, struct sock *, sk, 416 416 void *, value, u64, flags) 417 417 { 418 - if (!in_serving_softirq() && !in_task()) 418 + if (in_irq() || in_nmi()) 419 419 return (unsigned long)NULL; 420 420 421 421 return (unsigned long)____bpf_sk_storage_get(map, sk, value, flags); ··· 424 424 BPF_CALL_2(bpf_sk_storage_delete_tracing, struct bpf_map *, map, 425 425 struct sock *, sk) 426 426 { 427 - if (!in_serving_softirq() && !in_task()) 427 + if (in_irq() || in_nmi()) 428 428 return -EPERM; 429 429 430 430 return ____bpf_sk_storage_delete(map, sk);