1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <vmlinux.h> 4 #include <bpf/bpf_helpers.h> 5 #include "bpf_misc.h" 6 7 __noinline 8 long changes_pkt_data(struct __sk_buff *sk) 9 { 10 return bpf_skb_pull_data(sk, 0); 11 } 12 13 __noinline __weak 14 long does_not_change_pkt_data(struct __sk_buff *sk) 15 { 16 return 0; 17 } 18 19 SEC("?tc") 20 int main_changes_with_subprogs(struct __sk_buff *sk) 21 { 22 changes_pkt_data(sk); 23 does_not_change_pkt_data(sk); 24 return 0; 25 } 26 27 SEC("?tc") 28 int main_changes(struct __sk_buff *sk) 29 { 30 bpf_skb_pull_data(sk, 0); 31 return 0; 32 } 33 34 SEC("?tc") 35 int main_does_not_change(struct __sk_buff *sk) 36 { 37 return 0; 38 } 39 40 __noinline 41 long might_sleep(struct pt_regs *ctx __arg_ctx) 42 { 43 int i; 44 45 bpf_copy_from_user(&i, sizeof(i), NULL); 46 return i; 47 } 48 49 __noinline __weak 50 long does_not_sleep(struct pt_regs *ctx __arg_ctx) 51 { 52 return 0; 53 } 54 55 SEC("?uprobe.s") 56 int main_might_sleep_with_subprogs(struct pt_regs *ctx) 57 { 58 might_sleep(ctx); 59 does_not_sleep(ctx); 60 return 0; 61 } 62 63 SEC("?uprobe.s") 64 int main_might_sleep(struct pt_regs *ctx) 65 { 66 int i; 67 68 bpf_copy_from_user(&i, sizeof(i), NULL); 69 return i; 70 } 71 72 SEC("?uprobe.s") 73 int main_does_not_sleep(struct pt_regs *ctx) 74 { 75 return 0; 76 } 77 78 char _license[] SEC("license") = "GPL"; 79