Re: [PATCH v5 2/2] uaccess: rust: add UserSliceReader::strcpy_into_buf

From: Benno Lossin
Date: Wed Jun 18 2025 - 14:22:01 EST


On Tue Jun 17, 2025 at 10:55 AM CEST, Alice Ryhl wrote:
> On Tue, Jun 17, 2025 at 9:38 AM Benno Lossin <lossin@xxxxxxxxxx> wrote:
>> What about the case `self.length == 0`? Will `raw_strncpy_from_user`
>> return early with a page fault, or will it return with `len == 0`?
>> Because if it is the latter, then this will result in UB.
>
> If `self.length == 0`, then you will either:
> 1. If buf.is_empty() then you return EINVAL at the top.
> 2. Otherwise, you return EFAULT from the `len < buf.len()` case.

Ah that makes sense. Thanks for explaining.

---
Cheers,
Benno