linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] uaccess: rust: add UserSliceReader::strcpy_into_buf
Date: Wed, 18 Jun 2025 20:21:33 +0200	[thread overview]
Message-ID: <DAPV905HEGUN.5CLGEF6MLNWN@kernel.org> (raw)
In-Reply-To: <CAH5fLghMD2RQynaFdLVa+JAy17o5NW_pe7p3Cj1-A-FQVA--_A@mail.gmail.com>

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@kernel.org> 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

  reply	other threads:[~2025-06-18 18:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 12:41 [PATCH v5 0/2] strncpy_from_user for Rust Alice Ryhl
2025-06-16 12:41 ` [PATCH v5 1/2] uaccess: rust: add strncpy_from_user Alice Ryhl
2025-06-16 12:41 ` [PATCH v5 2/2] uaccess: rust: add UserSliceReader::strcpy_into_buf Alice Ryhl
2025-06-17  7:38   ` Benno Lossin
2025-06-17  8:55     ` Alice Ryhl
2025-06-18 18:21       ` Benno Lossin [this message]
2025-07-13 23:37 ` [PATCH v5 0/2] strncpy_from_user for Rust Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DAPV905HEGUN.5CLGEF6MLNWN@kernel.org \
    --to=lossin@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).