summaryrefslogtreecommitdiff
path: root/include/linux/debugobjects.h
diff options
context:
space:
mode:
authorAnastasios Papagiannis <tasos.papagiannnis@gmail.com>2026-09-18 16:17:55 +0300
committerAlexei Starovoitov <ast@kernel.org>2026-09-18 15:32:01 +0000
commit3f9d98dfed79ffc969d15cf214388ebf861f03af (patch)
treeb39e89876b3e77f0c2e149fca6d1c947db8d4c25 /include/linux/debugobjects.h
parentadc7fb9955e2718faf949cdc1efaf78179978445 (diff)
bpf: Add user memory access kfuncs for mm_struct
On CONFIG_MMU kernels, when security_bprm_check() runs, the argument and environment strings for the exec have been copied into bprm->mm. The new address space is not associated with a task_struct until exec_mmap(), so existing BPF user memory helpers cannot access it. Add bpf_copy_from_user_mm() and bpf_copy_from_user_mm_str() kfuncs. Both take a struct mm_struct pointer directly, allowing callers to access trusted address spaces that are not associated with a task_struct. bpf_copy_from_user_mm() has similar semantics to bpf_copy_from_user_task(). bpf_copy_from_user_mm_str() copies one NUL-terminated string and returns its size including the NUL terminator. It accepts BPF_F_PAD_ZEROS to clear unused destination bytes on success. Refactor the task-based helpers and the new mm-based kfuncs to share static internal implementations. The task-based interfaces validate their arguments before acquiring and holding a reference to the task's mm for the copy. No behavior change is intended for the existing task-based interfaces. Register both new kfuncs and mark them KF_SLEEPABLE because accessing a remote address space can fault. Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Matt Bobrowski <matt@bobrowski.net> Link: https://patch.msgid.link/20260918131757.42802-4-tasos.papagiannnis@gmail.com
Diffstat (limited to 'include/linux/debugobjects.h')
0 files changed, 0 insertions, 0 deletions