lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <23399683-99A4-4E91-9C7B-8B0E3A4083DE@fb.com>
Date:   Tue, 3 Nov 2020 05:35:14 +0000
From:   Song Liu <songliubraving@...com>
To:     Andrii Nakryiko <andrii@...nel.org>
CC:     bpf <bpf@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf-next 10/11] selftests/bpf: add split BTF dedup
 selftests



> On Oct 28, 2020, at 5:59 PM, Andrii Nakryiko <andrii@...nel.org> wrote:
> 
> Add selftests validating BTF deduplication for split BTF case. Add a helper
> macro that allows to validate entire BTF with raw BTF dump, not just
> type-by-type. This saves tons of code and complexity.
> 
> Signed-off-by: Andrii Nakryiko <andrii@...nel.org>

Acked-by: Song Liu <songliubraving@...com>

with a couple nits:

[...]

> 
> int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id);
> const char *btf_type_raw_dump(const struct btf *btf, int type_id);
> +int btf_validate_raw(struct btf *btf, int nr_types, const char *exp_types[]);
> 
> +#define VALIDATE_RAW_BTF(btf, raw_types...)				\
> +	btf_validate_raw(btf,						\
> +			 sizeof((const char *[]){raw_types})/sizeof(void *),\
> +			 (const char *[]){raw_types})
> +
> +const char *btf_type_c_dump(const struct btf *btf);
> #endif
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> new file mode 100644
> index 000000000000..097370a41b60
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> @@ -0,0 +1,326 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2020 Facebook */
> +#include <test_progs.h>
> +#include <bpf/btf.h>
> +#include "btf_helpers.h"
> +
> +
> +static void test_split_simple() {
> +	const struct btf_type *t;
> +	struct btf *btf1, *btf2 = NULL;
> +	int str_off, err;
> +
> +	btf1 = btf__new_empty();
> +	if (!ASSERT_OK_PTR(btf1, "empty_main_btf"))
> +		return;
> +
> +	btf__set_pointer_size(btf1, 8); /* enforce 64-bit arch */
> +
> +	btf__add_int(btf1, "int", 4, BTF_INT_SIGNED);	/* [1] int */
> +	btf__add_ptr(btf1, 1);				/* [2] ptr to int */
> +	btf__add_struct(btf1, "s1", 4);			/* [3] struct s1 { */
> +	btf__add_field(btf1, "f1", 1, 0, 0);		/*      int f1; */
> +							/* } */
> +

nit: two empty lines. 

> +	VALIDATE_RAW_BTF(
> +		btf1,
> +		"[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED",
> +		"[2] PTR '(anon)' type_id=1",
> +		"[3] STRUCT 's1' size=4 vlen=1\n"
> +		"\t'f1' type_id=1 bits_offset=0");
> +

[...]

> +
> +cleanup:
> +	btf__free(btf2);
> +	btf__free(btf1);
> +}
> +
> +static void test_split_struct_duped() {
> +	struct btf *btf1, *btf2 = NULL;

nit: No need to initialize btf2, for all 3 tests. 

> +	int err;
> +
[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ