BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: don't skip other information if xlated_prog_insns is skipped
@ 2025-11-04 14:26 Altgelt, Max (Nextron)
  2025-11-15  3:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Altgelt, Max (Nextron) @ 2025-11-04 14:26 UTC (permalink / raw)
  To: bpf@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1601 bytes --]

If xlated_prog_insns should not be exposed, other information
(such as func_info) still can and should be filled in.
Therefore, instead of directly terminating in this case,
continue with the normal flow.

Signed-off-by: Max Altgelt <max.altgelt@nextron-systems.com>
---
 kernel/bpf/syscall.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 8a129746bd6c..5a0dc3ad2eeb 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5034,19 +5034,19 @@ static int bpf_prog_get_info_by_fd(struct file *file,
 		struct bpf_insn *insns_sanitized;
 		bool fault;
 
-		if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) {
+		if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
+			insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
+			if (!insns_sanitized)
+				return -ENOMEM;
+			uinsns = u64_to_user_ptr(info.xlated_prog_insns);
+			ulen = min_t(u32, info.xlated_prog_len, ulen);
+			fault = copy_to_user(uinsns, insns_sanitized, ulen);
+			kfree(insns_sanitized);
+			if (fault)
+				return -EFAULT;
+		} else {
 			info.xlated_prog_insns = 0;
-			goto done;
 		}
-		insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
-		if (!insns_sanitized)
-			return -ENOMEM;
-		uinsns = u64_to_user_ptr(info.xlated_prog_insns);
-		ulen = min_t(u32, info.xlated_prog_len, ulen);
-		fault = copy_to_user(uinsns, insns_sanitized, ulen);
-		kfree(insns_sanitized);
-		if (fault)
-			return -EFAULT;
 	}
 
 	if (bpf_prog_is_offloaded(prog->aux)) {
-- 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5382 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf] bpf: don't skip other information if xlated_prog_insns is skipped
  2025-11-04 14:26 [PATCH bpf] bpf: don't skip other information if xlated_prog_insns is skipped Altgelt, Max (Nextron)
@ 2025-11-15  3:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-15  3:00 UTC (permalink / raw)
  To: Altgelt, Max; +Cc: bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 4 Nov 2025 14:26:56 +0000 you wrote:
> If xlated_prog_insns should not be exposed, other information
> (such as func_info) still can and should be filled in.
> Therefore, instead of directly terminating in this case,
> continue with the normal flow.
> 
> Signed-off-by: Max Altgelt <max.altgelt@nextron-systems.com>
> 
> [...]

Here is the summary with links:
  - [bpf] bpf: don't skip other information if xlated_prog_insns is skipped
    https://git.kernel.org/bpf/bpf-next/c/4722981cca37

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-15  3:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 14:26 [PATCH bpf] bpf: don't skip other information if xlated_prog_insns is skipped Altgelt, Max (Nextron)
2025-11-15  3:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox