Compare commits
10 Commits
3068befe31
...
35b6f3a08e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35b6f3a08e | ||
|
|
98561e7094 | ||
|
|
853c332641 | ||
|
|
178f17be10 | ||
|
|
644c4b6f8b | ||
|
|
41482aa641 | ||
|
|
7c9b757957 | ||
|
|
101e0389fb | ||
|
|
bf839bed54 | ||
|
|
b2837f70bb |
@ -0,0 +1,30 @@
|
||||
From f15814c93ade62519c9ccb50a8ca5c8998010ac2 Mon Sep 17 00:00:00 2001
|
||||
From: Ian Rogers <irogers@google.com>
|
||||
Date: Wed, 13 Jan 2021 14:36:08 -0800
|
||||
Subject: [PATCH] bpf, libbpf: Avoid unused function warning on
|
||||
bpf_tail_call_static
|
||||
|
||||
Add inline to __always_inline making it match the linux/compiler.h.
|
||||
Adding this avoids an unused function warning on bpf_tail_call_static
|
||||
when compining with -Wall.
|
||||
|
||||
Signed-off-by: Ian Rogers <irogers@google.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Link: https://lore.kernel.org/bpf/20210113223609.3358812-1-irogers@google.com
|
||||
---
|
||||
src/bpf_helpers.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/bpf_helpers.h b/src/bpf_helpers.h
|
||||
index 72b25111..ae6c975e 100644
|
||||
--- a/src/bpf_helpers.h
|
||||
+++ b/src/bpf_helpers.h
|
||||
@@ -30,7 +30,7 @@
|
||||
#define SEC(NAME) __attribute__((section(NAME), used))
|
||||
|
||||
#ifndef __always_inline
|
||||
-#define __always_inline __attribute__((always_inline))
|
||||
+#define __always_inline inline __attribute__((always_inline))
|
||||
#endif
|
||||
#ifndef __noinline
|
||||
#define __noinline __attribute__((noinline))
|
||||
@ -0,0 +1,44 @@
|
||||
From 3ee4823fcb6d3b090942650464dfe52c3f8f99b3 Mon Sep 17 00:00:00 2001
|
||||
From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
|
||||
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 <shung-hsi.yu@suse.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
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 f4a2d3e..3ee2768 100644
|
||||
--- a/src/libbpf.c
|
||||
+++ b/src/libbpf.c
|
||||
@@ -1220,6 +1220,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;
|
||||
+ }
|
||||
memcpy(obj->license, data, min(size, sizeof(obj->license) - 1));
|
||||
pr_debug("license of %s is %s\n", obj->path, obj->license);
|
||||
return 0;
|
||||
@@ -1230,7 +1234,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
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
From 69d537ba0b5cd736cd5081d84928f4393856d3db Mon Sep 17 00:00:00 2001
|
||||
From: James Hilliard <james.hilliard1@gmail.com>
|
||||
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 <james.hilliard1@gmail.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Acked-by: Jiri Olsa <jolsa@kernel.org>
|
||||
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
|
||||
@@ -336,7 +336,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) \
|
||||
{ \
|
||||
@@ -345,7 +345,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;
|
||||
@@ -376,7 +376,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) \
|
||||
{ \
|
||||
@@ -385,7 +385,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
|
||||
@@ -402,7 +402,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
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
From 0ff6d28aecf2980407ccbb7b79727f3349f74510 Mon Sep 17 00:00:00 2001
|
||||
From: Andrii Nakryiko <andrii@kernel.org>
|
||||
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 <andrii@kernel.org>
|
||||
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
|
||||
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 660bbb4..f4a2d3e 100644
|
||||
--- a/src/libbpf.c
|
||||
+++ b/src/libbpf.c
|
||||
@@ -8999,11 +8999,15 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd,
|
||||
attach_name = name + sec->len;
|
||||
|
||||
/* 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;
|
||||
@@ -9014,7 +9018,8 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd,
|
||||
/* kernel/module BTF ID */
|
||||
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
|
||||
|
||||
77
backport-libbpf-Fix-determine_ptr_size-guessing.patch
Normal file
77
backport-libbpf-Fix-determine_ptr_size-guessing.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From a5d75daa8c467a863ecf297982b70ed284adc0e9 Mon Sep 17 00:00:00 2001
|
||||
From: Douglas Raillard <douglas.raillard@arm.com>
|
||||
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 <douglas.raillard@arm.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Acked-by: Yonghong Song <yhs@fb.com>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
From 3a3ef0c1d09e1894740db71cdcb7be0bfd713671 Mon Sep 17 00:00:00 2001
|
||||
From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
|
||||
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 <shung-hsi.yu@suse.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
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
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
From 3745a20b2802cb215de0b3d4e289777209c73e16 Mon Sep 17 00:00:00 2001
|
||||
From: Xin Liu <liuxin350@huawei.com>
|
||||
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 <liuxin350@huawei.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
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
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
From 9da0dcb62149ab0a6c5711813d77a844ec6f393b Mon Sep 17 00:00:00 2001
|
||||
From: Jon Doron <jond@wiz.io>
|
||||
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 <jond@wiz.io>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Link: https://lore.kernel.org/bpf/20220925070431.1313680-1-arilou@gmail.com
|
||||
---
|
||||
src/btf.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/btf.c b/src/btf.c
|
||||
index 8066f5f..28c061d 100644
|
||||
--- a/src/btf.c
|
||||
+++ b/src/btf.c
|
||||
@@ -4618,7 +4618,7 @@ struct btf *libbpf_find_kernel_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)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
66
backport-libbpf-Fix-the-name-of-a-reused-map.patch
Normal file
66
backport-libbpf-Fix-the-name-of-a-reused-map.patch
Normal file
@ -0,0 +1,66 @@
|
||||
From 9b6f4eb1570c219474f6029caea71584d7a2188a Mon Sep 17 00:00:00 2001
|
||||
From: Anquan Wu <leiqi96@hotmail.com>
|
||||
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 <leiqi96@hotmail.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
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
|
||||
@@ -3327,7 +3327,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;
|
||||
|
||||
@@ -3335,7 +3335,12 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)
|
||||
if (err)
|
||||
return 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 -errno;
|
||||
|
||||
136
backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch
Normal file
136
backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch
Normal file
@ -0,0 +1,136 @@
|
||||
From 54caf920db0e489de90f3aaaa41e2a51ddbcd084 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Kuohai <xukuohai@huawei.com>
|
||||
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 <xukuohai@huawei.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
|
||||
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
|
||||
|
||||
63
backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch
Normal file
63
backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From f056d1bd5453c0194d528635672ac073c168e6f4 Mon Sep 17 00:00:00 2001
|
||||
From: Hou Tao <houtao1@huawei.com>
|
||||
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 <houtao1@huawei.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
Link: https://lore.kernel.org/bpf/20221116072351.1168938-3-houtao@huaweicloud.com
|
||||
---
|
||||
src/ringbuf.c | 13 +++++++++----
|
||||
1 file changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/ringbuf.c b/src/ringbuf.c
|
||||
index 8caaafe..1890ed4 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,13 @@ 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);
|
||||
+ errno = E2BIG;
|
||||
+ return -errno;
|
||||
+ }
|
||||
+ 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
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
From b822a139e3997a0a09da940e5c88ea505459e81f Mon Sep 17 00:00:00 2001
|
||||
From: Hou Tao <houtao1@huawei.com>
|
||||
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 <houtao1@huawei.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
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 ecaae29..393b5cd 100644
|
||||
--- a/src/libbpf_probes.c
|
||||
+++ b/src/libbpf_probes.c
|
||||
@@ -243,7 +243,7 @@ bool bpf_probe_map_type(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_UNSPEC:
|
||||
case BPF_MAP_TYPE_HASH:
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
From 45dca19bd2f3fff624f03e903be9241af7cb26c6 Mon Sep 17 00:00:00 2001
|
||||
From: Andrii Nakryiko <andrii@kernel.org>
|
||||
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 <andrii@kernel.org>
|
||||
Acked-by: Daniel Müller <deso@posteo.net>
|
||||
Link: https://lore.kernel.org/r/20220810183425.1998735-1-andrii@kernel.org
|
||||
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
|
||||
---
|
||||
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
|
||||
@@ -103,13 +103,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)
|
||||
@ -0,0 +1,152 @@
|
||||
From 3b6093fd43682ebab7a2d187e4e847068d6ce454 Mon Sep 17 00:00:00 2001
|
||||
From: Andrii Nakryiko <andrii@kernel.org>
|
||||
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 <acme@redhat.com>
|
||||
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
|
||||
---
|
||||
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 <asm/fcntl.h>
|
||||
+#include <linux/openat2.h>
|
||||
+
|
||||
+#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
|
||||
|
||||
44
libbpf.spec
44
libbpf.spec
@ -4,7 +4,7 @@
|
||||
|
||||
Name: %{githubname}
|
||||
Version: %{githubver}
|
||||
Release: 1
|
||||
Release: 6
|
||||
Summary: Libbpf library
|
||||
|
||||
License: LGPLv2 or BSD
|
||||
@ -13,6 +13,20 @@ Source: https://github.com/%{githubname}/%{githubname}/archive/v%{github
|
||||
BuildRequires: gcc elfutils-libelf-devel elfutils-devel
|
||||
|
||||
Patch6000: backport-libbpf-Support-detecting-and-attaching-of-writable-t.patch
|
||||
Patch6001: backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch
|
||||
Patch6002: backport-libbpf-Fix-the-name-of-a-reused-map.patch
|
||||
Patch6003: backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch
|
||||
Patch6004: backport-libbpf-Fix-determine_ptr_size-guessing.patch
|
||||
Patch6005: backport-libbpf-Avoid-unused-function-warning-on-bpf_tail_call_static.patch
|
||||
Patch6006: backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch
|
||||
Patch6007: backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch
|
||||
Patch6008: backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch
|
||||
Patch6009: backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch
|
||||
Patch6010: backport-libbpf-Deal-with-section-with-no-data-gracefully.patch
|
||||
Patch6011: backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch
|
||||
Patch6012: backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch
|
||||
Patch6013: backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch
|
||||
Patch6014: backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch
|
||||
|
||||
# This package supersedes libbpf from kernel-tools,
|
||||
# which has default Epoch: 0. By having Epoch: 1
|
||||
@ -40,7 +54,7 @@ Requires: %{name}-devel = 2:%{version}-%{release}
|
||||
The %{name}-static package contains static library for
|
||||
developing applications that use %{name}
|
||||
|
||||
%global make_flags DESTDIR=%{buildroot} OBJDIR=%{_builddir} CFLAGS="%{build_cflags} -fPIC" LDFLAGS="%{build_ldflags} -Wl,--no-as-needed" LIBDIR=/%{_libdir} NO_PKG_CONFIG=1
|
||||
%global make_flags DESTDIR=%{buildroot} OBJDIR=%{_builddir} CFLAGS="%{build_cflags} -fPIC -Werror" LDFLAGS="%{build_ldflags} -Werror -Wl,--no-as-needed -Wl,-z,noexecstack" LIBDIR=/%{_libdir} NO_PKG_CONFIG=1
|
||||
|
||||
%prep
|
||||
%autosetup -n %{githubfull} -p1
|
||||
@ -64,6 +78,32 @@ developing applications that use %{name}
|
||||
%{_libdir}/libbpf.a
|
||||
|
||||
%changelog
|
||||
* Thu May 4 2023 zhangmingyi <zhangmingyi5@huawei.com> -2:0.3-6
|
||||
- add -Werror -Wl,-z,noexecstack options
|
||||
|
||||
* Tue Mar 21 2023 zhangmingyi <zhangmingyi5@huawei.com> - 2:0.3-5
|
||||
- backporting patches from upstream:
|
||||
backport-libbpf-Fix-crash-if-SEC-freplace-programs-don-t-have.patch
|
||||
backport-libbpf-Fix-the-case-of-running-as-non-root-with-capa.patch
|
||||
backport-libbpf-Fix-overrun-in-netlink-attribute-iteration.patch
|
||||
backport-libbpf-Fix-use-after-free-in-btf_dump_name_dups.patch
|
||||
backport-libbpf-Deal-with-section-with-no-data-gracefully.patch
|
||||
backport-libbpf-Fix-null-pointer-dereference-in-find_prog_by_.patch
|
||||
backport-sync-start-syncing-include-uapi-linux-fcntl.h-UAPI-h.patch
|
||||
backport-libbpf-Handle-size-overflow-for-ringbuf-mmap.patch
|
||||
backport-libbpf-Use-page-size-as-max_entries-when-probing-rin.patch
|
||||
|
||||
* Sun Jan 29 2023 zhangmingyi <zhangmingyi5@huawei.com> - 2:0.3-4
|
||||
- backporting: Avoid unused function warning on bpf_tail_call_static
|
||||
|
||||
* Wed Jan 18 2023 zhangmingyi <zhangmingyi5@huawei.com> - 2:0.3-3
|
||||
- Fix determine_ptr_size() guessing
|
||||
|
||||
* Sun Jan 15 2023 zhangmingyi <zhangmingyi5@huawei.com> - 2:0.3-2
|
||||
- backporting: backport-libbpf-Ensure-functions-with-always_inline-attribute-are-inline.patch
|
||||
backport-libbpf-Fix-the-name-of-a-reused-map.patch
|
||||
backport-libbpf-preserve-errno-across-pr_warn-pr_info-pr_debug.patch
|
||||
|
||||
* Tue Aug 23 2022 hujiawang<hujiawang1@huawei.com> - 2:0.3-1
|
||||
- updata libbpf v0.1.1 to v0.3
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user