lkml.org 
[lkml]   [2022]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH bpf-next v3 2/2] selftests/bpf: test maximum recursion depth for bpf_core_types_are_compat()
On Thu, Feb 3, 2022 at 4:55 PM Matteo Croce <mcroce@linux.microsoft.com> wrote:
> --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> @@ -13,6 +13,11 @@
> #define CREATE_TRACE_POINTS
> #include "bpf_testmod-events.h"
>
> +typedef int (*func_proto_typedef___match)(long);
> +typedef int (*func_proto_typedef___overflow)(func_proto_typedef___match);

There is no need for "___flavor" on the kernel side of type definition.
It makes the test confusing to read.

> +func_proto_typedef___match funcp = NULL;
> +func_proto_typedef___overflow funcp_of = NULL;

We have BTF_TYPE_EMIT() macro to avoid unnecessary declaration.

> +typedef int (*func_proto_typedef___match)(long);
> +typedef int (*func_proto_typedef___overflow)(func_proto_typedef___match);

With <=1 in the previous patch such single depth of func_proto
was reaching the recursion limit.
Hence the fix <=0 was necessary.
I've also changed this test to:

+typedef int (*func_proto_typedef)(long);
+typedef int (*func_proto_typedef_nested1)(func_proto_typedef);
+typedef int (*func_proto_typedef_nested2)(func_proto_typedef_nested1);

in bpf_testmod.c and in progs/core_kern_overflow.c
and
bpf_core_type_exists(func_proto_typedef_nested2);
to go above the limit.

Also added bpf_core_type_exists(func_proto_typedef_nested1)
to progs/core_kern.c to stay at the limit.

Please see the result in bpf-next.

\
 
 \ /
  Last update: 2022-02-04 20:38    [W:0.071 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site