summaryrefslogtreecommitdiff
path: root/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch
diff options
context:
space:
mode:
authorHolger Hoffstätte <holger@applied-asynchrony.com>2025-05-01 22:37:49 +0200
committerSam James <sam@gentoo.org>2025-05-02 05:37:28 +0100
commite6f6223943aefc793e2baf8e7e5d5982038ace8a (patch)
tree4990edfacabd82cf0d4b6675dbba96cfd8a6393c /dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch
parentbf70fbf7b0dc97fbc97af579954ea81a8df36113 (diff)
downloadgentoo-e6f6223943aefc793e2baf8e7e5d5982038ace8a.tar.gz
gentoo-e6f6223943aefc793e2baf8e7e5d5982038ace8a.tar.bz2
gentoo-e6f6223943aefc793e2baf8e7e5d5982038ace8a.zip
dev-util/bpftool: set error code in do_loader()
Patch from -stable kernel tree to correctly return error code when loading a BPF program fails. Bug: https://github.com/libbpf/bpftool/issues/156 Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com> Part-of: https://github.com/gentoo/gentoo/pull/41884 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch')
-rw-r--r--dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch b/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch
new file mode 100644
index 000000000000..8b77603e13ba
--- /dev/null
+++ b/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch
@@ -0,0 +1,45 @@
+Patch from: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=02a4694107b4c830d4bd6d194e98b3ac0bc86f29
+Adapted patch prefix to match the GH mirror sources.
+
+From 91588da58ed38e4ec870d479ab2d9467288893d2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Mar 2025 12:12:37 +0900
+Subject: bpf: bpftool: Setting error code in do_loader()
+
+From: Sewon Nam <swnam0729@gmail.com>
+
+[ Upstream commit 02a4694107b4c830d4bd6d194e98b3ac0bc86f29 ]
+
+We are missing setting error code in do_loader() when
+bpf_object__open_file() fails. This means the command's exit status code
+will be successful, even though the operation failed. So make sure to
+return the correct error code. To maintain consistency with other
+locations where bpf_object__open_file() is called, return -1.
+
+ [0] Closes: https://github.com/libbpf/bpftool/issues/156
+
+Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
+Signed-off-by: Sewon Nam <swnam0729@gmail.com>
+Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
+Tested-by: Quentin Monnet <qmo@kernel.org>
+Reviewed-by: Quentin Monnet <qmo@kernel.org>
+Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
+Link: https://lore.kernel.org/bpf/20250311031238.14865-1-swnam0729@gmail.com
+Signed-off-by: Alexei Starovoitov <ast@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/bpf/bpftool/prog.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
+index e71be67f1d865..52ffb74ae4e89 100644
+--- a/src/prog.c
++++ b/src/prog.c
+@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
+
+ obj = bpf_object__open_file(file, &open_opts);
+ if (!obj) {
++ err = -1;
+ p_err("failed to open object file");
+ goto err_close_obj;
+ }