From: Aichun Li liaichun@huawei.com
mainline inclusion from mainline-v5.11-rc5 commit 4519efa6f8ea343e43ade21b0189b0b295439202 category: bugfix bugzilla: 47241 CVE: NA
-------------------
The BPF_PROG_LOAD condition for kernel version <= 5.1 is
log->len_total > UINT_MAX >> 8 /* (16 * 1024 * 1024) - 1 */
Signed-off-by: McCabe, Robert J robert.mccabe@rockwellcollins.com Signed-off-by: Alexei Starovoitov ast@kernel.org
Signed-off-by: Aichun Li liaichun@huawei.com Reviewed-by: Yue Haibing yuehaibing@huawei.com Reviewed-by: Di Zhu zhudi21@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- tools/lib/bpf/bpf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index c3145ab3bdcac..4e603c5d5d319 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -71,7 +71,7 @@ struct bpf_load_program_attr { };
/* Recommend log buffer size */ -#define BPF_LOG_BUF_SIZE (256 * 1024) +#define BPF_LOG_BUF_SIZE (UINT32_MAX >> 8) /* verifier maximum in kernels <= 5.1 */ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, char *log_buf, size_t log_buf_sz); int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,