[PATCH bpf-next v5 2/9] bpf: Support private stack for struct_ops programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add 'priv_stack_allowed()' callback function in bpf_verifier_ops. If the
callback function returns true, the struct_ops are eligible to
use private stack. Otherwise, normal kernel stack is used.

Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx>
---
 include/linux/bpf.h   | 1 +
 kernel/bpf/verifier.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 6ad8ace7075a..a789cd2f5d6a 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -988,6 +988,7 @@ struct bpf_verifier_ops {
 	int (*btf_struct_access)(struct bpf_verifier_log *log,
 				 const struct bpf_reg_state *reg,
 				 int off, int size);
+	bool (*priv_stack_allowed)(void);
 };
 
 struct bpf_prog_offload_ops {
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index a12f5e823284..a14857015ad4 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5995,6 +5995,8 @@ static bool bpf_enable_private_stack(struct bpf_verifier_env *env)
 	case BPF_PROG_TYPE_PERF_EVENT:
 	case BPF_PROG_TYPE_RAW_TRACEPOINT:
 		return true;
+	case BPF_PROG_TYPE_STRUCT_OPS:
+		return env->ops->priv_stack_allowed && env->ops->priv_stack_allowed();
 	case BPF_PROG_TYPE_TRACING:
 		if (env->prog->expected_attach_type != BPF_TRACE_ITER)
 			return true;
-- 
2.43.5





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux