Re: [PATCH bpf-next v11 09/13] bpf: validate value_type

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

 





On 11/9/23 18:11, Martin KaFai Lau wrote:
On 11/6/23 12:12 PM, thinker.li@xxxxxxxxx wrote:
From: Kui-Feng Lee <thinker.li@xxxxxxxxx>

A value_type should consist of three components: refcnt, state, and data.
refcnt and state has been move to struct bpf_struct_ops_common_value to
make it easier to check the value type.

Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
---
  include/linux/bpf.h         | 14 ++++++
  kernel/bpf/bpf_struct_ops.c | 93 ++++++++++++++++++++++++-------------
  2 files changed, 74 insertions(+), 33 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c287f42b2e48..48e97a255945 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -3231,4 +3231,18 @@ static inline bool bpf_is_subprog(const struct bpf_prog *prog)
      return prog->aux->func_idx != 0;
  }
+#ifdef CONFIG_BPF_JIT

There is an existing "#if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL)" above and a few bpf_struct_ops_*() has already been there. Does it need another separate one which is only CONFIG_BPF_JIT here?

+enum bpf_struct_ops_state {
+    BPF_STRUCT_OPS_STATE_INIT,
+    BPF_STRUCT_OPS_STATE_INUSE,
+    BPF_STRUCT_OPS_STATE_TOBEFREE,
+    BPF_STRUCT_OPS_STATE_READY,
+};
+
+struct bpf_struct_ops_common_value {
+    refcount_t refcnt;
+    enum bpf_struct_ops_state state;
+};

Do the struct and enum really need to be in ifdef?

+#endif /* CONFIG_BPF_JIT */
+

I just removed this pair of #if-else.
You are right! They are not necessary.




[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