Skip to contentSkip to conversation

bpf: liveness: clarify get_outer_instance() handling in propagate_to_outer_instance()

PATCH Applied Shardul Bankar 3 participants 3 messages Oct 21, 2025 BPF

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 bpf: liveness: clarify get_outer_instance() handling in propagate_to_outer_instance()

propagate_to_outer_instance() calls get_outer_instance() and uses the returned pointer to reset and commit stack write marks. Under normal conditions, update_instance() guarantees that an outer instance exists, so get_outer_instance() cannot return an ERR_PTR.

However, explicitly checking for IS_ERR(outer_instance) makes this code more robust and self-documenting. It reduces cognitive load when reading the control flow and silences potential false-positive reports from static analysis or automated tooling.

No functional change intended.

---
 kernel/bpf/liveness.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/liveness.c +2 -0
index 3c611aba7f52..ae31f9ee4994 100644
@@ -522,6 +522,8 @@ static int propagate_to_outer_instance(struct bpf_verifier_env *env,
 
 	this_subprog_start = callchain_subprog_start(callchain);
 	outer_instance = get_outer_instance(env, instance);
+	if (IS_ERR(outer_instance))
+		return PTR_ERR(outer_instance);
 	callsite = callchain->callsites[callchain->curframe - 1];
 
 	reset_stack_write_marks(env, outer_instance, callsite);
Signature · 1 line
2.34.1
maintainer Acked-by on v3 1/1
#1 lore raw
Quoted 10 lines · Shardul Bankar

propagate_to_outer_instance() calls get_outer_instance() and uses the returned pointer to reset and commit stack write marks. Under normal conditions, update_instance() guarantees that an outer instance exists, so get_outer_instance() cannot return an ERR_PTR.

However, explicitly checking for IS_ERR(outer_instance) makes this code more robust and self-documenting. It reduces cognitive load when reading the control flow and silences potential false-positive reports from static analysis or automated tooling.

Quoted 6 lines

No functional change intended.

---

#2 lore raw
In reply to Shardul Bankar
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 11 lines · On Tue, 21 Oct 2025 13:38:46 +0530 you wrote:

propagate_to_outer_instance() calls get_outer_instance() and uses the returned pointer to reset and commit stack write marks. Under normal conditions, update_instance() guarantees that an outer instance exists, so get_outer_instance() cannot return an ERR_PTR.

However, explicitly checking for IS_ERR(outer_instance) makes this code more robust and self-documenting. It reduces cognitive load when reading the control flow and silences potential false-positive reports from static analysis or automated tooling.

[...]

Here is the summary with links:
- [v3,bpf] bpf: liveness: clarify get_outer_instance() handling in propagate_to_outer_instance()

    https://git.kernel.org/bpf/bpf-next/c/96d31dff3fa4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html