Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2#include <stddef.h>
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5#include "bpf_misc.h"
6
7#if !defined(__clang__)
8#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
9#endif
10
11struct Small {
12 long x;
13};
14
15struct Big {
16 long x;
17 long y;
18};
19
20__noinline int foo(const struct Big *big)
21{
22 if (!big)
23 return 0;
24
25 return bpf_get_prandom_u32() < big->y;
26}
27
28SEC("cgroup_skb/ingress")
29__failure __msg("invalid indirect access to stack")
30int global_func10(struct __sk_buff *skb)
31{
32 const struct Small small = {.x = skb->len };
33
34 return foo((struct Big *)&small) ? 1 : 0;
35}
1// SPDX-License-Identifier: GPL-2.0-only
2#include <stddef.h>
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5#include "bpf_misc.h"
6
7struct Small {
8 long x;
9};
10
11struct Big {
12 long x;
13 long y;
14};
15
16__noinline int foo(const struct Big *big)
17{
18 if (!big)
19 return 0;
20
21 return bpf_get_prandom_u32() < big->y;
22}
23
24SEC("cgroup_skb/ingress")
25__failure __msg("invalid indirect access to stack")
26int global_func10(struct __sk_buff *skb)
27{
28 const struct Small small = {.x = skb->len };
29
30 return foo((struct Big *)&small) ? 1 : 0;
31}