tools/testing/selftests/filesystems/openat2/rename_attack_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/openat2/rename_attack_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/openat2/rename_attack_test.c- Extension
.c- Size
- 3571 bytes
- Lines
- 160
- 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
errno.hfcntl.hsched.hsys/stat.hsys/types.hsys/mount.hsys/mman.hsys/prctl.hsignal.hstdio.hstdlib.hstdbool.hstring.hsyscall.hlimits.hunistd.hhelpers.hkselftest_harness.h
Detected Declarations
function Copyright
Annotated Snippet
if (fd < 0) {
if (fd == -EAGAIN)
eagains++;
else if (fd == -EXDEV)
exdevs++;
else if (fd == -ENOENT)
escapes++; /* escaped outside and got ENOENT... */
else
other_errs++; /* unexpected error */
} else {
if (fdequal(_metadata, fd, self->afd, NULL))
successes++;
else
escapes++; /* we got an unexpected fd */
}
if (fd >= 0)
close(fd);
}
TH_LOG("non-escapes: EAGAIN=%d EXDEV=%d E<other>=%d success=%d",
eagains, exdevs, other_errs, successes);
ASSERT_EQ(escapes, 0) {
TH_LOG("rename attack with %s (%d runs, got %d escapes)",
variant->name, ROUNDS, escapes);
}
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `sched.h`, `sys/stat.h`, `sys/types.h`, `sys/mount.h`, `sys/mman.h`, `sys/prctl.h`.
- Detected declarations: `function Copyright`.
- 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.