From: Benno Lossin <benno.lossin@proton.me>
To: Guangbo Cui <2407018371@qq.com>
Cc: a.hindborg@kernel.org, alex.gaynor@gmail.com,
aliceryhl@google.com, bjorn3_gh@protonmail.com,
boqun.feng@gmail.com, gary@garyguo.net,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
ojeda@kernel.org, rust-for-linux@vger.kernel.org,
simona.vetter@ffwll.ch, tmgross@umich.edu
Subject: Re: [PATCH v3 3/4] rust: validate: add `Validate` trait
Date: Mon, 21 Apr 2025 19:23:09 +0000 [thread overview]
Message-ID: <D9CK8IQAKV4Z.2YOX7NIAGTOS4@proton.me> (raw)
In-Reply-To: <tencent_D04FE925ED0AD6F0A4C297CA1A1A74FDE608@qq.com>
On Mon Apr 21, 2025 at 6:47 PM CEST, Guangbo Cui wrote:
> Really cool patch! I got a few thoughts below.
Thanks!
>> + /// Validate the underlying untrusted data.
>> + ///
>> + /// See the [`Validate`] trait for more information.
>> + pub fn validate_mut<'a, V: Validate<&'a mut Self>>(&'a mut self) -> Result<V, V::Err> {
>> + V::validate(&mut self.0)
>> + }
>> }
>
> The `validate_ref` and `validate_mut` functions should just call `V::validate(self)`
> directly, since self is an Untrusted<T>, and you already implemented ValidateInput for it.
> Calling `V::validate(&self.0)` would cause a type mismatch error.
Ah good catch, but the fix should be a different one. I intend to remove
the `Untrusted` wrapper in the input to `Validate::validate`, as
otherwise one would not be able to access the underlying value.
Maybe I don't need the `ValidateInput` trait after all. So the signature
of `validate{,_ref,_mut}` should ask for `V: Validate<{T, &T, &mut T}>`
instead.
---
Cheers,
Benno
next prev parent reply other threads:[~2025-04-21 19:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 13:49 [PATCH v3 0/4] Untrusted Data API Benno Lossin
2025-04-21 13:49 ` [PATCH v3 1/4] rust: transmute: add `cast_slice[_mut]` functions Benno Lossin
2025-04-21 18:42 ` Tamir Duberstein
2025-04-21 19:25 ` Benno Lossin
2025-04-21 13:49 ` [PATCH v3 2/4] rust: create basic untrusted data API Benno Lossin
2025-04-21 13:49 ` [PATCH v3 3/4] rust: validate: add `Validate` trait Benno Lossin
2025-04-21 16:47 ` Guangbo Cui
2025-04-21 19:23 ` Benno Lossin [this message]
2025-04-21 13:50 ` [PATCH v3 4/4] rust: iov: use untrusted data API Benno Lossin
2025-04-21 19:19 ` [PATCH v3 0/4] Untrusted Data API Benno Lossin
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=D9CK8IQAKV4Z.2YOX7NIAGTOS4@proton.me \
--to=benno.lossin@proton.me \
--cc=2407018371@qq.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--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=simona.vetter@ffwll.ch \
--cc=tmgross@umich.edu \
/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).