tools/testing/selftests/bpf/progs/wakeup_source_fail.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/wakeup_source_fail.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/wakeup_source_fail.c- Extension
.c- Size
- 1575 bytes
- Lines
- 77
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
struct bpf_ws_lockfunction __msgfunction __msgfunction __msgfunction __msgfunction __msg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright 2026 Google LLC */
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
struct bpf_ws_lock;
struct bpf_ws_lock *bpf_wakeup_sources_read_lock(void) __ksym;
void bpf_wakeup_sources_read_unlock(struct bpf_ws_lock *lock) __ksym;
void *bpf_wakeup_sources_get_head(void) __ksym;
SEC("syscall")
__failure __msg("BPF_EXIT instruction in main prog would lead to reference leak")
int wakeup_source_lock_no_unlock(void *ctx)
{
struct bpf_ws_lock *lock;
lock = bpf_wakeup_sources_read_lock();
if (!lock)
return 0;
return 0;
}
SEC("syscall")
__failure __msg("access beyond struct")
int wakeup_source_access_lock_fields(void *ctx)
{
struct bpf_ws_lock *lock;
int val;
lock = bpf_wakeup_sources_read_lock();
if (!lock)
return 0;
val = *(int *)lock;
bpf_wakeup_sources_read_unlock(lock);
return val;
}
SEC("syscall")
__failure __msg("release kfunc bpf_wakeup_sources_read_unlock expects referenced PTR_TO_BTF_ID passed to R1")
int wakeup_source_unlock_no_lock(void *ctx)
{
struct bpf_ws_lock *lock = (void *)0x1;
bpf_wakeup_sources_read_unlock(lock);
return 0;
}
SEC("syscall")
__failure __msg("Possibly NULL pointer passed to trusted")
int wakeup_source_unlock_null(void *ctx)
{
bpf_wakeup_sources_read_unlock(NULL);
return 0;
}
SEC("syscall")
__failure __msg("R0 invalid mem access 'scalar'")
int wakeup_source_unsafe_dereference(void *ctx)
{
struct list_head *head = bpf_wakeup_sources_get_head();
if (head->next)
return 1;
return 0;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `struct bpf_ws_lock`, `function __msg`, `function __msg`, `function __msg`, `function __msg`, `function __msg`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.