From 4fe4dffa1359921bb1bd316fbe6057dd576e8dbb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 19 May 2025 15:33:24 +0000 Subject: [PATCH] Revert "bpf: check changes_pkt_data property for extension programs" This reverts commit 7197fc4acdf238ec8ad06de5a8235df0c1f9c7d7 which is commit 81f6d0530ba031b5f038a091619bf2ff29568852 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Ic18aced32f0a5aa6ffa03d264a5a59c7b915e840 Signed-off-by: Greg Kroah-Hartman --- include/linux/bpf.h | 1 - kernel/bpf/verifier.c | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 168b6cd303c8..e719857effa1 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1427,7 +1427,6 @@ struct bpf_prog_aux { bool sleepable; bool tail_call_reachable; bool xdp_has_frags; - bool changes_pkt_data; /* BTF_KIND_FUNC_PROTO for valid attach_btf_id */ const struct btf_type *attach_func_proto; /* function name for valid attach_btf_id */ diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 27e4e7dedbad..9093c1ba7ea9 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -15496,7 +15496,6 @@ static int check_cfg(struct bpf_verifier_env *env) } } ret = 0; /* cfg looks good */ - env->prog->aux->changes_pkt_data = env->subprog_info[0].changes_pkt_data; err_free: kvfree(insn_state); @@ -18655,7 +18654,6 @@ static int jit_subprogs(struct bpf_verifier_env *env) } func[i]->aux->num_exentries = num_exentries; func[i]->aux->tail_call_reachable = env->subprog_info[i].tail_call_reachable; - func[i]->aux->changes_pkt_data = env->subprog_info[i].changes_pkt_data; func[i] = bpf_int_jit_compile(func[i]); if (!func[i]->jited) { err = -ENOTSUPP; @@ -19968,12 +19966,6 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, "Extension programs should be JITed\n"); return -EINVAL; } - if (prog->aux->changes_pkt_data && - !aux->func[subprog]->aux->changes_pkt_data) { - bpf_log(log, - "Extension program changes packet data, while original does not\n"); - return -EINVAL; - } } if (!tgt_prog->jited) { bpf_log(log, "Can attach to only JITed progs\n"); @@ -20433,6 +20425,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3 if (ret < 0) goto skip_full_check; + ret = check_attach_btf_id(env); + if (ret) + goto skip_full_check; + ret = resolve_pseudo_ldimm64(env); if (ret < 0) goto skip_full_check; @@ -20447,10 +20443,6 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3 if (ret < 0) goto skip_full_check; - ret = check_attach_btf_id(env); - if (ret) - goto skip_full_check; - ret = do_check_subprogs(env); ret = ret ?: do_check_main(env);