[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<AM6PR03MB5080C639B73200461C2087AE99FE2@AM6PR03MB5080.eurprd03.prod.outlook.com>
Date: Fri, 14 Feb 2025 00:26:53 +0000
From: Juntong Deng <juntong.deng@...look.com>
To: ast@...nel.org,
daniel@...earbox.net,
john.fastabend@...il.com,
andrii@...nel.org,
martin.lau@...ux.dev,
eddyz87@...il.com,
song@...nel.org,
yonghong.song@...ux.dev,
kpsingh@...nel.org,
sdf@...ichev.me,
haoluo@...gle.com,
jolsa@...nel.org,
memxor@...il.com,
snorcht@...il.com
Cc: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH bpf-next 2/6] bpf: Add max_acquired_refs to struct bpf_prog
This patch adds max_acquired_refs to struct bpf_prog.
max_acquired_refs is used to record the maximum number of references
that a bpf program may have acquired at the same time.
Signed-off-by: Juntong Deng <juntong.deng@...look.com>
---
include/linux/bpf.h | 1 +
kernel/bpf/verifier.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index f3f50e29d639..3ccc20f936b2 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1618,6 +1618,7 @@ struct bpf_prog {
enum bpf_attach_type expected_attach_type; /* For some prog types */
u32 len; /* Number of filter blocks */
u32 jited_len; /* Size of jited insns in bytes */
+ u32 max_acquired_refs;
u8 tag[BPF_TAG_SIZE];
struct bpf_prog_stats __percpu *stats;
int __percpu *active;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 9971c03adfd5..2d7f5aea90df 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1479,6 +1479,9 @@ static struct bpf_reference_state *acquire_reference_state(struct bpf_verifier_e
return NULL;
state->refs[new_ofs].insn_idx = insn_idx;
+ if (env->prog->max_acquired_refs < state->acquired_refs)
+ env->prog->max_acquired_refs = state->acquired_refs;
+
return &state->refs[new_ofs];
}
@@ -18927,6 +18930,8 @@ static int do_check(struct bpf_verifier_env *env)
bool do_print_state = false;
int prev_insn_idx = -1;
+ env->prog->max_acquired_refs = 0;
+
for (;;) {
bool exception_exit = false;
struct bpf_insn *insn;
--
2.39.5
Powered by blists - more mailing lists