xref: /openbmc/linux/tools/testing/selftests/bpf/progs/test_log_buf.c (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
3 
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 int a[4];
8 const volatile int off = 4000;
9 
10 SEC("raw_tp/sys_enter")
good_prog(const void * ctx)11 int good_prog(const void *ctx)
12 {
13 	a[0] = (int)(long)ctx;
14 	return a[1];
15 }
16 
17 SEC("raw_tp/sys_enter")
bad_prog(const void * ctx)18 int bad_prog(const void *ctx)
19 {
20 	/* out of bounds access */
21 	return a[off];
22 }
23 
24 char _license[] SEC("license") = "GPL";
25