Re: [PATCH bpf-next 1/5] mm: Add copy_remote_mm_str()

From: bot+bpf-ci

Date: Tue Aug 11 2026 - 08:41:25 EST


> mm: Add copy_remote_mm_str()
>
> copy_remote_vm_str() gets the target address space from a struct
> task_struct. This does not work for an address space that exists but is
> not yet associated with a task_struct, such as the mm held by struct
> linux_binprm during exec.
>
> This patch adds copy_remote_mm_str(), which operates directly on a struct
> mm_struct.

This isn't a bug, but could this last paragraph be reworded in the
imperative, e.g. "Add copy_remote_mm_str(), which operates directly on a
struct mm_struct", to match the changelog style asked for in
submitting-patches.rst?

> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 485df9c2dbddb..eede435bf4a3f 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3222,6 +3222,8 @@ extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
> void *buf, int len, unsigned int gup_flags);
>
> #ifdef CONFIG_BPF_SYSCALL
> +extern int copy_remote_mm_str(struct mm_struct *mm, unsigned long addr,
> + void *buf, int len, unsigned int gup_flags);
> extern int copy_remote_vm_str(struct task_struct *tsk, unsigned long addr,
> void *buf, int len, unsigned int gup_flags);
> #endif
> diff --git a/mm/memory.c b/mm/memory.c
> index 6b8280cfc1dbe..03cbd3b02befb 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -7218,6 +7218,29 @@ static int __copy_remote_vm_str(struct mm_struct *mm, unsigned long addr,
> return buf - old_buf;
> }
>
> +/**
> + * copy_remote_mm_str - copy a string from a remote address space.
> + * @mm: the remote address space
> + * @addr: start address to read from
> + * @buf: destination buffer
> + * @len: number of bytes to copy
> + * @gup_flags: flags modifying lookup behaviour

This isn't a bug, but would it be worth using a tab after the parameter
colons here, to match the copy_remote_vm_str and access_remote_vm
kernel-doc blocks in the same files? This is the only kernel-doc block in
mm/memory.c that aligns parameter descriptions with spaces rather than a
tab.

> + *
> + * The caller must hold a reference on @mm.
> + *
> + * Return: number of bytes copied from @addr (source) to @buf (destination),
> + * not including the trailing NUL. Always guarantees a NUL-terminated buffer.
> + * On any error, return -EFAULT.
> + */
> +int copy_remote_mm_str(struct mm_struct *mm, unsigned long addr,
> + void *buf, int len, unsigned int gup_flags)
> +{
> + if (unlikely(len == 0))
> + return 0;
> +
> + return __copy_remote_vm_str(mm, addr, buf, len, gup_flags);
> +}
> +
> /**
> * copy_remote_vm_str - copy a string from another process's address space.
> * @tsk: the task of the target address space
> @@ -7247,7 +7270,7 @@ int copy_remote_vm_str(struct task_struct *tsk, unsigned long addr,
> return -EFAULT;
> }
>
> - ret = __copy_remote_vm_str(mm, addr, buf, len, gup_flags);
> + ret = copy_remote_mm_str(mm, addr, buf, len, gup_flags);
>
> mmput(mm);
>

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31488001112