KERNACC(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

🌸 NAME 🌸

okay bestie, welcome to KERNACC(9) from the Kernel Developer's Manual β€” this page is literally all about kernacc and useracc, aka the functions that check memory regions for accessibility. Yes, both of them. Iconic.


πŸŽ€ SYNOPSIS πŸŽ€

the whole vibe is right here:

#include <sys/param.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>

int
kernacc(void *addr, int len, int rw);

int
useracc(void *addr, int len, int rw);

✨ DESCRIPTION ✨

okay so kernacc() and useracc() are the duo that checks whether operations of the type specified in rw are permitted in the range of virtual addresses given by addr and len. periodt.

the possible values of rw are any bitwise combination of VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. no cap, that's the whole menu.

kernacc() checks addresses in the kernel address space, while useracc() considers addr to represent an user space address. the process context to use for this operation is taken from the global variable curproc. iykyk 🫢


πŸ’– RETURN VALUES πŸ’–

both functions return boolean true if the type of access specified by rw is permitted. otherwise boolean false is returned. that's it, that's the tea. 😭


πŸ’€ BUGS πŸ’€

the process pointer should be passed in as an argument to useracc(). yes bestie, that's the bug note, and we are reporting it with love. πŸŽ€


xoxo, this Debian manual page is dated June 16, 1996 β€” bye bestie, go check those memory regions! πŸ’…βœ¨

πŸ“¦ where this page comes from