Skip to contentSkip to conversation

BPF: replace no-need function call with saved value

PATCH In review [email protected] 2 participants 2 messages Apr 7, 2023

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

PATCH 1/1 BPF: replace no-need function call with saved value

From: zhongjun <[email protected]>

The var 'is_priv' is already there, needn't call bpf_capable() again.
Applying this patch, to refine the codes making it robust and optimal.

base-commit: 919e659ed12568b5b8ba6c2ffdd82d8d31fc28af

---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
index d517d13878cf..bee9f29155b0 100644
@@ -17720,7 +17720,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr)
 	env->allow_uninit_stack = bpf_allow_uninit_stack();
 	env->bypass_spec_v1 = bpf_bypass_spec_v1();
 	env->bypass_spec_v4 = bpf_bypass_spec_v4();
-	env->bpf_capable = bpf_capable();
+	env->bpf_capable = is_priv;
 	env->rcu_tag_supported = btf_vmlinux &&
 		btf_find_by_name_kind(btf_vmlinux, "rcu", BTF_KIND_TYPE_TAG) > 0;
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 9 lines · On Thu, Apr 6, 2023 at 11:53 PM <[email protected]> wrote:

From: zhongjun <[email protected]>

The var 'is_priv' is already there, needn't call bpf_capable() again.
Applying this patch, to refine the codes making it robust and optimal.

base-commit: 919e659ed12568b5b8ba6c2ffdd82d8d31fc28af

Please stop spamming us.
All of your patches are auto-rejected from now on.