blob: 353ae6da00e17e595f85cb113fa891963a7b5882 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// SPDX-License-Identifier: GPL-2.0
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
SEC("netfilter")
__description("bpf_exit with invalid return code. test1")
__failure __msg("R0 is not a known value")
__naked void with_invalid_return_code_test1(void)
{
asm volatile (" \
r0 = *(u64*)(r1 + 0); \
exit; \
" ::: __clobber_all);
}
SEC("netfilter")
__description("bpf_exit with valid return code. test2")
__success
__naked void with_valid_return_code_test2(void)
{
asm volatile (" \
r0 = 0; \
exit; \
" ::: __clobber_all);
}
SEC("netfilter")
__description("bpf_exit with valid return code. test3")
__success
__naked void with_valid_return_code_test3(void)
{
asm volatile (" \
r0 = 1; \
exit; \
" ::: __clobber_all);
}
SEC("netfilter")
__description("bpf_exit with invalid return code. test4")
__failure __msg("R0 has value (0x2; 0x0)")
__naked void with_invalid_return_code_test4(void)
{
asm volatile (" \
r0 = 2; \
exit; \
" ::: __clobber_all);
}
|