arch/um/kernel/skas/uaccess.c
Source file repositories/reference/linux-study-clean/arch/um/kernel/skas/uaccess.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/kernel/skas/uaccess.c- Extension
.c- Size
- 7573 bytes
- Lines
- 369
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/highmem.hlinux/mm.hlinux/module.hlinux/sched.hasm/current.hasm/page.hkern_util.hasm/futex.hos.h
Detected Declarations
function Copyrightfunction do_op_one_pagefunction buffer_opfunction copy_chunk_from_userfunction raw_copy_from_userfunction copy_chunk_to_userfunction raw_copy_to_userfunction strncpy_chunk_from_userfunction strncpy_from_userfunction clear_chunkfunction __clear_userfunction strnlen_chunkfunction strnlen_userfunction arch_futex_atomic_op_inuserfunction futex_atomic_cmpxchg_inatomicexport raw_copy_from_userexport raw_copy_to_userexport strncpy_from_userexport __clear_userexport strnlen_userexport arch_futex_atomic_op_inuserexport futex_atomic_cmpxchg_inatomic
Annotated Snippet
if (n != 0) {
remain = (n < 0 ? remain : 0);
goto out;
}
addr += PAGE_SIZE;
remain -= PAGE_SIZE;
}
if (remain == 0)
goto out;
n = do_op_one_page(addr, remain, is_write, op, arg);
if (n != 0) {
remain = (n < 0 ? remain : 0);
goto out;
}
return 0;
out:
return remain;
}
static int copy_chunk_from_user(unsigned long from, int len, void *arg)
{
unsigned long *to_ptr = arg, to = *to_ptr;
memcpy((void *) to, (void *) from, len);
*to_ptr += len;
return 0;
}
unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to);
}
EXPORT_SYMBOL(raw_copy_from_user);
static int copy_chunk_to_user(unsigned long to, int len, void *arg)
{
unsigned long *from_ptr = arg, from = *from_ptr;
memcpy((void *) to, (void *) from, len);
*from_ptr += len;
return 0;
}
unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from);
}
EXPORT_SYMBOL(raw_copy_to_user);
static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
{
char **to_ptr = arg, *to = *to_ptr;
int n;
n = strnlen((void *) from, len);
memcpy_and_pad(to, len, (void *) from, n, 0);
*to_ptr += n;
if (n < len)
return 1;
return 0;
}
long strncpy_from_user(char *dst, const char __user *src, long count)
{
long n;
char *ptr = dst;
if (!access_ok(src, 1))
return -EFAULT;
n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
&ptr);
if (n != 0)
return -EFAULT;
return strnlen(dst, count);
}
EXPORT_SYMBOL(strncpy_from_user);
static int clear_chunk(unsigned long addr, int len, void *unused)
{
memset((void *) addr, 0, len);
return 0;
}
unsigned long __clear_user(void __user *mem, unsigned long len)
{
return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
Annotation
- Immediate include surface: `linux/err.h`, `linux/highmem.h`, `linux/mm.h`, `linux/module.h`, `linux/sched.h`, `asm/current.h`, `asm/page.h`, `kern_util.h`.
- Detected declarations: `function Copyright`, `function do_op_one_page`, `function buffer_op`, `function copy_chunk_from_user`, `function raw_copy_from_user`, `function copy_chunk_to_user`, `function raw_copy_to_user`, `function strncpy_chunk_from_user`, `function strncpy_from_user`, `function clear_chunk`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: integration 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.