diff --git a/0001-sync-bpf-helper-funcs-from-kernel.patch b/0001-sync-bpf-helper-funcs-from-kernel.patch deleted file mode 100644 index 02a56e5463f37650ff1361d8a96bb4d8334ba3f4..0000000000000000000000000000000000000000 --- a/0001-sync-bpf-helper-funcs-from-kernel.patch +++ /dev/null @@ -1,360 +0,0 @@ -From 78ac59d3afde9e11df3223cb669c54b1b77400e3 Mon Sep 17 00:00:00 2001 -From: kwb0523 -Date: Fri, 4 Aug 2023 16:30:46 +0800 -Subject: [PATCH] sync bpf helper funcs from kernel - ---- - src/bpf_helper_defs.h | 339 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 339 insertions(+) - -diff --git a/src/bpf_helper_defs.h b/src/bpf_helper_defs.h -index abe612e..95f05f1 100644 ---- a/src/bpf_helper_defs.h -+++ b/src/bpf_helper_defs.h -@@ -4370,4 +4370,343 @@ static void *(*bpf_kptr_xchg)(void *map_value, void *ptr) = (void *) 194; - */ - static void *(*bpf_map_lookup_percpu_elem)(void *map, const void *key, __u32 cpu) = (void *) 195; - -+/* -+ * bpf_skc_to_mptcp_sock -+ * -+ * Dynamically cast a *sk* pointer to a *mptcp_sock* pointer. -+ * -+ * Returns -+ * *sk* if casting is valid, or **NULL** otherwise. -+ */ -+static struct mptcp_sock *(*bpf_skc_to_mptcp_sock)(void *sk) = (void *) 196; -+ -+/* -+ * bpf_dynptr_from_mem -+ * -+ * Get a dynptr to local memory *data*. -+ * -+ * *data* must be a ptr to a map value. -+ * The maximum *size* supported is DYNPTR_MAX_SIZE. -+ * *flags* is currently unused. -+ * -+ * Returns -+ * 0 on success, -E2BIG if the size exceeds DYNPTR_MAX_SIZE, -+ * -EINVAL if flags is not 0. -+ */ -+static long (*bpf_dynptr_from_mem)(void *data, __u32 size, __u64 flags, struct bpf_dynptr *ptr) = (void *) 197; -+ -+/* -+ * bpf_ringbuf_reserve_dynptr -+ * -+ * Reserve *size* bytes of payload in a ring buffer *ringbuf* -+ * through the dynptr interface. *flags* must be 0. -+ * -+ * Please note that a corresponding bpf_ringbuf_submit_dynptr or -+ * bpf_ringbuf_discard_dynptr must be called on *ptr*, even if the -+ * reservation fails. This is enforced by the verifier. -+ * -+ * Returns -+ * 0 on success, or a negative error in case of failure. -+ */ -+static long (*bpf_ringbuf_reserve_dynptr)(void *ringbuf, __u32 size, __u64 flags, struct bpf_dynptr *ptr) = (void *) 198; -+ -+/* -+ * bpf_ringbuf_submit_dynptr -+ * -+ * Submit reserved ring buffer sample, pointed to by *data*, -+ * through the dynptr interface. This is a no-op if the dynptr is -+ * invalid/null. -+ * -+ * For more information on *flags*, please see -+ * 'bpf_ringbuf_submit'. -+ * -+ * Returns -+ * Nothing. Always succeeds. -+ */ -+static void (*bpf_ringbuf_submit_dynptr)(struct bpf_dynptr *ptr, __u64 flags) = (void *) 199; -+ -+/* -+ * bpf_ringbuf_discard_dynptr -+ * -+ * Discard reserved ring buffer sample through the dynptr -+ * interface. This is a no-op if the dynptr is invalid/null. -+ * -+ * For more information on *flags*, please see -+ * 'bpf_ringbuf_discard'. -+ * -+ * Returns -+ * Nothing. Always succeeds. -+ */ -+static void (*bpf_ringbuf_discard_dynptr)(struct bpf_dynptr *ptr, __u64 flags) = (void *) 200; -+ -+/* -+ * bpf_dynptr_read -+ * -+ * Read *len* bytes from *src* into *dst*, starting from *offset* -+ * into *src*. -+ * *flags* is currently unused. -+ * -+ * Returns -+ * 0 on success, -E2BIG if *offset* + *len* exceeds the length -+ * of *src*'s data, -EINVAL if *src* is an invalid dynptr or if -+ * *flags* is not 0. -+ */ -+static long (*bpf_dynptr_read)(void *dst, __u32 len, const struct bpf_dynptr *src, __u32 offset, __u64 flags) = (void *) 201; -+ -+/* -+ * bpf_dynptr_write -+ * -+ * Write *len* bytes from *src* into *dst*, starting from *offset* -+ * into *dst*. -+ * -+ * *flags* must be 0 except for skb-type dynptrs. -+ * -+ * For skb-type dynptrs: -+ * * All data slices of the dynptr are automatically -+ * invalidated after **bpf_dynptr_write**\ (). This is -+ * because writing may pull the skb and change the -+ * underlying packet buffer. -+ * -+ * * For *flags*, please see the flags accepted by -+ * **bpf_skb_store_bytes**\ (). -+ * -+ * Returns -+ * 0 on success, -E2BIG if *offset* + *len* exceeds the length -+ * of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst* -+ * is a read-only dynptr or if *flags* is not correct. For skb-type dynptrs, -+ * other errors correspond to errors returned by **bpf_skb_store_bytes**\ (). -+ */ -+static long (*bpf_dynptr_write)(const struct bpf_dynptr *dst, __u32 offset, void *src, __u32 len, __u64 flags) = (void *) 202; -+ -+/* -+ * bpf_dynptr_data -+ * -+ * Get a pointer to the underlying dynptr data. -+ * -+ * *len* must be a statically known value. The returned data slice -+ * is invalidated whenever the dynptr is invalidated. -+ * -+ * skb and xdp type dynptrs may not use bpf_dynptr_data. They should -+ * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr. -+ * -+ * Returns -+ * Pointer to the underlying dynptr data, NULL if the dynptr is -+ * read-only, if the dynptr is invalid, or if the offset and length -+ * is out of bounds. -+ */ -+static void *(*bpf_dynptr_data)(const struct bpf_dynptr *ptr, __u32 offset, __u32 len) = (void *) 203; -+ -+/* -+ * bpf_tcp_raw_gen_syncookie_ipv4 -+ * -+ * Try to issue a SYN cookie for the packet with corresponding -+ * IPv4/TCP headers, *iph* and *th*, without depending on a -+ * listening socket. -+ * -+ * *iph* points to the IPv4 header. -+ * -+ * *th* points to the start of the TCP header, while *th_len* -+ * contains the length of the TCP header (at least -+ * **sizeof**\ (**struct tcphdr**)). -+ * -+ * Returns -+ * On success, lower 32 bits hold the generated SYN cookie in -+ * followed by 16 bits which hold the MSS value for that cookie, -+ * and the top 16 bits are unused. -+ * -+ * On failure, the returned value is one of the following: -+ * -+ * **-EINVAL** if *th_len* is invalid. -+ */ -+static __s64 (*bpf_tcp_raw_gen_syncookie_ipv4)(struct iphdr *iph, struct tcphdr *th, __u32 th_len) = (void *) 204; -+ -+/* -+ * bpf_tcp_raw_gen_syncookie_ipv6 -+ * -+ * Try to issue a SYN cookie for the packet with corresponding -+ * IPv6/TCP headers, *iph* and *th*, without depending on a -+ * listening socket. -+ * -+ * *iph* points to the IPv6 header. -+ * -+ * *th* points to the start of the TCP header, while *th_len* -+ * contains the length of the TCP header (at least -+ * **sizeof**\ (**struct tcphdr**)). -+ * -+ * Returns -+ * On success, lower 32 bits hold the generated SYN cookie in -+ * followed by 16 bits which hold the MSS value for that cookie, -+ * and the top 16 bits are unused. -+ * -+ * On failure, the returned value is one of the following: -+ * -+ * **-EINVAL** if *th_len* is invalid. -+ * -+ * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. -+ */ -+static __s64 (*bpf_tcp_raw_gen_syncookie_ipv6)(struct ipv6hdr *iph, struct tcphdr *th, __u32 th_len) = (void *) 205; -+ -+/* -+ * bpf_tcp_raw_check_syncookie_ipv4 -+ * -+ * Check whether *iph* and *th* contain a valid SYN cookie ACK -+ * without depending on a listening socket. -+ * -+ * *iph* points to the IPv4 header. -+ * -+ * *th* points to the TCP header. -+ * -+ * Returns -+ * 0 if *iph* and *th* are a valid SYN cookie ACK. -+ * -+ * On failure, the returned value is one of the following: -+ * -+ * **-EACCES** if the SYN cookie is not valid. -+ */ -+static long (*bpf_tcp_raw_check_syncookie_ipv4)(struct iphdr *iph, struct tcphdr *th) = (void *) 206; -+ -+/* -+ * bpf_tcp_raw_check_syncookie_ipv6 -+ * -+ * Check whether *iph* and *th* contain a valid SYN cookie ACK -+ * without depending on a listening socket. -+ * -+ * *iph* points to the IPv6 header. -+ * -+ * *th* points to the TCP header. -+ * -+ * Returns -+ * 0 if *iph* and *th* are a valid SYN cookie ACK. -+ * -+ * On failure, the returned value is one of the following: -+ * -+ * **-EACCES** if the SYN cookie is not valid. -+ * -+ * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. -+ */ -+static long (*bpf_tcp_raw_check_syncookie_ipv6)(struct ipv6hdr *iph, struct tcphdr *th) = (void *) 207; -+ -+/* -+ * bpf_ktime_get_tai_ns -+ * -+ * A nonsettable system-wide clock derived from wall-clock time but -+ * ignoring leap seconds. This clock does not experience -+ * discontinuities and backwards jumps caused by NTP inserting leap -+ * seconds as CLOCK_REALTIME does. -+ * -+ * See: **clock_gettime**\ (**CLOCK_TAI**) -+ * -+ * Returns -+ * Current *ktime*. -+ */ -+static __u64 (*bpf_ktime_get_tai_ns)(void) = (void *) 208; -+ -+/* -+ * bpf_user_ringbuf_drain -+ * -+ * Drain samples from the specified user ring buffer, and invoke -+ * the provided callback for each such sample: -+ * -+ * long (\*callback_fn)(const struct bpf_dynptr \*dynptr, void \*ctx); -+ * -+ * If **callback_fn** returns 0, the helper will continue to try -+ * and drain the next sample, up to a maximum of -+ * BPF_MAX_USER_RINGBUF_SAMPLES samples. If the return value is 1, -+ * the helper will skip the rest of the samples and return. Other -+ * return values are not used now, and will be rejected by the -+ * verifier. -+ * -+ * Returns -+ * The number of drained samples if no error was encountered while -+ * draining samples, or 0 if no samples were present in the ring -+ * buffer. If a user-space producer was epoll-waiting on this map, -+ * and at least one sample was drained, they will receive an event -+ * notification notifying them of available space in the ring -+ * buffer. If the BPF_RB_NO_WAKEUP flag is passed to this -+ * function, no wakeup notification will be sent. If the -+ * BPF_RB_FORCE_WAKEUP flag is passed, a wakeup notification will -+ * be sent even if no sample was drained. -+ * -+ * On failure, the returned value is one of the following: -+ * -+ * **-EBUSY** if the ring buffer is contended, and another calling -+ * context was concurrently draining the ring buffer. -+ * -+ * **-EINVAL** if user-space is not properly tracking the ring -+ * buffer due to the producer position not being aligned to 8 -+ * bytes, a sample not being aligned to 8 bytes, or the producer -+ * position not matching the advertised length of a sample. -+ * -+ * **-E2BIG** if user-space has tried to publish a sample which is -+ * larger than the size of the ring buffer, or which cannot fit -+ * within a struct bpf_dynptr. -+ */ -+static long (*bpf_user_ringbuf_drain)(void *map, void *callback_fn, void *ctx, __u64 flags) = (void *) 209; -+ -+/* -+ * bpf_cgrp_storage_get -+ * -+ * Get a bpf_local_storage from the *cgroup*. -+ * -+ * Logically, it could be thought of as getting the value from -+ * a *map* with *cgroup* as the **key**. From this -+ * perspective, the usage is not much different from -+ * **bpf_map_lookup_elem**\ (*map*, **&**\ *cgroup*) except this -+ * helper enforces the key must be a cgroup struct and the map must also -+ * be a **BPF_MAP_TYPE_CGRP_STORAGE**. -+ * -+ * In reality, the local-storage value is embedded directly inside of the -+ * *cgroup* object itself, rather than being located in the -+ * **BPF_MAP_TYPE_CGRP_STORAGE** map. When the local-storage value is -+ * queried for some *map* on a *cgroup* object, the kernel will perform an -+ * O(n) iteration over all of the live local-storage values for that -+ * *cgroup* object until the local-storage value for the *map* is found. -+ * -+ * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be -+ * used such that a new bpf_local_storage will be -+ * created if one does not exist. *value* can be used -+ * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify -+ * the initial value of a bpf_local_storage. If *value* is -+ * **NULL**, the new bpf_local_storage will be zero initialized. -+ * -+ * Returns -+ * A bpf_local_storage pointer is returned on success. -+ * -+ * **NULL** if not found or there was an error in adding -+ * a new bpf_local_storage. -+ */ -+static void *(*bpf_cgrp_storage_get)(void *map, struct cgroup *cgroup, void *value, __u64 flags) = (void *) 210; -+ -+/* -+ * bpf_cgrp_storage_delete -+ * -+ * Delete a bpf_local_storage from a *cgroup*. -+ * -+ * Returns -+ * 0 on success. -+ * -+ * **-ENOENT** if the bpf_local_storage cannot be found. -+ */ -+static long (*bpf_cgrp_storage_delete)(void *map, struct cgroup *cgroup) = (void *) 211; -+ -+/* -+ * bpf_get_sockops_uid_gid -+ * -+ * Get sock's uid and gid -+ * -+ * Returns -+ * A 64-bit integer containing the current GID and UID, and -+ * created as such: *current_gid* **<< 32 \|** *current_uid*. -+ */ -+static __u64 (*bpf_get_sockops_uid_gid)(void *sockops) = (void *) 212; -+ -+/* -+ * bpf_sk_original_addr -+ * -+ * Get Ipv4 origdst or replysrc. Works with IPv4. -+ * -+ * Returns -+ * 0 on success, or a negative error in case of failure. -+ */ -+static int (*bpf_sk_original_addr)(void *bpf_socket, int optname, char *optval, int optlen) = (void *) 213; - --- -2.33.0 - diff --git a/backport-libbpf-Deal-with-section-with-no-data-gracefully.patch b/backport-libbpf-Deal-with-section-with-no-data-gracefully.patch deleted file mode 100644 index b43c629a563dc0c23047c64a54f466d23e58a894..0000000000000000000000000000000000000000 --- a/backport-libbpf-Deal-with-section-with-no-data-gracefully.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 3ee4823fcb6d3b090942650464dfe52c3f8f99b3 Mon Sep 17 00:00:00 2001 -From: Shung-Hsi Yu -Date: Wed, 12 Oct 2022 10:23:52 +0800 -Subject: [PATCH] libbpf: Deal with section with no data gracefully - -ELF section data pointer returned by libelf may be NULL (if section has -SHT_NOBITS), so null check section data pointer before attempting to -copy license and kversion section. - -Fixes: cb1e5e961991 ("bpf tools: Collect version and license from ELF sections") -Signed-off-by: Shung-Hsi Yu -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20221012022353.7350-3-shung-hsi.yu@suse.com ---- - src/libbpf.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 2e8ac13..29e9df0 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -1408,6 +1408,10 @@ static int bpf_object__check_endianness(struct bpf_object *obj) - static int - bpf_object__init_license(struct bpf_object *obj, void *data, size_t size) - { -+ if (!data) { -+ pr_warn("invalid license section in %s\n", obj->path); -+ return -LIBBPF_ERRNO__FORMAT; -+ } - /* libbpf_strlcpy() only copies first N - 1 bytes, so size + 1 won't - * go over allowed ELF data section buffer - */ -@@ -1421,7 +1425,7 @@ bpf_object__init_kversion(struct bpf_object *obj, void *data, size_t size) - { - __u32 kver; - -- if (size != sizeof(kver)) { -+ if (!data || size != sizeof(kver)) { - pr_warn("invalid kver section in %s\n", obj->path); - return -LIBBPF_ERRNO__FORMAT; - } --- -2.33.0 - diff --git a/backport-libbpf-Disable-SEC-pragma-macro-on-GCC.patch b/backport-libbpf-Disable-SEC-pragma-macro-on-GCC.patch deleted file mode 100644 index cb6ab762081700c774de50c1fa3867980b2b3a65..0000000000000000000000000000000000000000 --- a/backport-libbpf-Disable-SEC-pragma-macro-on-GCC.patch +++ /dev/null @@ -1,61 +0,0 @@ -From b31ca3fa0e62fde6aa66f855136e29e088ad9dde Mon Sep 17 00:00:00 2001 -From: James Hilliard -Date: Wed, 6 Jul 2022 05:18:38 -0600 -Subject: [PATCH] libbpf: Disable SEC pragma macro on GCC - -It seems the gcc preprocessor breaks with pragmas when surrounding -__attribute__. - -Disable these pragmas on GCC due to upstream bugs see: -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90400 - -Fixes errors like: -error: expected identifier or '(' before '#pragma' - 106 | SEC("cgroup/bind6") - | ^~~ - -error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma' - 114 | char _license[] SEC("license") = "GPL"; - | ^~~ - -Signed-off-by: James Hilliard -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20220706111839.1247911-1-james.hilliard1@gmail.com ---- - src/bpf_helpers.h | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/src/bpf_helpers.h b/src/bpf_helpers.h -index fb04eaf..7349b16 100644 ---- a/src/bpf_helpers.h -+++ b/src/bpf_helpers.h -@@ -22,12 +22,25 @@ - * To allow use of SEC() with externs (e.g., for extern .maps declarations), - * make sure __attribute__((unused)) doesn't trigger compilation warning. - */ -+#if __GNUC__ && !__clang__ -+ -+/* -+ * Pragma macros are broken on GCC -+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 -+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90400 -+ */ -+#define SEC(name) __attribute__((section(name), used)) -+ -+#else -+ - #define SEC(name) \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wignored-attributes\"") \ - __attribute__((section(name), used)) \ - _Pragma("GCC diagnostic pop") \ - -+#endif -+ - /* Avoid 'linux/stddef.h' definition of '__always_inline'. */ - #undef __always_inline - #define __always_inline inline __attribute__((always_inline)) --- -2.33.0 - diff --git a/backport-libbpf-Ensure-FD-3-during-bpf_map__reuse_fd.patch b/backport-libbpf-Ensure-FD-3-during-bpf_map__reuse_fd.patch deleted file mode 100644 index d93058577947ad3ac1f672a4e2fbd44692c68522..0000000000000000000000000000000000000000 --- a/backport-libbpf-Ensure-FD-3-during-bpf_map__reuse_fd.patch +++ /dev/null @@ -1,52 +0,0 @@ -From fa1a18d38bfb77207b0a3137e211a706fd8487f4 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Thu, 25 May 2023 15:13:11 -0700 -Subject: [PATCH] libbpf: Ensure FD >= 3 during bpf_map__reuse_fd() - -Improve bpf_map__reuse_fd() logic and ensure that dup'ed map FD is -"good" (>= 3) and has O_CLOEXEC flags. Use fcntl(F_DUPFD_CLOEXEC) for -that, similarly to ensure_good_fd() helper we already use in low-level -APIs that work with bpf() syscall. - -Conflict: NA -Reference:https://github.com/libbpf/libbpf/commit/fa1a18d38bfb77207b0a3137e211a706fd8487f4 - -Suggested-by: Lennart Poettering -Signed-off-by: Andrii Nakryiko -Signed-off-by: Daniel Borkmann -Link: https://lore.kernel.org/bpf/20230525221311.2136408-2-andrii@kernel.org ---- - src/libbpf.c | 13 ++++++------- - 1 file changed, 6 insertions(+), 7 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 60ef4c5e3..47632606b 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -4414,18 +4414,17 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd) - if (!new_name) - return libbpf_err(-errno); - -- new_fd = open("/", O_RDONLY | O_CLOEXEC); -+ /* -+ * Like dup(), but make sure new FD is >= 3 and has O_CLOEXEC set. -+ * This is similar to what we do in ensure_good_fd(), but without -+ * closing original FD. -+ */ -+ new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); - if (new_fd < 0) { - err = -errno; - goto err_free_new_name; - } - -- new_fd = dup3(fd, new_fd, O_CLOEXEC); -- if (new_fd < 0) { -- err = -errno; -- goto err_close_new_fd; -- } -- - err = zclose(map->fd); - if (err) { - err = -errno; --- -2.23.0 diff --git a/backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch b/backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch deleted file mode 100644 index 31b6866828be545bc7739e5d390ced91f76d43b3..0000000000000000000000000000000000000000 --- a/backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 69d537ba0b5cd736cd5081d84928f4393856d3db Mon Sep 17 00:00:00 2001 -From: James Hilliard -Date: Wed, 3 Aug 2022 09:14:03 -0600 -Subject: [PATCH] libbpf: Ensure functions with always_inline attribute are inline -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -GCC expects the always_inline attribute to only be set on inline -functions, as such we should make all functions with this attribute -use the __always_inline macro which makes the function inline and -sets the attribute. - -Fixes errors like: -/home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_tracing.h:439:1: error: ‘always_inline’ function might not be inlinable [-Werror=attributes] - 439 | ____##name(unsigned long long *ctx, ##args) - | ^~~~ - -Signed-off-by: James Hilliard -Signed-off-by: Andrii Nakryiko -Acked-by: Jiri Olsa -Link: https://lore.kernel.org/bpf/20220803151403.793024-1-james.hilliard1@gmail.com - -Conflict: remove the modify of src/usdt.bpf.h because the include file -src/usdt.bpf.h is not exist in current version -Reference: https://github.com/libbpf/libbpf/commit/69d537ba0b5cd736cd5081d84928f4393856d3db ---- - src/bpf_tracing.h | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/src/bpf_tracing.h b/src/bpf_tracing.h -index f9ef377..12c0bb5 100644 ---- a/src/bpf_tracing.h -+++ b/src/bpf_tracing.h -@@ -424,7 +424,7 @@ struct pt_regs; - */ - #define BPF_PROG(name, args...) \ - name(unsigned long long *ctx); \ --static __attribute__((always_inline)) typeof(name(0)) \ -+static __always_inline typeof(name(0)) \ - ____##name(unsigned long long *ctx, ##args); \ - typeof(name(0)) name(unsigned long long *ctx) \ - { \ -@@ -433,7 +433,7 @@ typeof(name(0)) name(unsigned long long *ctx) \ - return ____##name(___bpf_ctx_cast(args)); \ - _Pragma("GCC diagnostic pop") \ - } \ --static __attribute__((always_inline)) typeof(name(0)) \ -+static __always_inline typeof(name(0)) \ - ____##name(unsigned long long *ctx, ##args) - - struct pt_regs; -@@ -458,7 +458,7 @@ struct pt_regs; - */ - #define BPF_KPROBE(name, args...) \ - name(struct pt_regs *ctx); \ --static __attribute__((always_inline)) typeof(name(0)) \ -+static __always_inline typeof(name(0)) \ - ____##name(struct pt_regs *ctx, ##args); \ - typeof(name(0)) name(struct pt_regs *ctx) \ - { \ -@@ -467,7 +467,7 @@ typeof(name(0)) name(struct pt_regs *ctx) \ - return ____##name(___bpf_kprobe_args(args)); \ - _Pragma("GCC diagnostic pop") \ - } \ --static __attribute__((always_inline)) typeof(name(0)) \ -+static __always_inline typeof(name(0)) \ - ____##name(struct pt_regs *ctx, ##args) - - #define ___bpf_kretprobe_args0() ctx -@@ -482,7 +482,7 @@ ____##name(struct pt_regs *ctx, ##args) - */ - #define BPF_KRETPROBE(name, args...) \ - name(struct pt_regs *ctx); \ --static __attribute__((always_inline)) typeof(name(0)) \ -+static __always_inline typeof(name(0)) \ - ____##name(struct pt_regs *ctx, ##args); \ - typeof(name(0)) name(struct pt_regs *ctx) \ - { \ --- -2.33.0 - diff --git a/backport-libbpf-Ensure-libbpf-always-opens-files-with-O_CLOEX.patch b/backport-libbpf-Ensure-libbpf-always-opens-files-with-O_CLOEX.patch deleted file mode 100644 index 2b874446e70643bb6d1eccf0db293c2c9ebfdd96..0000000000000000000000000000000000000000 --- a/backport-libbpf-Ensure-libbpf-always-opens-files-with-O_CLOEX.patch +++ /dev/null @@ -1,103 +0,0 @@ -From ba7a44da68adfa4f0d8285de4cdc16e3754929a8 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Thu, 25 May 2023 15:13:10 -0700 -Subject: [PATCH] libbpf: Ensure libbpf always opens files with O_CLOEXEC - -Make sure that libbpf code always gets FD with O_CLOEXEC flag set, -regardless if file is open through open() or fopen(). For the latter -this means to add "e" to mode string, which is supported since pretty -ancient glibc v2.7. - -Also drop the outdated TODO comment in usdt.c, which was already completed. - -Conflict: code modify in libbpf_probes.c is in libbpf.c -Reference:https://github.com/libbpf/libbpf/commit/ba7a44da68adfa4f0d8285de4cdc16e3754929a8 - -Suggested-by: Lennart Poettering -Signed-off-by: Andrii Nakryiko -Signed-off-by: Daniel Borkmann -Link: https://lore.kernel.org/bpf/20230525221311.2136408-1-andrii@kernel.org ---- - src/btf.c | 2 +- - src/libbpf.c | 8 ++++---- - src/usdt.c | 5 ++--- - 3 files changed, 7 insertions(+), 8 deletions(-) - -diff --git a/src/btf.c b/src/btf.c -index 0a2c07924..8484b563b 100644 ---- a/src/btf.c -+++ b/src/btf.c -@@ -1064,7 +1064,7 @@ static struct btf *btf_parse_raw(const char *path, struct btf *base_btf) - int err = 0; - long sz; - -- f = fopen(path, "rb"); -+ f = fopen(path, "rbe"); - if (!f) { - err = -errno; - goto err_out; -diff --git a/src/libbpf.c b/src/libbpf.c -index 1ceb3a9..60ef4c5 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -826,7 +826,7 @@ __u32 get_kernel_version(void) - if (faccessat(AT_FDCWD, ubuntu_kver_file, R_OK, AT_EACCESS) == 0) { - FILE *f; - -- f = fopen(ubuntu_kver_file, "r"); -+ f = fopen(ubuntu_kver_file, "re"); - if (f) { - if (fscanf(f, "%*s %*s %d.%d.%d\n", &major, &minor, &patch) == 3) { - fclose(f); -@@ -4351,7 +4351,7 @@ static int bpf_get_map_info_from_fdinfo(int fd, struct bpf_map_info *info) - snprintf(file, sizeof(file), "/proc/%d/fdinfo/%d", getpid(), fd); - memset(info, 0, sizeof(*info)); - -- fp = fopen(file, "r"); -+ fp = fopen(file, "re"); - if (!fp) { - err = -errno; - pr_warn("failed to open %s: %d. No procfs support?\n", file, -@@ -7455,7 +7455,7 @@ int libbpf_kallsyms_parse(kallsyms_cb_t cb, void *ctx) - int ret, err = 0; - FILE *f; - -- f = fopen("/proc/kallsyms", "r"); -+ f = fopen("/proc/kallsyms", "re"); - if (!f) { - err = -errno; - pr_warn("failed to open /proc/kallsyms: %d\n", err); -@@ -10075,7 +10075,7 @@ static int parse_uint_from_file(const char *file, const char *fmt) - int err, ret; - FILE *f; - -- f = fopen(file, "r"); -+ f = fopen(file, "re"); - if (!f) { - err = -errno; - pr_debug("failed to open '%s': %s\n", file, -diff --git a/src/usdt.c b/src/usdt.c -index 086eef355..f1a141555 100644 ---- a/src/usdt.c -+++ b/src/usdt.c -@@ -466,7 +466,7 @@ static int parse_vma_segs(int pid, const char *lib_path, struct elf_seg **segs, - - proceed: - sprintf(line, "/proc/%d/maps", pid); -- f = fopen(line, "r"); -+ f = fopen(line, "re"); - if (!f) { - err = -errno; - pr_warn("usdt: failed to open '%s' to get base addr of '%s': %d\n", -@@ -954,8 +954,7 @@ struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct - spec_map_fd = bpf_map__fd(man->specs_map); - ip_map_fd = bpf_map__fd(man->ip_to_spec_id_map); - -- /* TODO: perform path resolution similar to uprobe's */ -- fd = open(path, O_RDONLY); -+ fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd < 0) { - err = -errno; - pr_warn("usdt: failed to open ELF binary '%s': %d\n", path, err); --- -2.23.0 diff --git a/backport-libbpf-Fix-alen-calculation-in-libbpf_nla_dump_error.patch b/backport-libbpf-Fix-alen-calculation-in-libbpf_nla_dump_error.patch deleted file mode 100644 index 0359e3ec3c21ba90597b3b53300e30ce461cdef5..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-alen-calculation-in-libbpf_nla_dump_error.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 418962b6861c0f3459400b3ea43aa6e709612f49 Mon Sep 17 00:00:00 2001 -From: Ilya Leoshkevich -Date: Fri, 10 Feb 2023 01:12:01 +0100 -Subject: [PATCH] libbpf: Fix alen calculation in libbpf_nla_dump_errormsg() - -The code assumes that everything that comes after nlmsgerr are nlattrs. -When calculating their size, it does not account for the initial -nlmsghdr. This may lead to accessing uninitialized memory. - -Fixes: bbf48c18ee0c ("libbpf: add error reporting in XDP") -Signed-off-by: Ilya Leoshkevich -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20230210001210.395194-8-iii@linux.ibm.com ---- - src/nlattr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/nlattr.c b/src/nlattr.c -index 3900d05..975e265 100644 ---- a/src/nlattr.c -+++ b/src/nlattr.c -@@ -178,7 +178,7 @@ int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh) - hlen += nlmsg_len(&err->msg); - - attr = (struct nlattr *) ((void *) err + hlen); -- alen = nlh->nlmsg_len - hlen; -+ alen = (void *)nlh + nlh->nlmsg_len - (void *)attr; - - if (libbpf_nla_parse(tb, NLMSGERR_ATTR_MAX, attr, alen, - extack_policy) != 0) { --- - diff --git a/backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch b/backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch deleted file mode 100644 index 599c3ff2a05b0899a7fee8d893ce9883aae7e306..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0ff6d28aecf2980407ccbb7b79727f3349f74510 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Fri, 9 Sep 2022 12:30:52 -0700 -Subject: [PATCH] libbpf: Fix crash if SEC("freplace") programs don't have - attach_prog_fd set - -Fix SIGSEGV caused by libbpf trying to find attach type in vmlinux BTF -for freplace programs. It's wrong to search in vmlinux BTF and libbpf -doesn't even mark vmlinux BTF as required for freplace programs. So -trying to search anything in obj->vmlinux_btf might cause NULL -dereference if nothing else in BPF object requires vmlinux BTF. - -Instead, error out if freplace (EXT) program doesn't specify -attach_prog_fd during at the load time. - -Fixes: 91abb4a6d79d ("libbpf: Support attachment of BPF tracing programs to kernel modules") -Signed-off-by: Andrii Nakryiko -Signed-off-by: Daniel Borkmann -Link: https://lore.kernel.org/bpf/20220909193053.577111-3-andrii@kernel.org ---- - src/libbpf.c | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 3ad1392..2ca30cc 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -9084,11 +9084,15 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attac - int err = 0; - - /* BPF program's BTF ID */ -- if (attach_prog_fd) { -+ if (prog->type == BPF_PROG_TYPE_EXT || attach_prog_fd) { -+ if (!attach_prog_fd) { -+ pr_warn("prog '%s': attach program FD is not set\n", prog->name); -+ return -EINVAL; -+ } - err = libbpf_find_prog_btf_id(attach_name, attach_prog_fd); - if (err < 0) { -- pr_warn("failed to find BPF program (FD %d) BTF ID for '%s': %d\n", -- attach_prog_fd, attach_name, err); -+ pr_warn("prog '%s': failed to find BPF program (FD %d) BTF ID for '%s': %d\n", -+ prog->name, attach_prog_fd, attach_name, err); - return err; - } - *btf_obj_fd = 0; -@@ -9105,7 +9109,8 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attac - err = find_kernel_btf_id(prog->obj, attach_name, attach_type, btf_obj_fd, btf_type_id); - } - if (err) { -- pr_warn("failed to find kernel BTF type ID of '%s': %d\n", attach_name, err); -+ pr_warn("prog '%s': failed to find kernel BTF type ID of '%s': %d\n", -+ prog->name, attach_name, err); - return err; - } - return 0; --- -2.33.0 - diff --git a/backport-libbpf-Fix-determine_ptr_size-guessing.patch b/backport-libbpf-Fix-determine_ptr_size-guessing.patch deleted file mode 100644 index 4cb99afa5e81dbaba91332e5ea8f9771fb65c56e..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-determine_ptr_size-guessing.patch +++ /dev/null @@ -1,77 +0,0 @@ -From a5d75daa8c467a863ecf297982b70ed284adc0e9 Mon Sep 17 00:00:00 2001 -From: Douglas Raillard -Date: Tue, 24 May 2022 10:44:47 +0100 -Subject: [PATCH] libbpf: Fix determine_ptr_size() guessing - -One strategy employed by libbpf to guess the pointer size is by finding -the size of "unsigned long" type. This is achieved by looking for a type -of with the expected name and checking its size. - -Unfortunately, the C syntax is friendlier to humans than to computers -as there is some variety in how such a type can be named. Specifically, -gcc and clang do not use the same names for integer types in debug info: - - - clang uses "unsigned long" - - gcc uses "long unsigned int" - -Lookup all the names for such a type so that libbpf can hope to find the -information it wants. - -Signed-off-by: Douglas Raillard -Signed-off-by: Andrii Nakryiko -Acked-by: Yonghong Song -Link: https://lore.kernel.org/bpf/20220524094447.332186-1-douglas.raillard@arm.com ---- - src/btf.c | 26 ++++++++++++++++++++------ - 1 file changed, 20 insertions(+), 6 deletions(-) - -diff --git a/src/btf.c b/src/btf.c -index bb1e06eb1..3d6c30d9a 100644 ---- a/src/btf.c -+++ b/src/btf.c -@@ -472,9 +472,22 @@ const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id) - - static int determine_ptr_size(const struct btf *btf) - { -+ static const char * const long_aliases[] = { -+ "long", -+ "long int", -+ "int long", -+ "unsigned long", -+ "long unsigned", -+ "unsigned long int", -+ "unsigned int long", -+ "long unsigned int", -+ "long int unsigned", -+ "int unsigned long", -+ "int long unsigned", -+ }; - const struct btf_type *t; - const char *name; -- int i, n; -+ int i, j, n; - - if (btf->base_btf && btf->base_btf->ptr_sz > 0) - return btf->base_btf->ptr_sz; -@@ -485,15 +498,16 @@ static int determine_ptr_size(const struct btf *btf) - if (!btf_is_int(t)) - continue; - -+ if (t->size != 4 && t->size != 8) -+ continue; -+ - name = btf__name_by_offset(btf, t->name_off); - if (!name) - continue; - -- if (strcmp(name, "long int") == 0 || -- strcmp(name, "long unsigned int") == 0) { -- if (t->size != 4 && t->size != 8) -- continue; -- return t->size; -+ for (j = 0; j < ARRAY_SIZE(long_aliases); j++) { -+ if (strcmp(name, long_aliases[j]) == 0) -+ return t->size; - } - } - diff --git a/backport-libbpf-Fix-is_pow_of_2.patch b/backport-libbpf-Fix-is_pow_of_2.patch deleted file mode 100644 index 092fbcc9dcff02ba4225a828cc2bfcdee5305dd2..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-is_pow_of_2.patch +++ /dev/null @@ -1,67 +0,0 @@ -From ad0783c4309a37690810a152a8902c3d12b086b5 Mon Sep 17 00:00:00 2001 -From: Yuze Chi -Date: Thu, 2 Jun 2022 22:51:56 -0700 -Subject: [PATCH] libbpf: Fix is_pow_of_2 - -Move the correct definition from linker.c into libbpf_internal.h. - -Fixes: 0087a681fa8c ("libbpf: Automatically fix up BPF_MAP_TYPE_RINGBUF size, if necessary") -Reported-by: Yuze Chi -Signed-off-by: Yuze Chi -Signed-off-by: Ian Rogers -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20220603055156.2830463-1-irogers@google.com ---- - src/libbpf.c | 5 ----- - src/libbpf_internal.h | 5 +++++ - src/linker.c | 5 ----- - 3 files changed, 5 insertions(+), 10 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 5afe4cbd6..b03165687 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -5071,11 +5071,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map) - - static void bpf_map__destroy(struct bpf_map *map); - --static bool is_pow_of_2(size_t x) --{ -- return x && (x & (x - 1)); --} -- - static size_t adjust_ringbuf_sz(size_t sz) - { - __u32 page_sz = sysconf(_SC_PAGE_SIZE); -diff --git a/src/libbpf_internal.h b/src/libbpf_internal.h -index 4abdbe2fe..ef5d97507 100644 ---- a/src/libbpf_internal.h -+++ b/src/libbpf_internal.h -@@ -580,4 +580,9 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man, - const char *usdt_provider, const char *usdt_name, - __u64 usdt_cookie); - -+static inline bool is_pow_of_2(size_t x) -+{ -+ return x && (x & (x - 1)) == 0; -+} -+ - #endif /* __LIBBPF_LIBBPF_INTERNAL_H */ -diff --git a/src/linker.c b/src/linker.c -index 9aa016fb5..85c0fddf5 100644 ---- a/src/linker.c -+++ b/src/linker.c -@@ -697,11 +697,6 @@ static int linker_load_obj_file(struct bpf_linker *linker, const char *filename, - return err; - } - --static bool is_pow_of_2(size_t x) --{ -- return x && (x & (x - 1)) == 0; --} -- - static int linker_sanity_check_elf(struct src_obj *obj) - { - struct src_sec *sec; --- -2.33.0 diff --git a/backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch b/backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch deleted file mode 100644 index ccbd0b4e6be4d4f20ebed8505ac6fe2ac0fce801..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 3a3ef0c1d09e1894740db71cdcb7be0bfd713671 Mon Sep 17 00:00:00 2001 -From: Shung-Hsi Yu -Date: Wed, 12 Oct 2022 10:23:53 +0800 -Subject: [PATCH] libbpf: Fix null-pointer dereference in - find_prog_by_sec_insn() - -When there are no program sections, obj->programs is left unallocated, -and find_prog_by_sec_insn()'s search lands on &obj->programs[0] == NULL, -and will cause null-pointer dereference in the following access to -prog->sec_idx. - -Guard the search with obj->nr_programs similar to what's being done in -__bpf_program__iter() to prevent null-pointer access from happening. - -Fixes: db2b8b06423c ("libbpf: Support CO-RE relocations for multi-prog sections") -Signed-off-by: Shung-Hsi Yu -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20221012022353.7350-4-shung-hsi.yu@suse.com ---- - src/libbpf.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 29e9df0..8c3f236 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -4115,6 +4115,9 @@ static struct bpf_program *find_prog_by_sec_insn(const struct bpf_object *obj, - int l = 0, r = obj->nr_programs - 1, m; - struct bpf_program *prog; - -+ if (!obj->nr_programs) -+ return NULL; -+ - while (l < r) { - m = l + (r - l + 1) / 2; - prog = &obj->programs[m]; --- -2.33.0 - diff --git a/backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch b/backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch deleted file mode 100644 index 7f46460c9f675d0d0059755a9a840034f3136cba..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 3745a20b2802cb215de0b3d4e289777209c73e16 Mon Sep 17 00:00:00 2001 -From: Xin Liu -Date: Fri, 30 Sep 2022 17:07:08 +0800 -Subject: [PATCH] libbpf: Fix overrun in netlink attribute iteration - -I accidentally found that a change in commit 1045b03e07d8 ("netlink: fix -overrun in attribute iteration") was not synchronized to the function -`nla_ok` in tools/lib/bpf/nlattr.c, I think it is necessary to modify, -this patch will do it. - -Signed-off-by: Xin Liu -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20220930090708.62394-1-liuxin350@huawei.com ---- - src/nlattr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/nlattr.c b/src/nlattr.c -index f57e77a..3900d05 100644 ---- a/src/nlattr.c -+++ b/src/nlattr.c -@@ -32,7 +32,7 @@ static struct nlattr *nla_next(const struct nlattr *nla, int *remaining) - - static int nla_ok(const struct nlattr *nla, int remaining) - { -- return remaining >= sizeof(*nla) && -+ return remaining >= (int)sizeof(*nla) && - nla->nla_len >= sizeof(*nla) && - nla->nla_len <= remaining; - } --- -2.33.0 - diff --git a/backport-libbpf-Fix-realloc-API-handling-in-zero-sized-edge-cases.patch b/backport-libbpf-Fix-realloc-API-handling-in-zero-sized-edge-cases.patch deleted file mode 100644 index e2638f0f6243824520744a22623705f203b2d0c1..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-realloc-API-handling-in-zero-sized-edge-cases.patch +++ /dev/null @@ -1,92 +0,0 @@ -From f117080307163d7057034341aa8ff6b201041599 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Mon, 10 Jul 2023 19:41:50 -0700 -Subject: [PATCH] libbpf: Fix realloc API handling in zero-sized edge cases - -realloc() and reallocarray() can either return NULL or a special -non-NULL pointer, if their size argument is zero. This requires a bit -more care to handle NULL-as-valid-result situation differently from -NULL-as-error case. This has caused real issues before ([0]), and just -recently bit again in production when performing bpf_program__attach_usdt(). - -This patch fixes 4 places that do or potentially could suffer from this -mishandling of NULL, including the reported USDT-related one. - -There are many other places where realloc()/reallocarray() is used and -NULL is always treated as an error value, but all those have guarantees -that their size is always non-zero, so those spot don't need any extra -handling. - - [0] d08ab82f59d5 ("libbpf: Fix double-free when linker processes empty sections") - -Fixes: 999783c8bbda ("libbpf: Wire up spec management and other arch-independent USDT logic") -Fixes: b63b3c490eee ("libbpf: Add bpf_program__set_insns function") -Fixes: 697f104db8a6 ("libbpf: Support custom SEC() handlers") -Fixes: b12688267280 ("libbpf: Change the order of data and text relocations.") -Signed-off-by: Andrii Nakryiko -Signed-off-by: Daniel Borkmann -Link: https://lore.kernel.org/bpf/20230711024150.1566433-1-andrii@kernel.org ---- - src/libbpf.c | 15 ++++++++++++--- - src/usdt.c | 5 ++++- - 2 files changed, 16 insertions(+), 4 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 78635feb1..63311a73c 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -6161,7 +6161,11 @@ static int append_subprog_relos(struct bpf_program *main_prog, struct bpf_progra - if (main_prog == subprog) - return 0; - relos = libbpf_reallocarray(main_prog->reloc_desc, new_cnt, sizeof(*relos)); -- if (!relos) -+ /* if new count is zero, reallocarray can return a valid NULL result; -+ * in this case the previous pointer will be freed, so we *have to* -+ * reassign old pointer to the new value (even if it's NULL) -+ */ -+ if (!relos && new_cnt) - return -ENOMEM; - if (subprog->nr_reloc) - memcpy(relos + main_prog->nr_reloc, subprog->reloc_desc, -@@ -8532,7 +8536,8 @@ int bpf_program__set_insns(struct bpf_program *prog, - return -EBUSY; - - insns = libbpf_reallocarray(prog->insns, new_insn_cnt, sizeof(*insns)); -- if (!insns) { -+ /* NULL is a valid return from reallocarray if the new count is zero */ -+ if (!insns && new_insn_cnt) { - pr_warn("prog '%s': failed to realloc prog code\n", prog->name); - return -ENOMEM; - } -@@ -8841,7 +8846,11 @@ int libbpf_unregister_prog_handler(int handler_id) - - /* try to shrink the array, but it's ok if we couldn't */ - sec_defs = libbpf_reallocarray(custom_sec_defs, custom_sec_def_cnt, sizeof(*sec_defs)); -- if (sec_defs) -+ /* if new count is zero, reallocarray can return a valid NULL result; -+ * in this case the previous pointer will be freed, so we *have to* -+ * reassign old pointer to the new value (even if it's NULL) -+ */ -+ if (sec_defs || custom_sec_def_cnt == 0) - custom_sec_defs = sec_defs; - - return 0; -diff --git a/src/usdt.c b/src/usdt.c -index f1a141555..37455d00b 100644 ---- a/src/usdt.c -+++ b/src/usdt.c -@@ -852,8 +852,11 @@ static int bpf_link_usdt_detach(struct bpf_link *link) - * system is so exhausted on memory, it's the least of user's - * concerns, probably. - * So just do our best here to return those IDs to usdt_manager. -+ * Another edge case when we can legitimately get NULL is when -+ * new_cnt is zero, which can happen in some edge cases, so we -+ * need to be careful about that. - */ -- if (new_free_ids) { -+ if (new_free_ids || new_cnt == 0) { - memcpy(new_free_ids + man->free_spec_cnt, usdt_link->spec_ids, - usdt_link->spec_cnt * sizeof(*usdt_link->spec_ids)); - man->free_spec_ids = new_free_ids; --- -2.33.0 diff --git a/backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch b/backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch deleted file mode 100644 index b9448e73f5fc5f9d89510d7e397b64d604a4afcb..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 9da0dcb62149ab0a6c5711813d77a844ec6f393b Mon Sep 17 00:00:00 2001 -From: Jon Doron -Date: Sun, 25 Sep 2022 10:04:31 +0300 -Subject: [PATCH] libbpf: Fix the case of running as non-root with capabilities - -When running rootless with special capabilities like: -FOWNER / DAC_OVERRIDE / DAC_READ_SEARCH - -The "access" API will not make the proper check if there is really -access to a file or not. - ->From the access man page: -" -The check is done using the calling process's real UID and GID, rather -than the effective IDs as is done when actually attempting an operation -(e.g., open(2)) on the file. Similarly, for the root user, the check -uses the set of permitted capabilities rather than the set of effective -capabilities; ***and for non-root users, the check uses an empty set of -capabilities.*** -" - -What that means is that for non-root user the access API will not do the -proper validation if the process really has permission to a file or not. - -To resolve this this patch replaces all the access API calls with -faccessat with AT_EACCESS flag. - -Signed-off-by: Jon Doron -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20220925070431.1313680-1-arilou@gmail.com ---- - src/btf.c | 2 +- - src/libbpf.c | 4 ++-- - src/usdt.c | 2 +- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/btf.c b/src/btf.c -index 3d6c30d..a542787 100644 ---- a/src/btf.c -+++ b/src/btf.c -@@ -4694,7 +4694,7 @@ struct btf *btf__load_vmlinux_btf(void) - for (i = 0; i < ARRAY_SIZE(locations); i++) { - snprintf(path, PATH_MAX, locations[i].path_fmt, buf.release); - -- if (access(path, R_OK)) -+ if (faccessat(AT_FDCWD, path, R_OK, AT_EACCESS)) - continue; - - if (locations[i].raw_btf) -diff --git a/src/libbpf.c b/src/libbpf.c -index 632c92d..fcaad31 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -823,7 +823,7 @@ __u32 get_kernel_version(void) - __u32 major, minor, patch; - struct utsname info; - -- if (access(ubuntu_kver_file, R_OK) == 0) { -+ if (faccessat(AT_FDCWD, ubuntu_kver_file, R_OK, AT_EACCESS) == 0) { - FILE *f; - - f = fopen(ubuntu_kver_file, "r"); -@@ -11261,7 +11261,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz) - continue; - snprintf(result, result_sz, "%.*s/%s", seg_len, s, file); - /* ensure it is an executable file/link */ -- if (access(result, R_OK | X_OK) < 0) -+ if (faccessat(AT_FDCWD, result, R_OK | X_OK, AT_EACCESS) < 0) - continue; - pr_debug("resolved '%s' to '%s'\n", file, result); - return 0; -diff --git a/src/usdt.c b/src/usdt.c -index f1c9339..058b91a 100644 ---- a/src/usdt.c -+++ b/src/usdt.c -@@ -282,7 +282,7 @@ struct usdt_manager *usdt_manager_new(struct bpf_object *obj) - * If this is not supported, USDTs with semaphores will not be supported. - * Added in: a6ca88b241d5 ("trace_uprobe: support reference counter in fd-based uprobe") - */ -- man->has_sema_refcnt = access(ref_ctr_sysfs_path, F_OK) == 0; -+ man->has_sema_refcnt = faccessat(AT_FDCWD, ref_ctr_sysfs_path, F_OK, AT_EACCESS) == 0; - - return man; - } --- -2.33.0 - diff --git a/backport-libbpf-Fix-the-name-of-a-reused-map.patch b/backport-libbpf-Fix-the-name-of-a-reused-map.patch deleted file mode 100644 index e68eca2433151079984f9d02ab4e905b556c7084..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-the-name-of-a-reused-map.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 9b6f4eb1570c219474f6029caea71584d7a2188a Mon Sep 17 00:00:00 2001 -From: Anquan Wu -Date: Tue, 12 Jul 2022 11:15:40 +0800 -Subject: [PATCH] libbpf: Fix the name of a reused map -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -BPF map name is limited to BPF_OBJ_NAME_LEN. -A map name is defined as being longer than BPF_OBJ_NAME_LEN, -it will be truncated to BPF_OBJ_NAME_LEN when a userspace program -calls libbpf to create the map. A pinned map also generates a path -in the /sys. If the previous program wanted to reuse the map, -it can not get bpf_map by name, because the name of the map is only -partially the same as the name which get from pinned path. - -The syscall information below show that map name "process_pinned_map" -is truncated to "process_pinned_". - - bpf(BPF_OBJ_GET, {pathname="/sys/fs/bpf/process_pinned_map", - bpf_fd=0, file_flags=0}, 144) = -1 ENOENT (No such file or directory) - - bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_HASH, key_size=4, - value_size=4,max_entries=1024, map_flags=0, inner_map_fd=0, - map_name="process_pinned_",map_ifindex=0, btf_fd=3, btf_key_type_id=6, - btf_value_type_id=10,btf_vmlinux_value_type_id=0}, 72) = 4 - -This patch check that if the name of pinned map are the same as the -actual name for the first (BPF_OBJ_NAME_LEN - 1), -bpf map still uses the name which is included in bpf object. - -Fixes: 26736eb9a483 ("tools: libbpf: allow map reuse") -Signed-off-by: Anquan Wu -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/OSZP286MB1725CEA1C95C5CB8E7CCC53FB8869@OSZP286MB1725.JPNP286.PROD.OUTLOOK.COM ---- - src/libbpf.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 72548798..68da1aca 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -4327,7 +4327,7 @@ int bpf_map__set_autocreate(struct bpf_map *map, bool autocreate) - int bpf_map__reuse_fd(struct bpf_map *map, int fd) - { - struct bpf_map_info info = {}; -- __u32 len = sizeof(info); -+ __u32 len = sizeof(info), name_len; - int new_fd, err; - char *new_name; - -@@ -4337,7 +4337,12 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd) - if (err) - return libbpf_err(err); - -- new_name = strdup(info.name); -+ name_len = strlen(info.name); -+ if (name_len == BPF_OBJ_NAME_LEN - 1 && strncmp(map->name, info.name, name_len) == 0) -+ new_name = strdup(map->name); -+ else -+ new_name = strdup(info.name); -+ - if (!new_name) - return libbpf_err(-errno); - diff --git a/backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch b/backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch deleted file mode 100644 index 33af055958d7fdfab42ed8b16b12af03eb81c620..0000000000000000000000000000000000000000 --- a/backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 54caf920db0e489de90f3aaaa41e2a51ddbcd084 Mon Sep 17 00:00:00 2001 -From: Xu Kuohai -Date: Tue, 11 Oct 2022 08:01:03 -0400 -Subject: [PATCH] libbpf: Fix use-after-free in btf_dump_name_dups - -ASAN reports an use-after-free in btf_dump_name_dups: - -ERROR: AddressSanitizer: heap-use-after-free on address 0xffff927006db at pc 0xaaaab5dfb618 bp 0xffffdd89b890 sp 0xffffdd89b928 -READ of size 2 at 0xffff927006db thread T0 - #0 0xaaaab5dfb614 in __interceptor_strcmp.part.0 (test_progs+0x21b614) - #1 0xaaaab635f144 in str_equal_fn tools/lib/bpf/btf_dump.c:127 - #2 0xaaaab635e3e0 in hashmap_find_entry tools/lib/bpf/hashmap.c:143 - #3 0xaaaab635e72c in hashmap__find tools/lib/bpf/hashmap.c:212 - #4 0xaaaab6362258 in btf_dump_name_dups tools/lib/bpf/btf_dump.c:1525 - #5 0xaaaab636240c in btf_dump_resolve_name tools/lib/bpf/btf_dump.c:1552 - #6 0xaaaab6362598 in btf_dump_type_name tools/lib/bpf/btf_dump.c:1567 - #7 0xaaaab6360b48 in btf_dump_emit_struct_def tools/lib/bpf/btf_dump.c:912 - #8 0xaaaab6360630 in btf_dump_emit_type tools/lib/bpf/btf_dump.c:798 - #9 0xaaaab635f720 in btf_dump__dump_type tools/lib/bpf/btf_dump.c:282 - #10 0xaaaab608523c in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:236 - #11 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875 - #12 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062 - #13 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697 - #14 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308 - #15 0xaaaab5d65990 (test_progs+0x185990) - -0xffff927006db is located 11 bytes inside of 16-byte region [0xffff927006d0,0xffff927006e0) -freed by thread T0 here: - #0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4) - #1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191 - #2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163 - #3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106 - #4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157 - #5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519 - #6 0xaaaab6353e10 in btf__add_field tools/lib/bpf/btf.c:2032 - #7 0xaaaab6084fcc in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:232 - #8 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875 - #9 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062 - #10 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697 - #11 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308 - #12 0xaaaab5d65990 (test_progs+0x185990) - -previously allocated by thread T0 here: - #0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4) - #1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191 - #2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163 - #3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106 - #4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157 - #5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519 - #6 0xaaaab6353ff0 in btf_add_enum_common tools/lib/bpf/btf.c:2070 - #7 0xaaaab6354080 in btf__add_enum tools/lib/bpf/btf.c:2102 - #8 0xaaaab6082f50 in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:162 - #9 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875 - #10 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062 - #11 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697 - #12 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308 - #13 0xaaaab5d65990 (test_progs+0x185990) - -The reason is that the key stored in hash table name_map is a string -address, and the string memory is allocated by realloc() function, when -the memory is resized by realloc() later, the old memory may be freed, -so the address stored in name_map references to a freed memory, causing -use-after-free. - -Fix it by storing duplicated string address in name_map. - -Fixes: 919d2b1dbb07 ("libbpf: Allow modification of BTF and add btf__add_str API") -Signed-off-by: Xu Kuohai -Signed-off-by: Andrii Nakryiko -Acked-by: Martin KaFai Lau -Link: https://lore.kernel.org/bpf/20221011120108.782373-2-xukuohai@huaweicloud.com ---- - src/btf_dump.c | 29 ++++++++++++++++++++++++++--- - 1 file changed, 26 insertions(+), 3 deletions(-) - -diff --git a/src/btf_dump.c b/src/btf_dump.c -index e4da6de..bf0cc0e 100644 ---- a/src/btf_dump.c -+++ b/src/btf_dump.c -@@ -219,6 +219,17 @@ static int btf_dump_resize(struct btf_dump *d) - return 0; - } - -+static void btf_dump_free_names(struct hashmap *map) -+{ -+ size_t bkt; -+ struct hashmap_entry *cur; -+ -+ hashmap__for_each_entry(map, cur, bkt) -+ free((void *)cur->key); -+ -+ hashmap__free(map); -+} -+ - void btf_dump__free(struct btf_dump *d) - { - int i; -@@ -237,8 +248,8 @@ void btf_dump__free(struct btf_dump *d) - free(d->cached_names); - free(d->emit_queue); - free(d->decl_stack); -- hashmap__free(d->type_names); -- hashmap__free(d->ident_names); -+ btf_dump_free_names(d->type_names); -+ btf_dump_free_names(d->ident_names); - - free(d); - } -@@ -1524,11 +1535,23 @@ static void btf_dump_emit_type_cast(struct btf_dump *d, __u32 id, - static size_t btf_dump_name_dups(struct btf_dump *d, struct hashmap *name_map, - const char *orig_name) - { -+ char *old_name, *new_name; - size_t dup_cnt = 0; -+ int err; -+ -+ new_name = strdup(orig_name); -+ if (!new_name) -+ return 1; - - hashmap__find(name_map, orig_name, (void **)&dup_cnt); - dup_cnt++; -- hashmap__set(name_map, orig_name, (void *)dup_cnt, NULL, NULL); -+ -+ err = hashmap__set(name_map, new_name, (void *)dup_cnt, -+ (const void **)&old_name, NULL); -+ if (err) -+ free(new_name); -+ -+ free(old_name); - - return dup_cnt; - } --- -2.33.0 - diff --git a/backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch b/backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch deleted file mode 100644 index 6b3865a944d895dec547eafb0f79dff9dbf26857..0000000000000000000000000000000000000000 --- a/backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch +++ /dev/null @@ -1,62 +0,0 @@ -From f056d1bd5453c0194d528635672ac073c168e6f4 Mon Sep 17 00:00:00 2001 -From: Hou Tao -Date: Wed, 16 Nov 2022 15:23:49 +0800 -Subject: [PATCH] libbpf: Handle size overflow for ringbuf mmap - -The maximum size of ringbuf is 2GB on x86-64 host, so 2 * max_entries -will overflow u32 when mapping producer page and data pages. Only -casting max_entries to size_t is not enough, because for 32-bits -application on 64-bits kernel the size of read-only mmap region -also could overflow size_t. - -So fixing it by casting the size of read-only mmap region into a __u64 -and checking whether or not there will be overflow during mmap. - -Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support") -Signed-off-by: Hou Tao -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20221116072351.1168938-3-houtao@huaweicloud.com ---- - src/ringbuf.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/src/ringbuf.c b/src/ringbuf.c -index 8bc117b..c42ba93 100644 ---- a/src/ringbuf.c -+++ b/src/ringbuf.c -@@ -59,6 +59,7 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd, - __u32 len = sizeof(info); - struct epoll_event *e; - struct ring *r; -+ __u64 mmap_sz; - void *tmp; - int err; - -@@ -97,8 +98,7 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd, - r->mask = info.max_entries - 1; - - /* Map writable consumer page */ -- tmp = mmap(NULL, rb->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, -- map_fd, 0); -+ tmp = mmap(NULL, rb->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0); - if (tmp == MAP_FAILED) { - err = -errno; - pr_warn("ringbuf: failed to mmap consumer page for map fd=%d: %d\n", -@@ -111,8 +111,12 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd, - * data size to allow simple reading of samples that wrap around the - * end of a ring buffer. See kernel implementation for details. - * */ -- tmp = mmap(NULL, rb->page_size + 2 * info.max_entries, PROT_READ, -- MAP_SHARED, map_fd, rb->page_size); -+ mmap_sz = rb->page_size + 2 * (__u64)info.max_entries; -+ if (mmap_sz != (__u64)(size_t)mmap_sz) { -+ pr_warn("ringbuf: ring buffer size (%u) is too big\n", info.max_entries); -+ return libbpf_err(-E2BIG); -+ } -+ tmp = mmap(NULL, (size_t)mmap_sz, PROT_READ, MAP_SHARED, map_fd, rb->page_size); - if (tmp == MAP_FAILED) { - err = -errno; - ringbuf_unmap_ring(rb, r); --- -2.33.0 - diff --git a/backport-libbpf-Set-close-on-exec-flag-on-gzopen.patch b/backport-libbpf-Set-close-on-exec-flag-on-gzopen.patch deleted file mode 100644 index ec494ea74e9706a50b0c065ae22028394c102fc3..0000000000000000000000000000000000000000 --- a/backport-libbpf-Set-close-on-exec-flag-on-gzopen.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 20699ecf61f21b761fcc369ddc85da5f5cf5a1cf Mon Sep 17 00:00:00 2001 -From: Marco Vedovati -Date: Thu, 10 Aug 2023 14:43:53 -0700 -Subject: [PATCH] libbpf: Set close-on-exec flag on gzopen - -Enable the close-on-exec flag when using gzopen. This is especially important -for multithreaded programs making use of libbpf, where a fork + exec could -race with libbpf library calls, potentially resulting in a file descriptor -leaked to the new process. This got missed in 59842c5451fe ("libbpf: Ensure -libbpf always opens files with O_CLOEXEC"). - -Fixes: 59842c5451fe ("libbpf: Ensure libbpf always opens files with O_CLOEXEC") -Signed-off-by: Marco Vedovati -Signed-off-by: Daniel Borkmann -Link: https://lore.kernel.org/bpf/20230810214350.106301-1-martin.kelly@crowdstrike.com ---- - src/libbpf.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 17883f5a4..b14a4376a 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -1978,9 +1978,9 @@ static int bpf_object__read_kconfig_file(struct bpf_object *obj, void *data) - return -ENAMETOOLONG; - - /* gzopen also accepts uncompressed files. */ -- file = gzopen(buf, "r"); -+ file = gzopen(buf, "re"); - if (!file) -- file = gzopen("/proc/config.gz", "r"); -+ file = gzopen("/proc/config.gz", "re"); - - if (!file) { - pr_warn("failed to open system Kconfig\n"); --- -2.33.0 diff --git a/backport-libbpf-Use-correct-return-pointer-in-attach_raw_tp.patch b/backport-libbpf-Use-correct-return-pointer-in-attach_raw_tp.patch deleted file mode 100644 index 7b087d0bc332e08e466042144af7a30044769e19..0000000000000000000000000000000000000000 --- a/backport-libbpf-Use-correct-return-pointer-in-attach_raw_tp.patch +++ /dev/null @@ -1,35 +0,0 @@ -From eb77c7210b8fd8af593c5da918bbbc7c36fb5814 Mon Sep 17 00:00:00 2001 -From: Jiri Olsa -Date: Mon, 14 Nov 2022 15:52:57 +0100 -Subject: [PATCH] libbpf: Use correct return pointer in attach_raw_tp - -We need to pass '*link' to final libbpf_get_error, -because that one holds the return value, not 'link'. - -Fixes: 4fa5bcfe07f7 ("libbpf: Allow BPF program auto-attach handlers to bail out") -Signed-off-by: Jiri Olsa -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20221114145257.882322-1-jolsa@kernel.org - -Conflict:NA -Reference:https://github.com/libbpf/libbpf/commit/eb77c7210b8fd8af593c5da918bbbc7c36fb5814 ---- - src/libbpf.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index b5df6ac..e17867d 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -11234,7 +11234,7 @@ static int attach_raw_tp(const struct bpf_program *prog, long cookie, struct bpf - } - - *link = bpf_program__attach_raw_tracepoint(prog, tp_name); -- return libbpf_get_error(link); -+ return libbpf_get_error(*link); - } - - /* Common logic for all BPF program types that attach to a btf_id */ --- -2.33.0 - diff --git a/backport-libbpf-Use-elf_getshdrnum-instead-of-e_shnum.patch b/backport-libbpf-Use-elf_getshdrnum-instead-of-e_shnum.patch deleted file mode 100644 index c03706316d34f669024a4452b8b44c3750a1aaf4..0000000000000000000000000000000000000000 --- a/backport-libbpf-Use-elf_getshdrnum-instead-of-e_shnum.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 741277511035893c72a34df05da3b943afa747a4 Mon Sep 17 00:00:00 2001 -From: Shung-Hsi Yu -Date: Wed, 12 Oct 2022 10:23:51 +0800 -Subject: [PATCH] libbpf: Use elf_getshdrnum() instead of e_shnum - -This commit replace e_shnum with the elf_getshdrnum() helper to fix two -oss-fuzz-reported heap-buffer overflow in __bpf_object__open. Both -reports are incorrectly marked as fixed and while still being -reproducible in the latest libbpf. - - # clusterfuzz-testcase-minimized-bpf-object-fuzzer-5747922482888704 - libbpf: loading object 'fuzz-object' from buffer - libbpf: sec_cnt is 0 - libbpf: elf: section(1) .data, size 0, link 538976288, flags 2020202020202020, type=2 - libbpf: elf: section(2) .data, size 32, link 538976288, flags 202020202020ff20, type=1 - ================================================================= - ==13==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000c0 at pc 0x0000005a7b46 bp 0x7ffd12214af0 sp 0x7ffd12214ae8 - WRITE of size 4 at 0x6020000000c0 thread T0 - SCARINESS: 46 (4-byte-write-heap-buffer-overflow-far-from-bounds) - #0 0x5a7b45 in bpf_object__elf_collect /src/libbpf/src/libbpf.c:3414:24 - #1 0x5733c0 in bpf_object_open /src/libbpf/src/libbpf.c:7223:16 - #2 0x5739fd in bpf_object__open_mem /src/libbpf/src/libbpf.c:7263:20 - ... - -The issue lie in libbpf's direct use of e_shnum field in ELF header as -the section header count. Where as libelf implemented an extra logic -that, when e_shnum == 0 && e_shoff != 0, will use sh_size member of the -initial section header as the real section header count (part of ELF -spec to accommodate situation where section header counter is larger -than SHN_LORESERVE). - -The above inconsistency lead to libbpf writing into a zero-entry calloc -area. So intead of using e_shnum directly, use the elf_getshdrnum() -helper provided by libelf to retrieve the section header counter into -sec_cnt. - -Fixes: 0d6988e16a12 ("libbpf: Fix section counting logic") -Fixes: 25bbbd7a444b ("libbpf: Remove assumptions about uniqueness of .rodata/.data/.bss maps") -Signed-off-by: Shung-Hsi Yu -Signed-off-by: Andrii Nakryiko -Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40868 -Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40957 -Link: https://lore.kernel.org/bpf/20221012022353.7350-2-shung-hsi.yu@suse.com -Conflict:context adaption -Reference:https://github.com/libbpf/libbpf/commit/741277511035893c72a34df05da3b943afa747a4 ---- - src/libbpf.c | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 184ce16..2e8ac13 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -597,7 +597,7 @@ struct elf_state { - size_t shstrndx; /* section index for section name strings */ - size_t strtabidx; - struct elf_sec_desc *secs; -- int sec_cnt; -+ size_t sec_cnt; - int maps_shndx; - int btf_maps_shndx; - __u32 btf_maps_sec_btf_id; -@@ -3312,10 +3312,15 @@ static int bpf_object__elf_collect(struct bpf_object *obj) - Elf64_Shdr *sh; - - /* ELF section indices are 0-based, but sec #0 is special "invalid" -- * section. e_shnum does include sec #0, so e_shnum is the necessary -- * size of an array to keep all the sections. -+ * section. Since section count retrieved by elf_getshdrnum() does -+ * include sec #0, it is already the necessary size of an array to keep -+ * all the sections. - */ -- obj->efile.sec_cnt = obj->efile.ehdr->e_shnum; -+ if (elf_getshdrnum(obj->efile.elf, &obj->efile.sec_cnt)) { -+ pr_warn("elf: failed to get the number of sections for %s: %s\n", -+ obj->path, elf_errmsg(-1)); -+ return -LIBBPF_ERRNO__FORMAT; -+ } - obj->efile.secs = calloc(obj->efile.sec_cnt, sizeof(*obj->efile.secs)); - if (!obj->efile.secs) - return -ENOMEM; --- -2.33.0 - diff --git a/backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch b/backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch deleted file mode 100644 index 62f684efed5b57e24da6e384eb3c64281faeeeb8..0000000000000000000000000000000000000000 --- a/backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch +++ /dev/null @@ -1,43 +0,0 @@ -From b822a139e3997a0a09da940e5c88ea505459e81f Mon Sep 17 00:00:00 2001 -From: Hou Tao -Date: Wed, 16 Nov 2022 15:23:48 +0800 -Subject: [PATCH] libbpf: Use page size as max_entries when probing ring buffer - map - -Using page size as max_entries when probing ring buffer map, else the -probe may fail on host with 64KB page size (e.g., an ARM64 host). - -After the fix, the output of "bpftool feature" on above host will be -correct. - -Before : - eBPF map_type ringbuf is NOT available - eBPF map_type user_ringbuf is NOT available - -After : - eBPF map_type ringbuf is available - eBPF map_type user_ringbuf is available - -Signed-off-by: Hou Tao -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/bpf/20221116072351.1168938-2-houtao@huaweicloud.com ---- - src/libbpf_probes.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/libbpf_probes.c b/src/libbpf_probes.c -index 97b06ce..49c36cb 100644 ---- a/src/libbpf_probes.c -+++ b/src/libbpf_probes.c -@@ -289,7 +289,7 @@ static int probe_map_create(enum bpf_map_type map_type, __u32 ifindex) - case BPF_MAP_TYPE_RINGBUF: - key_size = 0; - value_size = 0; -- max_entries = 4096; -+ max_entries = sysconf(_SC_PAGE_SIZE); - break; - case BPF_MAP_TYPE_STRUCT_OPS: - /* we'll get -ENOTSUPP for invalid BTF type ID for struct_ops */ --- -2.33.0 - diff --git a/backport-libbpf-disassociate-section-handler-on-explicit-bpf_.patch b/backport-libbpf-disassociate-section-handler-on-explicit-bpf_.patch deleted file mode 100644 index aacac64c8f69ce32959eeb92e7690d6d1b7165f0..0000000000000000000000000000000000000000 --- a/backport-libbpf-disassociate-section-handler-on-explicit-bpf_.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 3fd6eebb2d4d10546f0dc89cbc14ad110c4e5717 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Mon, 27 Mar 2023 11:52:00 -0700 -Subject: [PATCH] libbpf: disassociate section handler on explicit - bpf_program__set_type() call -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -If user explicitly overrides programs's type with -bpf_program__set_type() API call, we need to disassociate whatever -SEC_DEF handler libbpf determined initially based on program's SEC() -definition, as it's not goind to be valid anymore and could lead to -crashes and/or confusing failures. - -Also, fix up bpf_prog_test_load() helper in selftests/bpf, which is -force-setting program type (even if that's completely unnecessary; this -is quite a legacy piece of code), and thus should expect auto-attach to -not work, yet one of the tests explicitly relies on auto-attach for -testing. - -Instead, force-set program type only if it differs from the desired one. - -Signed-off-by: Andrii Nakryiko -Link: https://lore.kernel.org/r/20230327185202.1929145-2-andrii@kernel.org -Signed-off-by: Alexei Starovoitov -Signed-off-by: Daniel Müller - -Conflict:NA -Reference:https://github.com/libbpf/libbpf/commit/3fd6eebb2d4d10546f0dc89cbc14ad110c4e5717 ---- - src/libbpf.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 15737d7..49cd304 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -8468,6 +8468,7 @@ int bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type) - return libbpf_err(-EBUSY); - - prog->type = type; -+ prog->sec_def = NULL; - return 0; - } - --- -2.33.0 - diff --git a/backport-libbpf-make-RINGBUF-map-size-adjustments-more-eagerly.patch b/backport-libbpf-make-RINGBUF-map-size-adjustments-more-eagerly.patch deleted file mode 100644 index f15c73c4df44d9f2bbb95ca869b3aa2ac07d6180..0000000000000000000000000000000000000000 --- a/backport-libbpf-make-RINGBUF-map-size-adjustments-more-eagerly.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 610707057ac60311fde94b3a049de9d4826a3bf2 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Fri, 15 Jul 2022 16:09:51 -0700 -Subject: [PATCH] libbpf: make RINGBUF map size adjustments more eagerly - -Make libbpf adjust RINGBUF map size (rounding it up to closest power-of-2 -of page_size) more eagerly: during open phase when initializing the map -and on explicit calls to bpf_map__set_max_entries(). - -Such approach allows user to check actual size of BPF ringbuf even -before it's created in the kernel, but also it prevents various edge -case scenarios where BPF ringbuf size can get out of sync with what it -would be in kernel. One of them (reported in [0]) is during an attempt -to pin/reuse BPF ringbuf. - -Move adjust_ringbuf_sz() helper closer to its first actual use. The -implementation of the helper is unchanged. - -Also make detection of whether bpf_object is already loaded more robust -by checking obj->loaded explicitly, given that map->fd can be < 0 even -if bpf_object is already loaded due to ability to disable map creation -with bpf_map__set_autocreate(map, false). - - [0] Closes: https://github.com/libbpf/libbpf/pull/530 - -Fixes: 0087a681fa8c ("libbpf: Automatically fix up BPF_MAP_TYPE_RINGBUF size, if necessary") -Signed-off-by: Andrii Nakryiko -Acked-by: Yonghong Song -Link: https://lore.kernel.org/r/20220715230952.2219271-1-andrii@kernel.org -Signed-off-by: Alexei Starovoitov ---- - src/libbpf.c | 77 ++++++++++++++++++++++++++++------------------------ - 1 file changed, 42 insertions(+), 35 deletions(-) - -diff --git a/src/libbpf.c b/src/libbpf.c -index 9b5500659..b01fe01b0 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -2331,6 +2331,37 @@ int parse_btf_map_def(const char *map_name, struct btf *btf, - return 0; - } - -+static size_t adjust_ringbuf_sz(size_t sz) -+{ -+ __u32 page_sz = sysconf(_SC_PAGE_SIZE); -+ __u32 mul; -+ -+ /* if user forgot to set any size, make sure they see error */ -+ if (sz == 0) -+ return 0; -+ /* Kernel expects BPF_MAP_TYPE_RINGBUF's max_entries to be -+ * a power-of-2 multiple of kernel's page size. If user diligently -+ * satisified these conditions, pass the size through. -+ */ -+ if ((sz % page_sz) == 0 && is_pow_of_2(sz / page_sz)) -+ return sz; -+ -+ /* Otherwise find closest (page_sz * power_of_2) product bigger than -+ * user-set size to satisfy both user size request and kernel -+ * requirements and substitute correct max_entries for map creation. -+ */ -+ for (mul = 1; mul <= UINT_MAX / page_sz; mul <<= 1) { -+ if (mul * page_sz > sz) -+ return mul * page_sz; -+ } -+ -+ /* if it's impossible to satisfy the conditions (i.e., user size is -+ * very close to UINT_MAX but is not a power-of-2 multiple of -+ * page_size) then just return original size and let kernel reject it -+ */ -+ return sz; -+} -+ - static void fill_map_from_def(struct bpf_map *map, const struct btf_map_def *def) - { - map->def.type = def->map_type; -@@ -2344,6 +2375,10 @@ static void fill_map_from_def(struct bpf_map *map, const struct btf_map_def *def - map->btf_key_type_id = def->key_type_id; - map->btf_value_type_id = def->value_type_id; - -+ /* auto-adjust BPF ringbuf map max_entries to be a multiple of page size */ -+ if (map->def.type == BPF_MAP_TYPE_RINGBUF) -+ map->def.max_entries = adjust_ringbuf_sz(map->def.max_entries); -+ - if (def->parts & MAP_DEF_MAP_TYPE) - pr_debug("map '%s': found type = %u.\n", map->name, def->map_type); - -@@ -4317,9 +4352,15 @@ struct bpf_map *bpf_map__inner_map(struct bpf_map *map) - - int bpf_map__set_max_entries(struct bpf_map *map, __u32 max_entries) - { -- if (map->fd >= 0) -+ if (map->obj->loaded) - return libbpf_err(-EBUSY); -+ - map->def.max_entries = max_entries; -+ -+ /* auto-adjust BPF ringbuf map max_entries to be a multiple of page size */ -+ if (map->def.type == BPF_MAP_TYPE_RINGBUF) -+ map->def.max_entries = adjust_ringbuf_sz(map->def.max_entries); -+ - return 0; - } - -@@ -4875,37 +4916,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map) - - static void bpf_map__destroy(struct bpf_map *map); - --static size_t adjust_ringbuf_sz(size_t sz) --{ -- __u32 page_sz = sysconf(_SC_PAGE_SIZE); -- __u32 mul; -- -- /* if user forgot to set any size, make sure they see error */ -- if (sz == 0) -- return 0; -- /* Kernel expects BPF_MAP_TYPE_RINGBUF's max_entries to be -- * a power-of-2 multiple of kernel's page size. If user diligently -- * satisified these conditions, pass the size through. -- */ -- if ((sz % page_sz) == 0 && is_pow_of_2(sz / page_sz)) -- return sz; -- -- /* Otherwise find closest (page_sz * power_of_2) product bigger than -- * user-set size to satisfy both user size request and kernel -- * requirements and substitute correct max_entries for map creation. -- */ -- for (mul = 1; mul <= UINT_MAX / page_sz; mul <<= 1) { -- if (mul * page_sz > sz) -- return mul * page_sz; -- } -- -- /* if it's impossible to satisfy the conditions (i.e., user size is -- * very close to UINT_MAX but is not a power-of-2 multiple of -- * page_size) then just return original size and let kernel reject it -- */ -- return sz; --} -- - static int bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map, bool is_inner) - { - LIBBPF_OPTS(bpf_map_create_opts, create_attr); -@@ -4944,9 +4954,6 @@ static int bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map, b - } - - switch (def->type) { -- case BPF_MAP_TYPE_RINGBUF: -- map->def.max_entries = adjust_ringbuf_sz(map->def.max_entries); -- /* fallthrough */ - case BPF_MAP_TYPE_PERF_EVENT_ARRAY: - case BPF_MAP_TYPE_CGROUP_ARRAY: - case BPF_MAP_TYPE_STACK_TRACE: --- -2.33.0 diff --git a/backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch b/backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch deleted file mode 100644 index 9b43446941da26c9bfc0b93e29f1071d0d96eb68..0000000000000000000000000000000000000000 --- a/backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 45dca19bd2f3fff624f03e903be9241af7cb26c6 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Wed, 10 Aug 2022 11:34:25 -0700 -Subject: [PATCH] libbpf: preserve errno across pr_warn/pr_info/pr_debug -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -As suggested in [0], make sure that libbpf_print saves and restored -errno and as such guaranteed that no matter what actual print callback -user installs, macros like pr_warn/pr_info/pr_debug are completely -transparent as far as errno goes. - -While libbpf code is pretty careful about not clobbering important errno -values accidentally with pr_warn(), it's a trivial change to make sure -that pr_warn can be used anywhere without a risk of clobbering errno. - -No functional changes, just future proofing. - - [0] https://github.com/libbpf/libbpf/pull/536 - -Signed-off-by: Andrii Nakryiko -Acked-by: Daniel Müller -Link: https://lore.kernel.org/r/20220810183425.1998735-1-andrii@kernel.org -Signed-off-by: Alexei Starovoitov ---- - src/libbpf.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/libbpf.c b/src/libbpf.c -index f7364ea8..917d975b 100644 ---- a/src/libbpf.c -+++ b/src/libbpf.c -@@ -95,13 +95,18 @@ __printf(2, 3) - void libbpf_print(enum libbpf_print_level level, const char *format, ...) - { - va_list args; -+ int old_errno; - - if (!__libbpf_pr) - return; - -+ old_errno = errno; -+ - va_start(args, format); - __libbpf_pr(level, format, args); - va_end(args); -+ -+ errno = old_errno; - } - - static void pr_perm_msg(int err) diff --git a/backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch b/backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch deleted file mode 100644 index 760ecf68740016bb3ca740a0da3077e8286370f2..0000000000000000000000000000000000000000 --- a/backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 3b6093fd43682ebab7a2d187e4e847068d6ce454 Mon Sep 17 00:00:00 2001 -From: Andrii Nakryiko -Date: Wed, 16 Nov 2022 10:19:07 -0800 -Subject: [PATCH] sync: start syncing include/uapi/linux/fcntl.h UAPI header - -Libbpf relies on F_DUPFD_CLOEXEC constant coming from fcntl.h UAPI -header, so we need to sync it along other UAPI headers. Also update sync -script to keep doing this automatically going forward. - -Reported-by: Arnaldo Carvalho de Melo -Signed-off-by: Andrii Nakryiko ---- - include/uapi/linux/fcntl.h | 114 +++++++++++++++++++++++++++++++++++++ - scripts/sync-kernel.sh | 1 + - 2 files changed, 115 insertions(+) - create mode 100644 include/uapi/linux/fcntl.h - -diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h -new file mode 100644 -index 0000000..2f86b2a ---- /dev/null -+++ b/include/uapi/linux/fcntl.h -@@ -0,0 +1,114 @@ -+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -+#ifndef _UAPI_LINUX_FCNTL_H -+#define _UAPI_LINUX_FCNTL_H -+ -+#include -+#include -+ -+#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0) -+#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1) -+ -+/* -+ * Cancel a blocking posix lock; internal use only until we expose an -+ * asynchronous lock api to userspace: -+ */ -+#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5) -+ -+/* Create a file descriptor with FD_CLOEXEC set. */ -+#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) -+ -+/* -+ * Request nofications on a directory. -+ * See below for events that may be notified. -+ */ -+#define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2) -+ -+/* -+ * Set and get of pipe page size array -+ */ -+#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) -+#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) -+ -+/* -+ * Set/Get seals -+ */ -+#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) -+#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) -+ -+/* -+ * Types of seals -+ */ -+#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ -+#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ -+#define F_SEAL_GROW 0x0004 /* prevent file from growing */ -+#define F_SEAL_WRITE 0x0008 /* prevent writes */ -+#define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */ -+/* (1U << 31) is reserved for signed error codes */ -+ -+/* -+ * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the -+ * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on -+ * the specific file. -+ */ -+#define F_GET_RW_HINT (F_LINUX_SPECIFIC_BASE + 11) -+#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12) -+#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13) -+#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14) -+ -+/* -+ * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be -+ * used to clear any hints previously set. -+ */ -+#define RWH_WRITE_LIFE_NOT_SET 0 -+#define RWH_WRITE_LIFE_NONE 1 -+#define RWH_WRITE_LIFE_SHORT 2 -+#define RWH_WRITE_LIFE_MEDIUM 3 -+#define RWH_WRITE_LIFE_LONG 4 -+#define RWH_WRITE_LIFE_EXTREME 5 -+ -+/* -+ * The originally introduced spelling is remained from the first -+ * versions of the patch set that introduced the feature, see commit -+ * v4.13-rc1~212^2~51. -+ */ -+#define RWF_WRITE_LIFE_NOT_SET RWH_WRITE_LIFE_NOT_SET -+ -+/* -+ * Types of directory notifications that may be requested. -+ */ -+#define DN_ACCESS 0x00000001 /* File accessed */ -+#define DN_MODIFY 0x00000002 /* File modified */ -+#define DN_CREATE 0x00000004 /* File created */ -+#define DN_DELETE 0x00000008 /* File removed */ -+#define DN_RENAME 0x00000010 /* File renamed */ -+#define DN_ATTRIB 0x00000020 /* File changed attibutes */ -+#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */ -+ -+/* -+ * The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is -+ * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to -+ * unlinkat. The two functions do completely different things and therefore, -+ * the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to -+ * faccessat would be undefined behavior and thus treating it equivalent to -+ * AT_EACCESS is valid undefined behavior. -+ */ -+#define AT_FDCWD -100 /* Special value used to indicate -+ openat should use the current -+ working directory. */ -+#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ -+#define AT_EACCESS 0x200 /* Test access permitted for -+ effective IDs, not real IDs. */ -+#define AT_REMOVEDIR 0x200 /* Remove directory instead of -+ unlinking file. */ -+#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ -+#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */ -+#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */ -+ -+#define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */ -+#define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */ -+#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ -+#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ -+ -+#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ -+ -+#endif /* _UAPI_LINUX_FCNTL_H */ -diff --git a/scripts/sync-kernel.sh b/scripts/sync-kernel.sh -index 3468e71..b33f19f 100755 ---- a/scripts/sync-kernel.sh -+++ b/scripts/sync-kernel.sh -@@ -42,6 +42,7 @@ PATH_MAP=( \ - [tools/include/uapi/linux/bpf_common.h]=include/uapi/linux/bpf_common.h \ - [tools/include/uapi/linux/bpf.h]=include/uapi/linux/bpf.h \ - [tools/include/uapi/linux/btf.h]=include/uapi/linux/btf.h \ -+ [tools/include/uapi/linux/fcntl.h]=include/uapi/linux/fcntl.h \ - [tools/include/uapi/linux/if_link.h]=include/uapi/linux/if_link.h \ - [tools/include/uapi/linux/if_xdp.h]=include/uapi/linux/if_xdp.h \ - [tools/include/uapi/linux/netlink.h]=include/uapi/linux/netlink.h \ --- -2.33.0 - diff --git a/libbpf.spec b/libbpf.spec index 11143d11f889f7714004b07d153ecf3d4dcfbc12..8a137ba3aa8f09396b2ac7f3f92f4e0a4e58faf8 100644 --- a/libbpf.spec +++ b/libbpf.spec @@ -1,42 +1,19 @@ %global githubname libbpf -%global githubver 0.8.1 +%global githubver 1.3.0 %global githubfull %{githubname}-%{githubver} +%global libver 1.3.0 Name: %{githubname} Version: %{githubver} -Release: 11 +Release: 1 Summary: Libbpf library License: LGPLv2 or BSD URL: https://github.com/%{githubname}/%{githubname} Source: https://github.com/%{githubname}/%{githubname}/archive/refs/tags/v%{githubver}.tar.gz BuildRequires: gcc elfutils-libelf-devel elfutils-devel +BuildRequires: make -Patch0000: backport-libbpf-Fix-determine_ptr_size-guessing.patch -Patch0001: backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch -Patch0002: backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch -Patch0003: backport-libbpf-Fix-the-name-of-a-reused-map.patch -Patch0004: backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch -Patch0005: backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch -Patch0006: backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch -Patch0007: backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch -Patch0008: backport-libbpf-Deal-with-section-with-no-data-gracefully.patch -Patch0009: backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch -Patch0010: backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch -Patch0011: backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch -Patch0012: backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch -Patch0013: backport-libbpf-Fix-alen-calculation-in-libbpf_nla_dump_error.patch -Patch0014: backport-libbpf-Disable-SEC-pragma-macro-on-GCC.patch -Patch0015: backport-libbpf-disassociate-section-handler-on-explicit-bpf_.patch -Patch0016: backport-libbpf-Use-correct-return-pointer-in-attach_raw_tp.patch -Patch0017: backport-libbpf-Use-elf_getshdrnum-instead-of-e_shnum.patch -Patch0018: 0001-sync-bpf-helper-funcs-from-kernel.patch -Patch0019: backport-libbpf-Ensure-FD-3-during-bpf_map__reuse_fd.patch -Patch0020: backport-libbpf-Ensure-libbpf-always-opens-files-with-O_CLOEX.patch -Patch0021: backport-libbpf-Fix-realloc-API-handling-in-zero-sized-edge-cases.patch -Patch0022: backport-libbpf-Set-close-on-exec-flag-on-gzopen.patch -Patch0023: backport-libbpf-Fix-is_pow_of_2.patch -Patch0024: backport-libbpf-make-RINGBUF-map-size-adjustments-more-eagerly.patch # This package supersedes libbpf from kernel-tools, # which has default Epoch: 0. By having Epoch: 1 @@ -51,7 +28,8 @@ ABI. %package devel Summary: Development files for %{name} Requires: %{name} = 2:%{version}-%{release} -Requires: kernel-headers >= 5.10.0 +Requires: kernel-headers >= 5.16.0 +Requires: zlib %description devel The %{name}-devel package contains libraries header files for @@ -77,8 +55,8 @@ developing applications that use %{name} %make_install -C ./src %{make_flags} %files -%{_libdir}/libbpf.so.%{githubver} -%{_libdir}/libbpf.so.0 +%{_libdir}/libbpf.so.%{libver} +%{_libdir}/libbpf.so.1 %files devel %{_libdir}/libbpf.so @@ -89,6 +67,9 @@ developing applications that use %{name} %{_libdir}/libbpf.a %changelog +* Tue Jan 09 2024 Paul Thomas - 2:1.3.0-1 +- update to version 1.3.0 + * Thu Dec 7 2023 zhangmingyi 2:0.8.1-11 - backport patches from upstream: backport-libbpf-Fix-realloc-API-handling-in-zero-sized-edge-cases.patch diff --git a/v0.8.1.tar.gz b/v0.8.1.tar.gz deleted file mode 100644 index 4f23bbad61aea4f8859b19fbebc570fdeb79ac28..0000000000000000000000000000000000000000 Binary files a/v0.8.1.tar.gz and /dev/null differ diff --git a/v1.3.0.tar.gz b/v1.3.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..cbdfbfd4235ec365777c1f36d6cb240bd9397d73 Binary files /dev/null and b/v1.3.0.tar.gz differ