On 6/10/25 17:12, Руслан Семченко wrote:
From d1adf16aa1c43b44b536532a8053521d119f2f11 Mon Sep 17 00:00:00 2001
From: RuslanSemchenko <uncleruc2075@xxxxxxxxx>
Date: Tue, 10 Jun 2025 15:24:10 +0000
Subject: [PATCH] tools/bpf/bpf_jit_disasm.c: fix potential negative index
dereference after readlink failure
If readlink() fails, len is -1, which could cause tpath[-1]=0 out-of-bounds
write. Set len=0 if readlink fails, to avoid this.
Signed-off-by: RuslanSemchenko <uncleruc2075@xxxxxxxxx>
---
tools/bpf/bpf_jit_disasm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/bpf/bpf_jit_disasm.c b/tools/bpf/bpf_jit_disasm.c
index 1baee9e2aba9..5ab8f80e2834 100644
--- a/tools/bpf/bpf_jit_disasm.c
+++ b/tools/bpf/bpf_jit_disasm.c
@@ -45,6 +45,8 @@ static void get_exec_path(char *tpath, size_t size)
assert(path);
len = readlink(path, tpath, size);
+ if (len < 0)
+ len = 0;
tpath[len] = 0;
free(path);
--
I'm not sure if maintainers will be able to apply this patch.
Maybe try to resend it with `git send-email --to bpf@xxxxxxxxxxxxxxx
path/to/patch`
Subject, From, Date should not be in the mail body.