Re: [PATCH bpf-next v3 2/2] selftests/bpf: test maximum recursion depth for bpf_core_types_are_compat()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 3, 2022 at 4:55 PM Matteo Croce <mcroce@xxxxxxxxxxxxxxxxxxx> 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.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux