Commit b7e852a9 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Andrii Nakryiko

bpf: Remove unused arguments from btf_struct_access().

Remove unused arguments from btf_struct_access() callback.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarDavid Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20230404045029.82870-3-alexei.starovoitov@gmail.com
parent 7d64c513
...@@ -893,8 +893,7 @@ struct bpf_verifier_ops { ...@@ -893,8 +893,7 @@ struct bpf_verifier_ops {
struct bpf_prog *prog, u32 *target_size); struct bpf_prog *prog, u32 *target_size);
int (*btf_struct_access)(struct bpf_verifier_log *log, int (*btf_struct_access)(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size);
u32 *next_btf_id, enum bpf_type_flag *flag);
}; };
struct bpf_prog_offload_ops { struct bpf_prog_offload_ops {
......
...@@ -571,8 +571,7 @@ DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key); ...@@ -571,8 +571,7 @@ DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key);
extern struct mutex nf_conn_btf_access_lock; extern struct mutex nf_conn_btf_access_lock;
extern int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, extern int (*nfct_btf_struct_access)(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size);
u32 *next_btf_id, enum bpf_type_flag *flag);
typedef unsigned int (*bpf_dispatcher_fn)(const void *ctx, typedef unsigned int (*bpf_dispatcher_fn)(const void *ctx,
const struct bpf_insn *insnsi, const struct bpf_insn *insnsi,
......
...@@ -5459,7 +5459,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env, ...@@ -5459,7 +5459,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
const struct btf_type *t = btf_type_by_id(reg->btf, reg->btf_id); const struct btf_type *t = btf_type_by_id(reg->btf, reg->btf_id);
const char *tname = btf_name_by_offset(reg->btf, t->name_off); const char *tname = btf_name_by_offset(reg->btf, t->name_off);
enum bpf_type_flag flag = 0; enum bpf_type_flag flag = 0;
u32 btf_id; u32 btf_id = 0;
int ret; int ret;
if (!env->allow_ptr_leaks) { if (!env->allow_ptr_leaks) {
...@@ -5509,7 +5509,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env, ...@@ -5509,7 +5509,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
verbose(env, "verifier internal error: reg->btf must be kernel btf\n"); verbose(env, "verifier internal error: reg->btf must be kernel btf\n");
return -EFAULT; return -EFAULT;
} }
ret = env->ops->btf_struct_access(&env->log, reg, off, size, atype, &btf_id, &flag); ret = env->ops->btf_struct_access(&env->log, reg, off, size);
} else { } else {
/* Writes are permitted with default btf_struct_access for /* Writes are permitted with default btf_struct_access for
* program allocated objects (which always have ref_obj_id > 0), * program allocated objects (which always have ref_obj_id > 0),
......
...@@ -173,14 +173,11 @@ static int bpf_dummy_ops_check_member(const struct btf_type *t, ...@@ -173,14 +173,11 @@ static int bpf_dummy_ops_check_member(const struct btf_type *t,
static int bpf_dummy_ops_btf_struct_access(struct bpf_verifier_log *log, static int bpf_dummy_ops_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size)
u32 *next_btf_id,
enum bpf_type_flag *flag)
{ {
const struct btf_type *state; const struct btf_type *state;
const struct btf_type *t; const struct btf_type *t;
s32 type_id; s32 type_id;
int err;
type_id = btf_find_by_name_kind(reg->btf, "bpf_dummy_ops_state", type_id = btf_find_by_name_kind(reg->btf, "bpf_dummy_ops_state",
BTF_KIND_STRUCT); BTF_KIND_STRUCT);
...@@ -194,9 +191,10 @@ static int bpf_dummy_ops_btf_struct_access(struct bpf_verifier_log *log, ...@@ -194,9 +191,10 @@ static int bpf_dummy_ops_btf_struct_access(struct bpf_verifier_log *log,
return -EACCES; return -EACCES;
} }
err = btf_struct_access(log, reg, off, size, atype, next_btf_id, flag); if (off + size > sizeof(struct bpf_dummy_ops_state)) {
if (err < 0) bpf_log(log, "write access at off %d with size %d\n", off, size);
return err; return -EACCES;
}
return NOT_INIT; return NOT_INIT;
} }
......
...@@ -8742,20 +8742,18 @@ EXPORT_SYMBOL_GPL(nf_conn_btf_access_lock); ...@@ -8742,20 +8742,18 @@ EXPORT_SYMBOL_GPL(nf_conn_btf_access_lock);
int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, int (*nfct_btf_struct_access)(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size);
u32 *next_btf_id, enum bpf_type_flag *flag);
EXPORT_SYMBOL_GPL(nfct_btf_struct_access); EXPORT_SYMBOL_GPL(nfct_btf_struct_access);
static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log, static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size)
u32 *next_btf_id, enum bpf_type_flag *flag)
{ {
int ret = -EACCES; int ret = -EACCES;
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
if (nfct_btf_struct_access) if (nfct_btf_struct_access)
ret = nfct_btf_struct_access(log, reg, off, size, atype, next_btf_id, flag); ret = nfct_btf_struct_access(log, reg, off, size);
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
return ret; return ret;
...@@ -8822,14 +8820,13 @@ EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action); ...@@ -8822,14 +8820,13 @@ EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
static int xdp_btf_struct_access(struct bpf_verifier_log *log, static int xdp_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size)
u32 *next_btf_id, enum bpf_type_flag *flag)
{ {
int ret = -EACCES; int ret = -EACCES;
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
if (nfct_btf_struct_access) if (nfct_btf_struct_access)
ret = nfct_btf_struct_access(log, reg, off, size, atype, next_btf_id, flag); ret = nfct_btf_struct_access(log, reg, off, size);
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
return ret; return ret;
......
...@@ -72,8 +72,7 @@ static bool bpf_tcp_ca_is_valid_access(int off, int size, ...@@ -72,8 +72,7 @@ static bool bpf_tcp_ca_is_valid_access(int off, int size,
static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log, static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size)
u32 *next_btf_id, enum bpf_type_flag *flag)
{ {
const struct btf_type *t; const struct btf_type *t;
size_t end; size_t end;
......
...@@ -192,8 +192,7 @@ BTF_ID(struct, nf_conn___init) ...@@ -192,8 +192,7 @@ BTF_ID(struct, nf_conn___init)
/* Check writes into `struct nf_conn` */ /* Check writes into `struct nf_conn` */
static int _nf_conntrack_btf_struct_access(struct bpf_verifier_log *log, static int _nf_conntrack_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, const struct bpf_reg_state *reg,
int off, int size, enum bpf_access_type atype, int off, int size)
u32 *next_btf_id, enum bpf_type_flag *flag)
{ {
const struct btf_type *ncit, *nct, *t; const struct btf_type *ncit, *nct, *t;
size_t end; size_t end;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment