include/linux/instrumented.h
Source file repositories/reference/linux-study-clean/include/linux/instrumented.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/instrumented.h- Extension
.h- Size
- 6884 bytes
- Lines
- 234
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
linux/bug.hlinux/compiler.hlinux/kasan-checks.hlinux/kcsan-checks.hlinux/kmsan-checks.hlinux/types.h
Detected Declarations
function instrument_readfunction instrument_writefunction instrument_read_writefunction instrument_atomic_check_alignmentfunction instrument_atomic_readfunction instrument_atomic_writefunction instrument_atomic_read_writefunction instrument_copy_to_userfunction instrument_copy_from_user_beforefunction instrument_copy_from_user_afterfunction instrument_memcpy_beforefunction instrument_memcpy_after
Annotated Snippet
#ifndef _LINUX_INSTRUMENTED_H
#define _LINUX_INSTRUMENTED_H
#include <linux/bug.h>
#include <linux/compiler.h>
#include <linux/kasan-checks.h>
#include <linux/kcsan-checks.h>
#include <linux/kmsan-checks.h>
#include <linux/types.h>
/**
* instrument_read - instrument regular read access
* @v: address of access
* @size: size of access
*
* Instrument a regular read access. The instrumentation should be inserted
* before the actual read happens.
*/
static __always_inline void instrument_read(const volatile void *v, size_t size)
{
kasan_check_read(v, size);
kcsan_check_read(v, size);
}
/**
* instrument_write - instrument regular write access
* @v: address of access
* @size: size of access
*
* Instrument a regular write access. The instrumentation should be inserted
* before the actual write happens.
*/
static __always_inline void instrument_write(const volatile void *v, size_t size)
{
kasan_check_write(v, size);
kcsan_check_write(v, size);
}
/**
* instrument_read_write - instrument regular read-write access
* @v: address of access
* @size: size of access
*
* Instrument a regular write access. The instrumentation should be inserted
* before the actual write happens.
*/
static __always_inline void instrument_read_write(const volatile void *v, size_t size)
{
kasan_check_write(v, size);
kcsan_check_read_write(v, size);
}
static __always_inline void instrument_atomic_check_alignment(const volatile void *v, size_t size)
{
#ifndef __DISABLE_EXPORTS
if (IS_ENABLED(CONFIG_DEBUG_ATOMIC)) {
unsigned int mask = size - 1;
if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_LARGEST_ALIGN))
mask &= sizeof(struct { long x; } __aligned_largest) - 1;
WARN_ON_ONCE((unsigned long)v & mask);
}
#endif
}
/**
* instrument_atomic_read - instrument atomic read access
* @v: address of access
* @size: size of access
*
* Instrument an atomic read access. The instrumentation should be inserted
* before the actual read happens.
*/
static __always_inline void instrument_atomic_read(const volatile void *v, size_t size)
{
kasan_check_read(v, size);
kcsan_check_atomic_read(v, size);
instrument_atomic_check_alignment(v, size);
}
/**
* instrument_atomic_write - instrument atomic write access
* @v: address of access
* @size: size of access
*
* Instrument an atomic write access. The instrumentation should be inserted
* before the actual write happens.
*/
static __always_inline void instrument_atomic_write(const volatile void *v, size_t size)
{
Annotation
- Immediate include surface: `linux/bug.h`, `linux/compiler.h`, `linux/kasan-checks.h`, `linux/kcsan-checks.h`, `linux/kmsan-checks.h`, `linux/types.h`.
- Detected declarations: `function instrument_read`, `function instrument_write`, `function instrument_read_write`, `function instrument_atomic_check_alignment`, `function instrument_atomic_read`, `function instrument_atomic_write`, `function instrument_atomic_read_write`, `function instrument_copy_to_user`, `function instrument_copy_from_user_before`, `function instrument_copy_from_user_after`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.