From: sashiko-bot@kernel.org
To: "Raag Jadav" <raag.jadav@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 4/5] drm/xe/drm_ras: Wire up error threshold callbacks
Date: Thu, 23 Jul 2026 03:47:32 +0000 [thread overview]
Message-ID: <20260723034732.934681F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722034228.662746-5-raag.jadav@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The driver violates the DRM RAS framework API contract by failing to perform bounds checking on the user-supplied threshold value.
Pre-existing issues:
- [High] Lack of reference counting or RCU read locks in the generic drm_ras core causes a TOCTOU race leading to Use-After-Free of drm_ras_node and xe_device during concurrent device unbind.
--
--- Patch [4]: [PATCH v5 4/5] drm/xe/drm_ras: Wire up error threshold callbacks ---
commit a57e8de665a45c38e3544fb21f325ce074bc995d
Author: Raag Jadav <raag.jadav@intel.com>
drm/xe/drm_ras: Wire up error threshold callbacks
This commit wires up the get/set error threshold support in the xe driver to
the generic drm_ras core. This allows userspace to query and configure
correctable error thresholds via Netlink.
> diff --git a/drivers/gpu/drm/xe/xe_drm_ras.c b/drivers/gpu/drm/xe/xe_drm_ras.c
> --- a/drivers/gpu/drm/xe/xe_drm_ras.c
> +++ b/drivers/gpu/drm/xe/xe_drm_ras.c
> @@ -86,6 +86,38 @@ static int clear_correctable_error_counter(struct drm_ras_node *node, u32 error_
> return clear_error_counter(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, error_id);
> }
>
> +static int query_correctable_error_threshold(struct drm_ras_node *ep, u32 error_id,
> + const char **name, u32 *threshold)
> +{
> + struct xe_device *xe = ep->priv;
[Severity: High]
This is a pre-existing issue, but can this dereference of ep and ep->priv
lead to a use-after-free during concurrent device unbind?
If a Netlink request calls get_node_error_threshold() in the generic drm_ras
core, it retrieves the node via xa_load() but doesn't hold RCU or take a
reference count. Concurrently, if the device is unbound, the drmm action
cleanup_node() could free the drm_ras_node and the xe_device.
When the Netlink thread resumes and calls this callback, could the ep pointer
and the xe_device it points to already be freed?
> + struct xe_drm_ras *ras = &xe->ras;
> + struct xe_drm_ras_counter *info = ras->info[DRM_XE_RAS_ERR_SEV_CORRECTABLE];
[ ... ]
> +static int set_correctable_error_threshold(struct drm_ras_node *ep, u32 error_id, u32 threshold)
> +{
> + struct xe_device *xe = ep->priv;
> + struct xe_drm_ras *ras = &xe->ras;
> + struct xe_drm_ras_counter *info = ras->info[DRM_XE_RAS_ERR_SEV_CORRECTABLE];
> +
> + if (!info || !info[error_id].name)
> + return -ENOENT;
> +
> + if (!xe->info.has_sysctrl)
> + return -EOPNOTSUPP;
> +
> + return xe_ras_set_threshold(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, error_id, threshold);
[Severity: Medium]
Is this missing a bounds check on the user-supplied threshold value?
The DRM RAS documentation in include/drm/drm_ras.h explicitly mandates
that the driver is responsible for error threshold bounds checking in the
set_error_threshold() callback. Here, the threshold value is passed directly
to xe_ras_set_threshold() and the system controller without validation.
Could this lead to speculative hardware misbehavior or interrupt storms if
userspace passes malformed values like 0 or an extremely large integer?
> +}
> +
> static struct xe_drm_ras_counter *allocate_and_copy_counters(struct xe_device *xe)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722034228.662746-1-raag.jadav@intel.com?part=4
next prev parent reply other threads:[~2026-07-23 3:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 3:41 [PATCH v5 0/5] Introduce error threshold to drm_ras Raag Jadav
2026-07-22 3:41 ` [PATCH v5 1/5] drm/ras: Cancel and free message on get counter failure Raag Jadav
2026-07-22 17:27 ` Rodrigo Vivi
2026-07-23 3:47 ` sashiko-bot
2026-07-22 3:41 ` [PATCH v5 2/5] drm/ras: Introduce error threshold Raag Jadav
2026-07-22 17:30 ` Rodrigo Vivi
2026-07-31 13:42 ` Raag Jadav
2026-08-05 9:53 ` Rodrigo Vivi
2026-07-23 3:47 ` sashiko-bot
2026-07-22 3:41 ` [PATCH v5 3/5] drm/xe/ras: Add support for " Raag Jadav
2026-07-22 3:41 ` [PATCH v5 4/5] drm/xe/drm_ras: Wire up error threshold callbacks Raag Jadav
2026-07-23 3:47 ` sashiko-bot [this message]
2026-07-22 3:41 ` [PATCH v5 5/5] drm/xe/sysctrl: Reuse xe_sysctrl_create_command() Raag Jadav
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=20260723034732.934681F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=raag.jadav@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox