The package rpms/retsnoop.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/retsnoop.git/commit/?id=bd5eb2ffa....
Change:
+ExcludeArch: armv7hl
Thanks.
Full change:
============
commit 9990fc2ab5c55b5ac734b0c6d6c73ca08924f1c1
Author: Michel Alexandre Salim <salimma(a)fedoraproject.org>
Date: Wed Oct 26 12:21:22 2022 -0500
Actually copy in README.Fedora so it can be used
Signed-off-by: Michel Alexandre Salim <salimma(a)fedoraproject.org>
diff --git a/retsnoop.spec b/retsnoop.spec
index 43fec62..4204321 100644
--- a/retsnoop.spec
+++ b/retsnoop.spec
@@ -84,6 +84,7 @@ URL:
https://github.com/anakryiko/retsnoop
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: %{libbpf_url}/archive/v%{libbpf_version}/libbpf-%{libbpf_version}.tar.gz
Source2:
%{bpftool_url}/archive/v%{bpftool_version}/bpftool-%{bpftool_version}.tar.gz
+Source3: README.Fedora
Patch0:
%{url}/commit/64280c6d26d7ec5e9de99d9e6ceed5efa81f8d5c.patch#/%{name}-use-cflags.diff
Patch1:
%{url}/commit/36305e9cb6e244250734d64f6cc25fb8d68bf6f0.patch#/%{name}-fix-32-bit-builds.diff
@@ -124,6 +125,9 @@ rmdir bpftool
mv bpftool-%{bpftool_version} bpftool
# same license files as libbpf, no-op
+# README.Fedora
+cp -p %{SOURCE3} .
+
# Rust parts
# the path is hardcoded, make sure Cargo.toml is found in the expected place
ln -s sidecar/Cargo.toml .
commit bd5eb2ffaf705ae2621aaa229666d0be31c05133
Author: Michel Alexandre Salim <salimma(a)fedoraproject.org>
Date: Wed Oct 26 11:51:00 2022 -0500
Initial Fedora release
Signed-off-by: Michel Alexandre Salim <salimma(a)fedoraproject.org>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f2dd163
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/bpftool-*.*.*.tar.gz
+/libbpf-*.*.*.tar.gz
+/retsnoop-*.*.*.tar.gz
diff --git a/README.Fedora b/README.Fedora
new file mode 100644
index 0000000..2b8db06
--- /dev/null
+++ b/README.Fedora
@@ -0,0 +1,8 @@
+# Fedora-specific notes
+
+## KASLR
+`retsnoop` does not currently support DWARF-based symbolization on KASLR kernels,
including Fedora's:
+
+https://github.com/anakryiko/retsnoop/issues/23
+
+A workaround is to boot with `kaslr=no` on the kernel cmdline
diff --git a/retsnoop-fix-32-bit-builds.diff b/retsnoop-fix-32-bit-builds.diff
new file mode 100644
index 0000000..83b9479
--- /dev/null
+++ b/retsnoop-fix-32-bit-builds.diff
@@ -0,0 +1,66 @@
+From 36305e9cb6e244250734d64f6cc25fb8d68bf6f0 Mon Sep 17 00:00:00 2001
+From: Andrii Nakryiko <andrii(a)kernel.org>
+Date: Mon, 24 Oct 2022 11:32:01 -0700
+Subject: [PATCH] retsnoop: avoid using arch-specific integers in BPF skeleton
+
+Avoid using long in BPF skeletons (that is, don't declare global BPF
+variables using long types), because their size differs between 32-bit
+and 64-bit architectures. While on BPF side long is always 8 byte long.
+This should allow easier compilation on 32-bit architectures.
+
+Reported-by: Michel Alexandre Salim <michel(a)michel-slm.name>
+Signed-off-by: Andrii Nakryiko <andrii(a)kernel.org>
+---
+ src/calib_feat.bpf.c | 2 +-
+ src/mass_attach.bpf.c | 4 ++--
+ src/retsnoop.bpf.c | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/calib_feat.bpf.c b/src/calib_feat.bpf.c
+index 7c34525..d558824 100644
+--- a/src/calib_feat.bpf.c
++++ b/src/calib_feat.bpf.c
+@@ -10,7 +10,7 @@ char LICENSE[] SEC("license") = "Dual BSD/GPL";
+ #define MAX_ATTEMPTS 50
+
+ int my_tid = 0;
+-long entry_ip = 0;
++__u64 entry_ip = 0;
+ int kret_ip_off = 0;
+
+ bool has_bpf_get_func_ip = false;
+diff --git a/src/mass_attach.bpf.c b/src/mass_attach.bpf.c
+index dcc8d0b..9976b4d 100644
+--- a/src/mass_attach.bpf.c
++++ b/src/mass_attach.bpf.c
+@@ -11,7 +11,7 @@ extern int handle_func_exit(void *ctx, u32 func_id, u64 func_ip, u64
ret);
+
+ struct {
+ __uint(type, BPF_MAP_TYPE_HASH);
+- __type(key, long);
++ __type(key, __u64);
+ __type(value, unsigned);
+ } ip_to_id SEC(".maps");
+
+@@ -34,7 +34,7 @@ const volatile bool has_fentry_protection = false;
+
+ extern const volatile bool use_lbr;
+
+-static long lbr_szs[MAX_CPU_CNT];
++static __u64 lbr_szs[MAX_CPU_CNT];
+ static struct perf_branch_entry lbrs[MAX_CPU_CNT][MAX_LBR_ENTRIES];
+
+ /* has to be called from entry-point BPF program if not using
+diff --git a/src/retsnoop.bpf.c b/src/retsnoop.bpf.c
+index 8002e23..66112a0 100644
+--- a/src/retsnoop.bpf.c
++++ b/src/retsnoop.bpf.c
+@@ -67,7 +67,7 @@ const volatile __u32 comm_deny_cnt = 0;
+ const volatile __u64 duration_ns = 0;
+
+ char func_names[MAX_FUNC_CNT][MAX_FUNC_NAME_LEN] = {};
+-long func_ips[MAX_FUNC_CNT] = {};
++__u64 func_ips[MAX_FUNC_CNT] = {};
+ int func_flags[MAX_FUNC_CNT] = {};
+
+ const volatile char spaces[512] = {};
diff --git a/retsnoop-use-cflags.diff b/retsnoop-use-cflags.diff
new file mode 100644
index 0000000..476ebf4
--- /dev/null
+++ b/retsnoop-use-cflags.diff
@@ -0,0 +1,27 @@
+From 64280c6d26d7ec5e9de99d9e6ceed5efa81f8d5c Mon Sep 17 00:00:00 2001
+From: Michel Alexandre Salim <michel(a)michel-slm.name>
+Date: Mon, 24 Oct 2022 13:45:09 -0500
+Subject: [PATCH] use system CFLAGS if set
+
+When building `retsnoop` in Linux distributions, distribution-wide
+settings are passed via `CFLAGS`. Use this if set and provide a default
+otherwise.
+
+Signed-off-by: Michel Alexandre Salim <michel(a)michel-slm.name>
+---
+ src/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index 5b9c8fb..8090f42 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,7 +17,7 @@ SIDECAR := ../sidecar/target/$(if $(DEBUG),debug,release)/addr2line
+ # libbpf to avoid dependency on system-wide headers, which could be missing or
+ # outdated
+ INCLUDES := -I$(OUTPUT) -I../libbpf/include/uapi
+-CFLAGS := -g -Wall -O$(if $(DEBUG),0,2)
++CFLAGS ?= -g -Wall -O$(if $(DEBUG),0,2)
+
+ ARCH ?= $(shell uname -m \
+ | sed 's/x86_64/x86/' \
diff --git a/retsnoop.spec b/retsnoop.spec
new file mode 100644
index 0000000..43fec62
--- /dev/null
+++ b/retsnoop.spec
@@ -0,0 +1,168 @@
+# simfail runs on bare metal but not on Koji
+%bcond_with check
+
+%global toolchain clang
+
+# upstream build system requires the use of libbpf and bpftool sources
+# see
https://github.com/anakryiko/retsnoop/issues/22
+%global libbpf_url
https://github.com/libbpf/libbpf
+%global libbpf_version 1.0.1
+
+%global bpftool_url
https://github.com/libbpf/bpftool
+%global bpftool_version 7.0.0
+
+Name: retsnoop
+Version: 0.9.2
+Release: %autorelease
+Summary: A tool for investigating kernel error call stacks
+
+# retsnoop: BSD-2-Clause
+# bundled libbpf: LGPL-2.1-only OR BSD-2-Clause
+# statically linked rust crates
+#
+## Apache-2.0 OR MIT
+# addr2line
+# backtrace
+# bitflags
+# cc
+# cfg-if
+# cfg-if 0.1
+# cpp_demangle
+# crc32fast
+# dirs-sys
+# dirs2
+# fallible-iterator
+# findshlibs
+# flate2
+# getopts
+# gimli
+# glob
+# libc
+# memmap
+# object
+# pest
+# proc-macro2
+# quote
+# rustc-demangle
+# rustc-serialize
+# rustc-test
+# rustc_version 0.3
+# semver-parser
+# semver
+# smallvec
+# stable_deref_trait
+# syn
+# term 0.6
+# thiserror
+# time 0.1
+# ucd-trie
+# unicode-width
+# vec_map
+#
+## MIT
+# ansi_term
+# atty
+# clap2
+# strsim
+# textwrap 0.11
+# typed-arena
+#
+## 0BSD OR Apache-2.0 OR MIT
+# adler
+#
+## MIT OR Unlicense
+# memchr
+#
+## Apache-2.0 OR MIT OR Zlib
+# miniz_oxide
+#
+## (MIT OR Apache-2.0) AND Unicode-DFS-2016
+# unicode-ident
+#
+License: BSD-2-Clause AND (LGPL-2.1-only OR BSD-2-Clause) AND (Apache-2.0 OR MIT)
AND MIT AND (0BSD OR Apache-2.0 OR MIT) AND (MIT OR Unlicense) AND (Apache-2.0 OR MIT OR
Zlib) AND (MIT OR Apache-2.0) AND Unicode-DFS-2016
+URL:
https://github.com/anakryiko/retsnoop
+Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
+Source1: %{libbpf_url}/archive/v%{libbpf_version}/libbpf-%{libbpf_version}.tar.gz
+Source2:
%{bpftool_url}/archive/v%{bpftool_version}/bpftool-%{bpftool_version}.tar.gz
+Patch0:
%{url}/commit/64280c6d26d7ec5e9de99d9e6ceed5efa81f8d5c.patch#/%{name}-use-cflags.diff
+Patch1:
%{url}/commit/36305e9cb6e244250734d64f6cc25fb8d68bf6f0.patch#/%{name}-fix-32-bit-builds.diff
+
+# has a Rust component
+ExclusiveArch: %{rust_arches}
+# rust syn crate not compiling on 32-bit ARM
+ExcludeArch: armv7hl
+
+BuildRequires: clang
+BuildRequires: make
+BuildRequires: rust-packaging >= 21
+# libbpf deps
+BuildRequires: elfutils-libelf-devel
+
+# upstream does not support dynamic linking
+Provides: bundled(libbpf) = %{libbpf_version}
+
+%description
+retsnoop is BPF-based tool that is meant to help debugging kernel issues. It
+allows to capture call stacks of kernel functions that return errors (NULL or
+-Exxx) and emits every such detected call stack, along with the captured
+results.
+
+
+%prep
+%autosetup -p1
+# provide the libbpf version we specify rather than using git submodule
+tar xf %{SOURCE1}
+rmdir libbpf
+mv libbpf-%{libbpf_version} libbpf
+mv libbpf/LICENSE libbpf-LICENSE
+mv libbpf/LICENSE.BSD-2-Clause libbpf-LICENSE.BSD-2-Clause
+mv libbpf/LICENSE.LGPL-2.1 libbpf-LICENSE.LGPL-2.1
+
+# provide the bpftool version we specify rather than using git submodule
+tar xf %{SOURCE2}
+rmdir bpftool
+mv bpftool-%{bpftool_version} bpftool
+# same license files as libbpf, no-op
+
+# Rust parts
+# the path is hardcoded, make sure Cargo.toml is found in the expected place
+ln -s sidecar/Cargo.toml .
+# the checksums in the lock file might not match
+rm sidecar/Cargo.lock
+%cargo_prep
+
+%generate_buildrequires
+%cargo_generate_buildrequires
+
+
+%build
+%if 0%{?fedora} < 36
+# this is only called automatically after
+#
https://www.fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck
+%set_build_flags
+%endif
+cd sidecar
+%cargo_build
+cd -
+%make_build -C src HOSTCC=clang
+
+
+%install
+%make_install -C src prefix=%{_prefix}
+
+
+%if %{with check}
+%check
+./src/simfail -a
+%endif
+
+
+%files
+%license LICENSE libbpf-LICENSE*
+%doc README.md TODO.md README.Fedora
+%{_bindir}/retsnoop
+%{_bindir}/simfail
+
+
+%changelog
+%autochangelog
diff --git a/series b/series
new file mode 100644
index 0000000..9696768
--- /dev/null
+++ b/series
@@ -0,0 +1,2 @@
+retsnoop-use-cflags.diff
+retsnoop-fix-32-bit-builds.diff
diff --git a/sources b/sources
new file mode 100644
index 0000000..5292935
--- /dev/null
+++ b/sources
@@ -0,0 +1,3 @@
+SHA512 (bpftool-7.0.0.tar.gz) =
168de172ee557ac4c4ac6f42b74c0876a68c45273f0582eb577df9cd853697ba8109e19e5e0ab0b10f824875fa8dc3cb56b557df2aaba462236d60d2afebc45e
+SHA512 (libbpf-1.0.1.tar.gz) =
2ee6d85c0a33f723e5b93ddddf97118e67754c9e44ca0449ceb49126820f89fea9ddc282a5add764dc4da090af6164cc6641b497489253d192ed01bc397df9be
+SHA512 (retsnoop-0.9.2.tar.gz) =
469a3c5175407538af3abfc863cc834465a8318a428d618c0de888f612877d8c6f759df1a53f3f5d1260af3af87f66b9890202e45a4567c0dcde7187613b47d1