Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 71 lines 1.5 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3#include <vmlinux.h> 4#include <bpf/bpf_helpers.h> 5#include "bpf_misc.h" 6 7#if __clang_major__ >= 21 && 0 8SEC("socket") 9__description("__builtin_trap with simple c code") 10__failure __msg("unexpected __bpf_trap() due to uninitialized variable?") 11void bpf_builtin_trap_with_simple_c(void) 12{ 13 __builtin_trap(); 14} 15#endif 16 17SEC("socket") 18__description("__bpf_trap with simple c code") 19__failure __msg("unexpected __bpf_trap() due to uninitialized variable?") 20void bpf_trap_with_simple_c(void) 21{ 22 __bpf_trap(); 23} 24 25SEC("socket") 26__description("__bpf_trap as the second-from-last insn") 27__failure __msg("unexpected __bpf_trap() due to uninitialized variable?") 28__naked void bpf_trap_at_func_end(void) 29{ 30 asm volatile ( 31 "r0 = 0;" 32 "call %[__bpf_trap];" 33 "exit;" 34 : 35 : __imm(__bpf_trap) 36 : __clobber_all); 37} 38 39SEC("socket") 40__description("dead code __bpf_trap in the middle of code") 41__success 42__naked void dead_bpf_trap_in_middle(void) 43{ 44 asm volatile ( 45 "r0 = 0;" 46 "if r0 == 0 goto +1;" 47 "call %[__bpf_trap];" 48 "r0 = 2;" 49 "exit;" 50 : 51 : __imm(__bpf_trap) 52 : __clobber_all); 53} 54 55SEC("socket") 56__description("reachable __bpf_trap in the middle of code") 57__failure __msg("unexpected __bpf_trap() due to uninitialized variable?") 58__naked void live_bpf_trap_in_middle(void) 59{ 60 asm volatile ( 61 "r0 = 0;" 62 "if r0 == 1 goto +1;" 63 "call %[__bpf_trap];" 64 "r0 = 2;" 65 "exit;" 66 : 67 : __imm(__bpf_trap) 68 : __clobber_all); 69} 70 71char _license[] SEC("license") = "GPL";