Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>
Fangrui Song <i@maskray.me> <maskray@google.com>
Geliang Tang <geliang@kernel.org> <geliang.tang@suse.com>
Herbert Xu <herbert@gondor.apana.org.au>
Jason Wang <jasowangio@gmail.com> <jasowang@redhat.com>
Jesper Dangaard Brouer <hawk@kernel.org> <brouer@redhat.com>
Kees Cook <kees@kernel.org> <keescook@chromium.org>
Maxim Mikityanskiy <maxtram95@gmail.com> <maximmi@nvidia.com>
Expand Down
2 changes: 1 addition & 1 deletion BPF-CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9b51a6155d14389876916726430da30eabb1d4ed
7cbd0c4cebe4c9f678d15e6b9ba975e1155a107f
2 changes: 1 addition & 1 deletion CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0b58988cacfc91604c4b5be2c3295f8aac0ee3d0
9a3a07d06e7d74f4aecc51396c771149336ac55d
24 changes: 12 additions & 12 deletions scripts/sync-kernel-expected-diff.patch
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
- DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) prefix= \
+ $(Q)$(MAKE) -C $(BPF_DIR) OBJDIR=$(patsubst %/,%,$(LIBBPF_BOOTSTRAP_OUTPUT)) \
+ DESTDIR="" PREFIX=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) \
ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" $@ install_headers
ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
CFLAGS="$(LIBBPF_BOOTSTRAP_CFLAGS)" EXTRA_CFLAGS= $@ install_headers

$(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
@@ -75,9 +73,9 @@
@@ -76,9 +74,9 @@
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(or $(OUTPUT),.) \
-I$(LIBBPF_INCLUDE) \
Expand All @@ -71,7 +71,7 @@
ifneq ($(BPFTOOL_VERSION),)
CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
endif
@@ -123,11 +121,7 @@
@@ -146,11 +144,7 @@
endif

ifeq ($(check_feat),1)
Expand All @@ -83,17 +83,17 @@
+include Makefile.feature
endif

LIBS = $(LIBBPF) -lelf -lz
@@ -225,7 +219,7 @@
$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
$(QUIET_CLANG)$(CLANG) \
LIBS = $(LIBBPF) -lelf $(CRYPTO_LIBS) -lz
@@ -263,7 +257,7 @@
-Wno-microsoft-anon-tag \
-fms-extensions \
-I$(or $(OUTPUT),.) \
- -I$(srctree)/tools/include/uapi/ \
+ -I$(srctree)/include/uapi/ \
-I$(LIBBPF_BOOTSTRAP_INCLUDE) \
-g -O2 -Wall -fno-stack-protector \
--target=bpf -c $< -o $@
@@ -243,7 +237,7 @@
@@ -281,7 +275,7 @@

CFLAGS += $(if $(BUILD_BPF_SKELS),,-DBPFTOOL_WITHOUT_SKELETONS)

Expand All @@ -102,7 +102,7 @@
$(QUIET_CC)$(CC) $(CFLAGS) -c -MMD $< -o $@

$(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP)
@@ -262,7 +256,7 @@
@@ -300,7 +294,7 @@
$(call QUIET_CLEAN, feature-detect)
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null

Expand All @@ -111,7 +111,7 @@
$(call QUIET_CLEAN, bpftool)
$(Q)$(RM) -- $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
$(Q)$(RM) -- $(OUTPUT)*.skel.h $(OUTPUT)vmlinux.h
@@ -278,7 +272,7 @@
@@ -316,7 +310,7 @@

install: install-bin
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
Expand All @@ -120,7 +120,7 @@

uninstall:
$(call QUIET_UNINST, bpftool)
@@ -286,16 +280,16 @@
@@ -324,16 +318,16 @@
$(Q)$(RM) -- $(DESTDIR)$(bash_compdir)/bpftool

doc:
Expand Down
13 changes: 6 additions & 7 deletions src/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
case BTF_KIND_STRUCT:
case BTF_KIND_UNION: {
const struct btf_member *m = (const void *)(t + 1);
__u32 i, vlen = BTF_INFO_VLEN(t->info);
__u32 i, vlen = btf_vlen(t);

if (json_output) {
jsonw_uint_field(w, "size", t->size);
Expand All @@ -193,7 +193,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
const char *name = btf_str(btf, m->name_off);
__u32 bit_off, bit_sz;

if (BTF_INFO_KFLAG(t->info)) {
if (btf_kflag(t)) {
bit_off = BTF_MEMBER_BIT_OFFSET(m->offset);
bit_sz = BTF_MEMBER_BITFIELD_SIZE(m->offset);
} else {
Expand Down Expand Up @@ -224,7 +224,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
}
case BTF_KIND_ENUM: {
const struct btf_enum *v = (const void *)(t + 1);
__u32 i, vlen = BTF_INFO_VLEN(t->info);
__u32 i, vlen = btf_vlen(t);
const char *encoding;

encoding = btf_kflag(t) ? "SIGNED" : "UNSIGNED";
Expand Down Expand Up @@ -300,8 +300,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
break;
}
case BTF_KIND_FWD: {
const char *fwd_kind = BTF_INFO_KFLAG(t->info) ? "union"
: "struct";
const char *fwd_kind = btf_kflag(t) ? "union" : "struct";

if (json_output)
jsonw_string_field(w, "fwd_kind", fwd_kind);
Expand All @@ -322,7 +321,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
}
case BTF_KIND_FUNC_PROTO: {
const struct btf_param *p = (const void *)(t + 1);
__u32 i, vlen = BTF_INFO_VLEN(t->info);
__u32 i, vlen = btf_vlen(t);

if (json_output) {
jsonw_uint_field(w, "ret_type_id", t->type);
Expand Down Expand Up @@ -365,7 +364,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
case BTF_KIND_DATASEC: {
const struct btf_var_secinfo *v = (const void *)(t + 1);
const struct btf_type *vt;
__u32 i, vlen = BTF_INFO_VLEN(t->info);
__u32 i, vlen = btf_vlen(t);

if (json_output) {
jsonw_uint_field(w, "size", t->size);
Expand Down
14 changes: 7 additions & 7 deletions src/btf_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ static int btf_dumper_struct(const struct btf_dumper *d, __u32 type_id,
if (!t)
return -EINVAL;

kind_flag = BTF_INFO_KFLAG(t->info);
vlen = BTF_INFO_VLEN(t->info);
kind_flag = btf_kflag(t);
vlen = btf_vlen(t);
jsonw_start_object(d->jw);
m = (struct btf_member *)(t + 1);

Expand Down Expand Up @@ -535,7 +535,7 @@ static int btf_dumper_datasec(const struct btf_dumper *d, __u32 type_id,
if (!t)
return -EINVAL;

vlen = BTF_INFO_VLEN(t->info);
vlen = btf_vlen(t);
vsi = (struct btf_var_secinfo *)(t + 1);

jsonw_start_object(d->jw);
Expand All @@ -557,7 +557,7 @@ static int btf_dumper_do_type(const struct btf_dumper *d, __u32 type_id,
{
const struct btf_type *t = btf__type_by_id(d->btf, type_id);

switch (BTF_INFO_KIND(t->info)) {
switch (btf_kind(t)) {
case BTF_KIND_INT:
return btf_dumper_int(t, bit_offset, data, d->jw,
d->is_plain_text);
Expand Down Expand Up @@ -631,7 +631,7 @@ static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id,

t = btf__type_by_id(btf, type_id);

switch (BTF_INFO_KIND(t->info)) {
switch (btf_kind(t)) {
case BTF_KIND_INT:
case BTF_KIND_TYPEDEF:
case BTF_KIND_FLOAT:
Expand Down Expand Up @@ -661,7 +661,7 @@ static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id,
break;
case BTF_KIND_FWD:
BTF_PRINT_ARG("%s %s ",
BTF_INFO_KFLAG(t->info) ? "union" : "struct",
btf_kflag(t) ? "union" : "struct",
btf__name_by_offset(btf, t->name_off));
break;
case BTF_KIND_VOLATILE:
Expand Down Expand Up @@ -718,7 +718,7 @@ static int btf_dump_func(const struct btf *btf, char *func_sig,
BTF_PRINT_ARG("%s(", btf__name_by_offset(btf, func->name_off));
else
BTF_PRINT_ARG("(");
vlen = BTF_INFO_VLEN(func_proto->info);
vlen = btf_vlen(func_proto);
for (i = 0; i < vlen; i++) {
struct btf_param *arg = &((struct btf_param *)(func_proto + 1))[i];

Expand Down
2 changes: 2 additions & 0 deletions src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h
if (sign_progs) {
sopts.insns = opts.insns;
sopts.insns_sz = opts.insns_sz;
sopts.data = opts.data;
sopts.data_sz = opts.data_sz;
sopts.excl_prog_hash = prog_sha;
sopts.excl_prog_hash_sz = sizeof(prog_sha);
sopts.signature = sig_buf;
Expand Down
24 changes: 20 additions & 4 deletions src/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,21 @@ int bpftool_prog_sign(struct bpf_load_and_run_opts *opts)
CMS_ContentInfo *cms = NULL;
long actual_sig_len = 0;
X509 *x509 = NULL;
void *data = NULL;
size_t data_sz;
int err = 0;

bd_in = BIO_new_mem_buf(opts->insns, opts->insns_sz);
data_sz = (size_t)opts->insns_sz + opts->data_sz;
data = malloc(data_sz);
if (!data) {
err = -ENOMEM;
goto cleanup;
}
memcpy(data, opts->insns, opts->insns_sz);
if (opts->data_sz)
memcpy((char *)data + opts->insns_sz, opts->data, opts->data_sz);

bd_in = BIO_new_mem_buf(data, data_sz);
if (!bd_in) {
err = -ENOMEM;
goto cleanup;
Expand Down Expand Up @@ -175,10 +187,13 @@ int bpftool_prog_sign(struct bpf_load_and_run_opts *opts)
goto cleanup;
}

EVP_Digest(opts->insns, opts->insns_sz, opts->excl_prog_hash,
&opts->excl_prog_hash_sz, EVP_sha256(), NULL);
if (EVP_Digest(opts->insns, opts->insns_sz, opts->excl_prog_hash,
&opts->excl_prog_hash_sz, EVP_sha256(), NULL) != 1) {
err = -EIO;
goto cleanup;
}

bd_out = BIO_new(BIO_s_mem());
bd_out = BIO_new(BIO_s_mem());
if (!bd_out) {
err = -ENOMEM;
goto cleanup;
Expand Down Expand Up @@ -212,6 +227,7 @@ int bpftool_prog_sign(struct bpf_load_and_run_opts *opts)
X509_free(x509);
EVP_PKEY_free(private_key);
BIO_free(bd_in);
free(data);
DISPLAY_OSSL_ERR(err < 0);
return err;
}
Loading