Skip to contentSkip to conversation

kcm: use BPF_PROG_RUN

PATCH Applied Sami Tolvanen 5 participants 6 messages Sep 5, 2019 – Sep 24, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcm: use BPF_PROG_RUN

Instead of invoking struct bpf_prog::bpf_func directly, use the BPF_PROG_RUN macro.

---
 net/kcm/kcmsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/kcm/kcmsock.c +1 -1
index 5dbc0c48f8cb..f350c613bd7d 100644
@@ -379,7 +379,7 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
 	struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
 	struct bpf_prog *prog = psock->bpf_prog;
 
-	return (*prog->bpf_func)(skb, prog->insnsi);
+	return BPF_PROG_RUN(prog, skb);
 }
 
 static int kcm_read_sock_done(struct strparser *strp, int err)
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Sami Tolvanen

Instead of invoking struct bpf_prog::bpf_func directly, use the BPF_PROG_RUN macro.

Quoted 18 lines
---
  net/kcm/kcmsock.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/kcm/kcmsock.c +1 -1
index 5dbc0c48f8cb..f350c613bd7d 100644
@@ -379,7 +379,7 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
  	struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
  	struct bpf_prog *prog = psock->bpf_prog;
 
-	return (*prog->bpf_func)(skb, prog->insnsi);
+	return BPF_PROG_RUN(prog, skb);
  }
 
  static int kcm_read_sock_done(struct strparser *strp, int err)
#3 lore raw
Quoted 5 lines · Alexei Starovoitov
Quoted 4 lines · Yonghong Song

On 9/5/19 2:15 PM, Sami Tolvanen wrote:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Instead of invoking struct bpf_prog::bpf_func directly, use the BPF_PROG_RUN macro.

Applied. Thanks

Then we probably need this as well, what do you think ?

net/kcm/kcmsock.c +6 -1
index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..6508e88efdaf57f206b84307f5ad5915a2ed21f7 100644
@@ -378,8 +378,13 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
 {
        struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
        struct bpf_prog *prog = psock->bpf_prog;
+       int res;
 
-       return BPF_PROG_RUN(prog, skb);
+       preempt_disable();
+       res = BPF_PROG_RUN(prog, skb);
+       preempt_enable();
+
+       return res;
 }
 
 static int kcm_read_sock_done(struct strparser *strp, int err)
maintainer
#4 lore raw
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Alexei Starovoitov
Quoted 4 lines · Yonghong Song
Quoted 3 lines · Sami Tolvanen

Instead of invoking struct bpf_prog::bpf_func directly, use the BPF_PROG_RUN macro.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied. Thanks

Then we probably need this as well, what do you think ?

Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption disabled") probably forgot about it since it wasn't using BPF_PROG_RUN() in the first place. If you get a chance, please send a proper patch, thanks!

Quoted 19 lines
net/kcm/kcmsock.c +6 -1
index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..6508e88efdaf57f206b84307f5ad5915a2ed21f7 100644
@@ -378,8 +378,13 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
 {
        struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
        struct bpf_prog *prog = psock->bpf_prog;
+       int res;
 
-       return BPF_PROG_RUN(prog, skb);
+       preempt_disable();
+       res = BPF_PROG_RUN(prog, skb);
+       preempt_enable();
+
+       return res;
 }
 
 static int kcm_read_sock_done(struct strparser *strp, int err)
#5 lore raw
Quoted 11 lines · Daniel Borkmann
Quoted 10 lines · Eric Dumazet
Quoted 9 lines · Alexei Starovoitov
Quoted 7 lines · Yonghong Song
Quoted 4 lines · Sami Tolvanen

Instead of invoking struct bpf_prog::bpf_func directly, use the BPF_PROG_RUN macro.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Applied. Thanks

Then we probably need this as well, what do you think ?

Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption disabled") probably forgot about it since it wasn't using BPF_PROG_RUN() in the first place. If you get a chance, please send a proper patch, thanks!

Sure, I will send this today.