tools/testing/selftests/bpf/progs/bpf_iter_tasks.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bpf_iter_tasks.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/bpf_iter_tasks.c- Extension
.c- Size
- 5686 bytes
- Lines
- 199
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.h
Detected Declarations
function dump_taskfunction dump_task_sleepable
Annotated Snippet
if (i % 2 == 0) {
if (big_str1[i] != 'b') {
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}
} else {
if (big_str1[i] != 'a') {
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}
}
}
/* Longer length than the string that crosses a page boundary */
ret = bpf_copy_from_user_task_str(big_str2, 5005, user_ptr_long, task, BPF_F_PAD_ZEROS);
if (bpf_strncmp(big_str2, 4, "baba") != 0 || ret != 5000
|| bpf_strncmp(big_str2 + 4996, 5, "bab\0\0") != 0) {
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}
/* Shorter length than the string that crosses a page boundary */
ret = bpf_copy_from_user_task_str(big_str3, 4996, user_ptr_long, task, 0);
if (bpf_strncmp(big_str3, 4, "baba") != 0 || ret != 4996
|| bpf_strncmp(big_str3 + 4992, 4, "bab\0") != 0) {
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}
++num_success_copy_from_user_task_str;
if (ctx->meta->seq_num == 0)
BPF_SEQ_PRINTF(seq, " tgid gid data\n");
BPF_SEQ_PRINTF(seq, "%8d %8d %8d\n", task->tgid, task->pid, user_data);
return 0;
}
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`.
- Detected declarations: `function dump_task`, `function dump_task_sleepable`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.