BPF List
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: kkd@meta.com, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	kernel-team@fb.com
Subject: [PATCH bpf-next v1 2/7] bpf: Be consistent between {acquire,find,release}_lock_state
Date: Wed, 20 Nov 2024 16:53:24 -0800	[thread overview]
Message-ID: <20241121005329.408873-3-memxor@gmail.com> (raw)
In-Reply-To: <20241121005329.408873-1-memxor@gmail.com>

Both acquire_lock_state and release_lock_state take the bpf_func_state
as a parameter, while find_lock_state does not. Future patches will end
up requiring operating on non-cur_func(env) bpf_func_state (for
resilient locks), hence just make the prototype consistent and take
bpf_func_state directly.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 kernel/bpf/verifier.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c106720d0c62..0ff436c06c13 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1436,10 +1436,9 @@ static int release_lock_state(struct bpf_func_state *state, int type, int id, vo
 	return -EINVAL;
 }
 
-static struct bpf_resource_state *find_lock_state(struct bpf_verifier_env *env, enum res_state_type type,
+static struct bpf_resource_state *find_lock_state(struct bpf_func_state *state, enum res_state_type type,
 						   int id, void *ptr)
 {
-	struct bpf_func_state *state = cur_func(env);
 	int i;
 
 	for (i = 0; i < state->acquired_res; i++) {
@@ -11873,7 +11872,7 @@ static int check_reg_allocation_locked(struct bpf_verifier_env *env, struct bpf_
 
 	if (!cur_func(env)->active_locks)
 		return -EINVAL;
-	s = find_lock_state(env, RES_TYPE_LOCK, id, ptr);
+	s = find_lock_state(cur_func(env), RES_TYPE_LOCK, id, ptr);
 	if (!s) {
 		verbose(env, "held lock and object are not in the same allocation\n");
 		return -EINVAL;
-- 
2.43.5


  parent reply	other threads:[~2024-11-21  0:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21  0:53 [PATCH bpf-next v1 0/7] IRQ save/restore Kumar Kartikeya Dwivedi
2024-11-21  0:53 ` [PATCH bpf-next v1 1/7] bpf: Refactor and rename resource management Kumar Kartikeya Dwivedi
2024-11-21 16:57   ` Eduard Zingerman
2024-11-21 17:17     ` Kumar Kartikeya Dwivedi
2024-11-22  0:24   ` Alexei Starovoitov
2024-11-22  0:31     ` Kumar Kartikeya Dwivedi
2024-11-21  0:53 ` Kumar Kartikeya Dwivedi [this message]
2024-11-21 17:54   ` [PATCH bpf-next v1 2/7] bpf: Be consistent between {acquire,find,release}_lock_state Eduard Zingerman
2024-11-21  0:53 ` [PATCH bpf-next v1 3/7] bpf: Consolidate RCU and preempt locks in bpf_func_state Kumar Kartikeya Dwivedi
2024-11-21 18:09   ` Eduard Zingerman
2024-11-21 18:12     ` Kumar Kartikeya Dwivedi
2024-11-21 18:54       ` Eduard Zingerman
2024-11-21 22:04         ` Kumar Kartikeya Dwivedi
2024-11-21  0:53 ` [PATCH bpf-next v1 4/7] bpf: Refactor mark_{dynptr,iter}_read Kumar Kartikeya Dwivedi
2024-11-21 18:00   ` Eduard Zingerman
2024-11-21  0:53 ` [PATCH bpf-next v1 5/7] bpf: Introduce support for bpf_local_irq_{save,restore} Kumar Kartikeya Dwivedi
2024-11-21 20:21   ` Eduard Zingerman
2024-11-21 22:06     ` Kumar Kartikeya Dwivedi
2024-11-21 23:08       ` Eduard Zingerman
2024-11-21 23:12         ` Kumar Kartikeya Dwivedi
2024-11-22  0:30           ` Eduard Zingerman
2024-11-22  0:32       ` Alexei Starovoitov
2024-11-22  0:42         ` Kumar Kartikeya Dwivedi
2024-11-21 22:46   ` kernel test robot
2024-11-21  0:53 ` [PATCH bpf-next v1 6/7] selftests/bpf: Expand coverage of preempt tests to sleepable kfunc Kumar Kartikeya Dwivedi
2024-11-21 20:23   ` Eduard Zingerman
2024-11-21  0:53 ` [PATCH bpf-next v1 7/7] selftests/bpf: Add IRQ save/restore tests Kumar Kartikeya Dwivedi
2024-11-21 20:43   ` Eduard Zingerman
2024-11-21 22:07     ` Kumar Kartikeya Dwivedi
2024-11-21 23:09       ` Eduard Zingerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241121005329.408873-3-memxor@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox