1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2020 Facebook */
3 #include <stddef.h>
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 #include "bpf_misc.h"
7 
8 __attribute__ ((noinline))
f1(struct __sk_buff * skb)9 int f1(struct __sk_buff *skb)
10 {
11 	return skb->len;
12 }
13 
14 int f3(int, struct __sk_buff *skb);
15 
16 __attribute__ ((noinline))
f2(int val,struct __sk_buff * skb)17 int f2(int val, struct __sk_buff *skb)
18 {
19 	return f1(skb) + f3(val, skb + 1); /* type mismatch */
20 }
21 
22 __attribute__ ((noinline))
f3(int val,struct __sk_buff * skb)23 int f3(int val, struct __sk_buff *skb)
24 {
25 	return skb->ifindex * val;
26 }
27 
28 SEC("tc")
29 __failure __msg("modified ctx ptr R2")
global_func6(struct __sk_buff * skb)30 int global_func6(struct __sk_buff *skb)
31 {
32 	return f1(skb) + f2(2, skb) + f3(3, skb);
33 }
34