lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8ZVCB2BC5L7.2FK9GSCBCEGMO@proton.me>
Date: Sun, 06 Apr 2025 21:20:39 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alexandre Courbot <acourbot@...dia.com>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Danilo Krummrich <dakr@...nel.org>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Bjorn Helgaas <bhelgaas@...gle.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org
Subject: Re: [PATCH v3 2/2] samples: rust: convert PCI rust sample driver to use try_access_with()

On Sun Apr 6, 2025 at 3:58 PM CEST, Alexandre Courbot wrote:
> This method limits the scope of the revocable guard and is considered
> safer to use for most cases, so let's showcase it here.
>
> Acked-by: Danilo Krummrich <dakr@...nel.org>
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>

Reviewed-by: Benno Lossin <benno.lossin@...ton.me>

---
Cheers,
Benno

> ---
>  samples/rust/rust_driver_pci.rs | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> index 1fb6e44f33951c521c8b086a7a3a012af911cf26..f2cb1c220bce42d161cf48664e8a5dd19770ba97 100644
> --- a/samples/rust/rust_driver_pci.rs
> +++ b/samples/rust/rust_driver_pci.rs
> @@ -83,13 +83,12 @@ fn probe(pdev: &mut pci::Device, info: &Self::IdInfo) -> Result<Pin<KBox<Self>>>
>              GFP_KERNEL,
>          )?;
>  
> -        let bar = drvdata.bar.try_access().ok_or(ENXIO)?;
> +        let res = drvdata
> +            .bar
> +            .try_access_with(|b| Self::testdev(info, b))
> +            .ok_or(ENXIO)??;
>  
> -        dev_info!(
> -            pdev.as_ref(),
> -            "pci-testdev data-match count: {}\n",
> -            Self::testdev(info, &bar)?
> -        );
> +        dev_info!(pdev.as_ref(), "pci-testdev data-match count: {}\n", res);
>  
>          Ok(drvdata.into())
>      }



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ