All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yilin Chen" <1479826151@qq.com>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH] rust: drm: fix GEM object pointer safety docs
Date: Tue, 07 Jul 2026 16:07:22 +0000	[thread overview]
Message-ID: <20260707160722.DF3FD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_37A376A02B95E3DBE7E5C64882B7A4F90807@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unsound Safety Contract in IntoGEMObject::from_raw
--

--- Patch [1]: [PATCH] rust: drm: fix GEM object pointer safety docs ---
commit 83b1634421cc950ce3b8ca23f3c9ab5c476d4697
Author: Yilin Chen <1479826151@qq.com>

rust: drm: fix GEM object pointer safety docs

This commit updates the Safety documentation for IntoGEMObject::from_raw()
to state that the argument must be a valid pointer to struct drm_gem_object
rather than a pointer to Self.

> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index c8b66d8168719..90b256093e4cb 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -118,7 +118,7 @@ pub trait IntoGEMObject: Sized + super::private::Sealed + AlwaysRefCounted {
>      ///
>      /// # Safety
>      ///
> -    /// - `self_ptr` must be a valid pointer to `Self`.
> +    /// - `self_ptr` must be a valid pointer to `struct drm_gem_object`.

[Severity: High]
Does this change make the safety contract unsound?

By removing the requirement that the pointer originates from an instance of
Self, the safety contract no longer protects against passing an arbitrary
valid drm_gem_object pointer.

If a caller satisfies this new documentation by passing a valid
drm_gem_object pointer that is not embedded in an instance of Self, won't
the container_of macro in the trait implementation yield an invalid pointer
and cause out-of-bounds memory access when fields of Self are accessed?

>      /// - The caller promises that holding the immutable reference returned by this function does
>      ///   not violate rust's data aliasing rules and remains valid throughout the lifetime of `'a`.
>      unsafe fn from_raw<'a>(self_ptr: *mut bindings::drm_gem_object) -> &'a Self;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_37A376A02B95E3DBE7E5C64882B7A4F90807@qq.com?part=1

      reply	other threads:[~2026-07-07 16:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 16:02 [PATCH] rust: drm: fix GEM object pointer safety docs Yilin Chen
2026-07-07 16:07 ` sashiko-bot [this message]

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=20260707160722.DF3FD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=1479826151@qq.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.