~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/verifier_cgroup_inv_retcode.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Converted from tools/testing/selftests/bpf/verifier/cgroup_inv_retcode.c */
  3 
  4 #include <linux/bpf.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include "bpf_misc.h"
  7 
  8 SEC("cgroup/sock")
  9 __description("bpf_exit with invalid return code. test1")
 10 __failure __msg("smin=0 smax=4294967295 should have been in [0, 1]")
 11 __naked void with_invalid_return_code_test1(void)
 12 {
 13         asm volatile ("                                 \
 14         r0 = *(u32*)(r1 + 0);                           \
 15         exit;                                           \
 16 "       ::: __clobber_all);
 17 }
 18 
 19 SEC("cgroup/sock")
 20 __description("bpf_exit with invalid return code. test2")
 21 __success
 22 __naked void with_invalid_return_code_test2(void)
 23 {
 24         asm volatile ("                                 \
 25         r0 = *(u32*)(r1 + 0);                           \
 26         r0 &= 1;                                        \
 27         exit;                                           \
 28 "       ::: __clobber_all);
 29 }
 30 
 31 SEC("cgroup/sock")
 32 __description("bpf_exit with invalid return code. test3")
 33 __failure __msg("smin=0 smax=3 should have been in [0, 1]")
 34 __naked void with_invalid_return_code_test3(void)
 35 {
 36         asm volatile ("                                 \
 37         r0 = *(u32*)(r1 + 0);                           \
 38         r0 &= 3;                                        \
 39         exit;                                           \
 40 "       ::: __clobber_all);
 41 }
 42 
 43 SEC("cgroup/sock")
 44 __description("bpf_exit with invalid return code. test4")
 45 __success
 46 __naked void with_invalid_return_code_test4(void)
 47 {
 48         asm volatile ("                                 \
 49         r0 = 1;                                         \
 50         exit;                                           \
 51 "       ::: __clobber_all);
 52 }
 53 
 54 SEC("cgroup/sock")
 55 __description("bpf_exit with invalid return code. test5")
 56 __failure __msg("smin=2 smax=2 should have been in [0, 1]")
 57 __naked void with_invalid_return_code_test5(void)
 58 {
 59         asm volatile ("                                 \
 60         r0 = 2;                                         \
 61         exit;                                           \
 62 "       ::: __clobber_all);
 63 }
 64 
 65 SEC("cgroup/sock")
 66 __description("bpf_exit with invalid return code. test6")
 67 __failure __msg("R0 is not a known value (ctx)")
 68 __naked void with_invalid_return_code_test6(void)
 69 {
 70         asm volatile ("                                 \
 71         r0 = r1;                                        \
 72         exit;                                           \
 73 "       ::: __clobber_all);
 74 }
 75 
 76 SEC("cgroup/sock")
 77 __description("bpf_exit with invalid return code. test7")
 78 __failure __msg("R0 has unknown scalar value should have been in [0, 1]")
 79 __naked void with_invalid_return_code_test7(void)
 80 {
 81         asm volatile ("                                 \
 82         r0 = *(u32*)(r1 + 0);                           \
 83         r2 = *(u32*)(r1 + 4);                           \
 84         r0 *= r2;                                       \
 85         exit;                                           \
 86 "       ::: __clobber_all);
 87 }
 88 
 89 char _license[] SEC("license") = "GPL";
 90 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php