trace_user_fault_read(9)
π trace_user_fault_read(9) β Kernel API Manual, bestie edition π
okay so this is a page straight out of the Kernel API Manual, and honestly? it's giving "copy stuff from user space into a per-CPU buffer" and I'm obsessed. let's get into it. β¨
πΈ NAME πΈ
trace_user_fault_read β literally just reading user space into a per CPU buffer, no cap π
π¦ SYNOPSIS π¦
char * trace_user_fault_read (struct trace_user_buf_info *tinfo , const
char __user *ptr , size_t size , trace_user_buf_copy copy_func , void
*data );
β¨ ARGUMENTS β¨
tinfoβ thetinfothat was allocated bytrace_user_fault_get. it's the whole vibe check for where this buffer lives π«Άptrβ the user space pointer you wanna read, bestie πsizeβ how much user space you're reading. the size. yes, that size πcopy_funcβ an optional function to use for copying from user space. optional like your third coffee of the day βdataβ data passed along tocopy_func, but only if you actually supplied one π
π DESCRIPTION π
okay so preemption must be disabled when this is called, and it must not be enabled while you're using the returned buffer. not me being dramatic β this is the actual rule. π₯ what this does is copy from user space into a per CPU buffer, and it does it per CPU, which is the whole point.
the size must not be greater than the size you passed in to trace_user_fault_init. that's the ceiling, queen. π
if copy_func is NULL, then trace_user_fault_read will just use copy_from_user, no big deal. otherwise it calls copy_func. and when it calls copy_func, it hands it these:
buffer: the per CPU buffer of thetinfoptr: the pointer ptr to user space to readsize: the size of the ptr to readdata: the data parameter
it's expected that copy_func will return 0 on success and non zero if there was a fault. so like, 0 = slay, non zero = something went wrong π
returns a pointer to the buffer with the content read from ptr. preemption must remain disabled while the caller accesses the buffer this function returns β fr fr, don't turn it back on mid-buffer, that's not the move. π ββοΈ
returns NULL if there was a fault, or if the size you passed in is greater than the size passed to trace_user_fault_init. so NULL is the "nope" return, both ways. π
β οΈ quick recap bestie: preemption stays off for the whole ride, and yoursizenever exceeds thetrace_user_fault_initsize. those are the two non-negotiables. π
π SEE ALSO π
kernel file ./kernel/trace/trace.c, plus the whole friend group:
trace_array_put(9)tracing_is_enabled(9)tracing_on(9)tracing_snapshot(9)tracing_alloc_snapshot(9)tracer_tracing_disable(9)tracer_tracing_enable(9)tracing_off(9)tracer_tracing_is_on(9)tracing_is_on(9)register_tracer(9)tracing_start(9)tracing_stop(9)trace_buffered_event_enable(9)trace_buffered_event_disable(9)trace_dump_stack(9)ignore_event(9)trace_adjust_address(9)tracing_update_buffers(9)trace_user_fault_destroy(9)trace_user_fault_init(9)trace_user_fault_get(9)trace_user_fault_put(9)err_pos(9)tracing_log_err(9)trace_array_get_by_name(9)tracing_init_dentry(9)
and that's the page, bestie!! π§ it lives in ./kernel/trace, it's dated October 2026, and it's filed under trace_user_fault_read(9) β iykyk π mwah, go read some user space π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms