KERNACC(9)
β¨ KERNACC(9) β¨
okay bestie, so this is a Kernel Developer's Manual page β section 9, the deep-magic zone where only the brave hang out π
. It's called kernacc and useracc, and it's literally just "can we touch this memory or not" energy. Let's get into it π«Ά
πΈ NAME πΈ
kernacc, useracc β check memory regions for accessibility π
π SYNOPSIS π
first, the vibes (the includes, don't skip them, they're load-bearing):
#include <sys/param.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
then the actual icons themselves:
int
kernacc(void *addr, int len, int rw);
int
useracc(void *addr, int len, int rw);
π¦ DESCRIPTION π¦
so here's the tea β β kernacc() and useracc() are your little vibe checkers. They look at the range of virtual addresses described by addr and len and ask: is this operation actually allowed here? The operation being checked is whatever you passed in rw.
And what can rw even be, you ask? It's any bitwise combination of these three baddies:
VM_PROT_READVM_PROT_WRITEVM_PROT_EXECUTE
not me saying you can absolutely OR them together like a little permissions smoothie π
The two functions are basically sisters, but they live in different neighborhoods:
kernacc()checks addresses up in the kernel address space πuseracc()treatsaddras a user space address π
and here's the plot twist β the process context used for this whole operation gets taken from the global variable curproc. not passed in, justβ¦ scooped out of the global. we'll circle back to that in BUGS bestie, don't worry π
π RETURN VALUES π
both functions keep it simple, iconic, no notes:
- they return boolean true if the type of access you specified in
rwis permitted β¨ - otherwise they return boolean false π
π BUGS π
the process pointer should be passed in as an argument to useracc().
fr fr. that's it. that's the bug. it's lowkey just vibing off curproc instead of taking it as a parameter π
and that's a wrap, bestie π«Ά this page came from the Debian crew, dated June 16, 1996 β yes, 1996, the manual page is older than most of the people reading it, and it's still serving πβ¨ slay, periodt.
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1996 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms