tools/testing/selftests/bpf/progs/exceptions_fail.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/exceptions_fail.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/exceptions_fail.c- Extension
.c- Size
- 8593 bytes
- Lines
- 450
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_tracing.hbpf/bpf_helpers.hbpf/bpf_core_read.hbpf_misc.hbpf_experimental.h
Detected Declarations
struct foostruct hmap_elemfunction exception_cb_bad_ret_type2function exception_cb_bad_arg_2function exception_cb_ok_arg_smallfunction __msgfunction __msgfunction __msgfunction reject_exception_cb_type_4function __msgfunction timer_cbfunction __msgfunction subprog_lockfunction __msgfunction __msgfunction __msgfunction throwing_subprogfunction __msgfunction rblessfunction __msgfunction __msgfunction global_subprog_may_throwfunction __msgfunction subprog_reffunction subprog_cb_reffunction __msgfunction __msgfunction __msgfunction throwing_exception_cbfunction exception_cb1function exception_cb2function static_funcfunction global_funcfunction __msgfunction __msgfunction __msgfunction __msgfunction exception_cb_bad_retfunction __msgfunction __msgfunction loop_cb1function loop_cb2function __msgfunction __msgfunction foofunction __msgfunction always_throwsfunction rcu_lock_then_throw
Annotated Snippet
struct foo {
struct bpf_rb_node node;
};
struct hmap_elem {
struct bpf_timer timer;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 64);
__type(key, int);
__type(value, struct hmap_elem);
} hmap SEC(".maps");
private(A) struct bpf_spin_lock lock;
private(A) struct bpf_rb_root rbtree __contains(foo, node);
__noinline void *exception_cb_bad_ret_type1(u64 cookie)
{
return NULL;
}
__noinline void exception_cb_bad_ret_type2(u64 cookie)
{
}
__noinline int exception_cb_bad_arg_0(void)
{
return 0;
}
__noinline int exception_cb_bad_arg_2(int a, int b)
{
return 0;
}
__noinline int exception_cb_ok_arg_small(int a)
{
return 0;
}
SEC("?tc")
__exception_cb(exception_cb_bad_ret_type1)
__failure __msg("Global function exception_cb_bad_ret_type1() return value not void or scalar.")
int reject_exception_cb_type_1(struct __sk_buff *ctx)
{
bpf_throw(0);
return 0;
}
SEC("?tc")
__exception_cb(exception_cb_bad_arg_0)
__failure __msg("exception cb only supports single integer argument")
int reject_exception_cb_type_2(struct __sk_buff *ctx)
{
bpf_throw(0);
return 0;
}
SEC("?tc")
__exception_cb(exception_cb_bad_arg_2)
__failure __msg("exception cb only supports single integer argument")
int reject_exception_cb_type_3(struct __sk_buff *ctx)
{
bpf_throw(0);
return 0;
}
SEC("?tc")
__exception_cb(exception_cb_ok_arg_small)
__success
int reject_exception_cb_type_4(struct __sk_buff *ctx)
{
bpf_throw(0);
return 0;
}
SEC("?tc")
__exception_cb(exception_cb_bad_ret_type2)
__failure __msg("exception cb cannot return void")
int reject_exception_cb_type_5(struct __sk_buff *ctx)
{
bpf_throw(0);
return 0;
}
__noinline
static int timer_cb(void *map, int *key, struct bpf_timer *timer)
{
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_tracing.h`, `bpf/bpf_helpers.h`, `bpf/bpf_core_read.h`, `bpf_misc.h`, `bpf_experimental.h`.
- Detected declarations: `struct foo`, `struct hmap_elem`, `function exception_cb_bad_ret_type2`, `function exception_cb_bad_arg_2`, `function exception_cb_ok_arg_small`, `function __msg`, `function __msg`, `function __msg`, `function reject_exception_cb_type_4`, `function __msg`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.