Skip to content

Commit 240436c

Browse files
committed
Daniel Borkmann says: ==================== bpf-next-for-netdev The following pull-request contains BPF updates for your *net-next* tree. We've added 22 non-merge commits during the last 3 day(s) which contain a total of 23 files changed, 652 insertions(+), 431 deletions(-). The main changes are: 1) Add verifier support for annotating user's global BPF subprogram arguments with few commonly requested annotations for a better developer experience, from Andrii Nakryiko. These tags are: - Ability to annotate a special PTR_TO_CTX argument - Ability to annotate a generic PTR_TO_MEM as non-NULL 2) Support BPF verifier tracking of BPF_JNE which helps cases when the compiler transforms (unsigned) "a > 0" into "if a == 0 goto xxx" and the like, from Menglong Dong. 3) Fix a warning in bpf_mem_cache's check_obj_size() as reported by LKP, from Hou Tao. 4) Re-support uid/gid options when mounting bpffs which had to be reverted with the prior token series revert to avoid conflicts, from Daniel Borkmann. 5) Fix a libbpf NULL pointer dereference in bpf_object__collect_prog_relos() found from fuzzing the library with malformed ELF files, from Mingyi Zhang. 6) Skip DWARF sections in libbpf's linker sanity check given compiler options to generate compressed debug sections can trigger a rejection due to misalignment, from Alyssa Ross. 7) Fix an unnecessary use of the comma operator in BPF verifier, from Simon Horman. 8) Fix format specifier for unsigned long values in cpustat sample, from Colin Ian King. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents cff9c56 + 5abde62 commit 240436c

23 files changed

+652
-431
lines changed

include/linux/bpf.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,12 +2466,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
24662466
struct btf_func_model *m);
24672467

24682468
struct bpf_reg_state;
2469-
int btf_check_subprog_arg_match(struct bpf_verifier_env *env, int subprog,
2470-
struct bpf_reg_state *regs);
2471-
int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,
2472-
struct bpf_reg_state *regs);
2473-
int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
2474-
struct bpf_reg_state *reg, u32 *nargs);
2469+
int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog);
24752470
int btf_check_type_match(struct bpf_verifier_log *log, const struct bpf_prog *prog,
24762471
struct btf *btf, const struct btf_type *t);
24772472
const char *btf_find_decl_tag_value(const struct btf *btf, const struct btf_type *pt,

include/linux/bpf_verifier.h

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,13 @@ static inline bool bpf_verifier_log_needed(const struct bpf_verifier_log *log)
606606

607607
#define BPF_MAX_SUBPROGS 256
608608

609+
struct bpf_subprog_arg_info {
610+
enum bpf_arg_type arg_type;
611+
union {
612+
u32 mem_size;
613+
};
614+
};
615+
609616
struct bpf_subprog_info {
610617
/* 'start' has to be the first field otherwise find_subprog() won't work */
611618
u32 start; /* insn idx of function entry point */
@@ -617,6 +624,10 @@ struct bpf_subprog_info {
617624
bool is_cb: 1;
618625
bool is_async_cb: 1;
619626
bool is_exception_cb: 1;
627+
bool args_cached: 1;
628+
629+
u8 arg_cnt;
630+
struct bpf_subprog_arg_info args[MAX_BPF_FUNC_REG_ARGS];
620631
};
621632

622633
struct bpf_verifier_env;
@@ -727,6 +738,16 @@ struct bpf_verifier_env {
727738
char tmp_str_buf[TMP_STR_BUF_LEN];
728739
};
729740

741+
static inline struct bpf_func_info_aux *subprog_aux(struct bpf_verifier_env *env, int subprog)
742+
{
743+
return &env->prog->aux->func_info_aux[subprog];
744+
}
745+
746+
static inline struct bpf_subprog_info *subprog_info(struct bpf_verifier_env *env, int subprog)
747+
{
748+
return &env->subprog_info[subprog];
749+
}
750+
730751
__printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log,
731752
const char *fmt, va_list args);
732753
__printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
@@ -764,14 +785,6 @@ bpf_prog_offload_replace_insn(struct bpf_verifier_env *env, u32 off,
764785
void
765786
bpf_prog_offload_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt);
766787

767-
int check_ptr_off_reg(struct bpf_verifier_env *env,
768-
const struct bpf_reg_state *reg, int regno);
769-
int check_func_arg_reg_off(struct bpf_verifier_env *env,
770-
const struct bpf_reg_state *reg, int regno,
771-
enum bpf_arg_type arg_type);
772-
int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
773-
u32 regno, u32 mem_size);
774-
775788
/* this lives here instead of in bpf.h because it needs to dereference tgt_prog */
776789
static inline u64 bpf_trampoline_compute_key(const struct bpf_prog *tgt_prog,
777790
struct btf *btf, u32 btf_id)

0 commit comments

Comments
 (0)