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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d1693e2c-35a3-a411-edd8-3ea0964abb74@fb.com>
Date:   Fri, 23 Apr 2021 16:03:36 -0700
From:   Yonghong Song <yhs@...com>
To:     Andrii Nakryiko <andrii@...nel.org>, <bpf@...r.kernel.org>,
        <netdev@...r.kernel.org>, <ast@...com>, <daniel@...earbox.net>
CC:     <kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 5/6] selftests/bpf: extend linked_vars
 selftests with static variables



On 4/23/21 11:53 AM, Andrii Nakryiko wrote:
> Now that BPF static linker supports static variable renames and thus
> non-unique static variables in BPF skeleton, add tests validating static
> variables are resolved properly during multi-file static linking.
> 
> Signed-off-by: Andrii Nakryiko <andrii@...nel.org>

Acked-by: Yonghong Song <yhs@...com>

> ---
>   tools/testing/selftests/bpf/prog_tests/linked_vars.c | 12 ++++++++----
>   tools/testing/selftests/bpf/progs/linked_vars1.c     |  4 +++-
>   tools/testing/selftests/bpf/progs/linked_vars2.c     |  4 +++-
>   3 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/linked_vars.c b/tools/testing/selftests/bpf/prog_tests/linked_vars.c
> index 267166abe4c1..75dcce539ff1 100644
> --- a/tools/testing/selftests/bpf/prog_tests/linked_vars.c
> +++ b/tools/testing/selftests/bpf/prog_tests/linked_vars.c
> @@ -14,8 +14,12 @@ void test_linked_vars(void)
>   	if (!ASSERT_OK_PTR(skel, "skel_open"))
>   		return;
>   
> +	skel->bss->linked_vars1__input_bss_static = 100;
>   	skel->bss->input_bss1 = 1000;
> +
> +	skel->bss->linked_vars2__input_bss_static = 200;
>   	skel->bss->input_bss2 = 2000;
> +
>   	skel->bss->input_bss_weak = 3000;
>   
>   	err = linked_vars__load(skel);
> @@ -29,11 +33,11 @@ void test_linked_vars(void)
>   	/* trigger */
>   	syscall(SYS_getpgid);
>   
> -	ASSERT_EQ(skel->bss->output_bss1, 1000 + 2000 + 3000, "output_bss1");
> -	ASSERT_EQ(skel->bss->output_bss2, 1000 + 2000 + 3000, "output_bss2");
> +	ASSERT_EQ(skel->bss->output_bss1, 100 + 1000 + 2000 + 3000, "output_bss1");
> +	ASSERT_EQ(skel->bss->output_bss2, 200 + 1000 + 2000 + 3000, "output_bss2");
>   	/* 10 comes from "winner" input_data_weak in first obj file */
> -	ASSERT_EQ(skel->bss->output_data1, 1 + 2 + 10, "output_bss1");
> -	ASSERT_EQ(skel->bss->output_data2, 1 + 2 + 10, "output_bss2");
> +	ASSERT_EQ(skel->bss->output_data1, 1 + 2 + 10, "output_data1");
> +	ASSERT_EQ(skel->bss->output_data2, 1 + 2 + 10, "output_data2");
>   	/* 100 comes from "winner" input_rodata_weak in first obj file */
>   	ASSERT_EQ(skel->bss->output_rodata1, 11 + 22 + 100, "output_weak1");
>   	ASSERT_EQ(skel->bss->output_rodata2, 11 + 22 + 100, "output_weak2");
> diff --git a/tools/testing/selftests/bpf/progs/linked_vars1.c b/tools/testing/selftests/bpf/progs/linked_vars1.c
> index ef9e9d0bb0ca..7d5152c066d9 100644
> --- a/tools/testing/selftests/bpf/progs/linked_vars1.c
> +++ b/tools/testing/selftests/bpf/progs/linked_vars1.c
> @@ -10,6 +10,8 @@ extern int LINUX_KERNEL_VERSION __kconfig;
>   extern bool CONFIG_BPF_SYSCALL __kconfig __weak;
>   extern const void bpf_link_fops __ksym __weak;
>   
> +static volatile int input_bss_static;
> +
>   int input_bss1;
>   int input_data1 = 1;
>   const volatile int input_rodata1 = 11;
> @@ -32,7 +34,7 @@ long output_sink1;
>   static __noinline int get_bss_res(void)
>   {
>   	/* just make sure all the relocations work against .text as well */
> -	return input_bss1 + input_bss2 + input_bss_weak;
> +	return input_bss_static + input_bss1 + input_bss2 + input_bss_weak;
>   }
>   
>   SEC("raw_tp/sys_enter")
> diff --git a/tools/testing/selftests/bpf/progs/linked_vars2.c b/tools/testing/selftests/bpf/progs/linked_vars2.c
> index e4f5bd388a3c..fdc347a609d9 100644
> --- a/tools/testing/selftests/bpf/progs/linked_vars2.c
> +++ b/tools/testing/selftests/bpf/progs/linked_vars2.c
> @@ -10,6 +10,8 @@ extern int LINUX_KERNEL_VERSION __kconfig;
>   extern bool CONFIG_BPF_SYSCALL __kconfig;
>   extern const void __start_BTF __ksym;
>   
> +static volatile int input_bss_static;
> +
>   int input_bss2;
>   int input_data2 = 2;
>   const volatile int input_rodata2 = 22;
> @@ -38,7 +40,7 @@ static __noinline int get_data_res(void)
>   SEC("raw_tp/sys_enter")
>   int BPF_PROG(handler2)
>   {
> -	output_bss2 = input_bss1 + input_bss2 + input_bss_weak;
> +	output_bss2 = input_bss_static + input_bss1 + input_bss2 + input_bss_weak;
>   	output_data2 = get_data_res();
>   	output_rodata2 = input_rodata1 + input_rodata2 + input_rodata_weak;
>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ