* [PATCH bpf-next] bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage
@ 2020-11-16 20:01 Martin KaFai Lau
2020-11-17 1:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Martin KaFai Lau @ 2020-11-16 20:01 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski, kernel-team, netdev
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>
---
net/core/bpf_sk_storage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index 359908a7d3c1..a32037daa933 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -415,7 +415,7 @@ static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
BPF_CALL_4(bpf_sk_storage_get_tracing, struct bpf_map *, map, struct sock *, sk,
void *, value, u64, flags)
{
- if (!in_serving_softirq() && !in_task())
+ if (in_irq() || in_nmi())
return (unsigned long)NULL;
return (unsigned long)____bpf_sk_storage_get(map, sk, value, flags);
@@ -424,7 +424,7 @@ BPF_CALL_4(bpf_sk_storage_get_tracing, struct bpf_map *, map, struct sock *, sk,
BPF_CALL_2(bpf_sk_storage_delete_tracing, struct bpf_map *, map,
struct sock *, sk)
{
- if (!in_serving_softirq() && !in_task())
+ if (in_irq() || in_nmi())
return -EPERM;
return ____bpf_sk_storage_delete(map, sk);
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage
2020-11-16 20:01 [PATCH bpf-next] bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage Martin KaFai Lau
@ 2020-11-17 1:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-11-17 1:00 UTC (permalink / raw)
To: Martin KaFai Lau; +Cc: bpf, ast, daniel, kuba, kernel-team, netdev
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
On Mon, 16 Nov 2020 12:01:13 -0800 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage
https://git.kernel.org/bpf/bpf-next/c/b93ef089d35c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-17 1:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 20:01 [PATCH bpf-next] bpf: Fix the irq and nmi check in bpf_sk_storage for tracing usage Martin KaFai Lau
2020-11-17 1:00 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.