From: sashiko-bot@kernel.org
To: "Raag Jadav" <raag.jadav@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 1/5] drm/ras: Cancel and free message on get counter failure
Date: Thu, 23 Jul 2026 03:47:31 +0000 [thread overview]
Message-ID: <20260723034731.E7C961F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722034228.662746-2-raag.jadav@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing RCU read lock or refcounting causes a Use-After-Free of `drm_ras_node` in netlink callbacks.
--
--- Patch [1]: [PATCH v5 1/5] drm/ras: Cancel and free message on get counter failure ---
commit a7d45a29dc348f6234c9ec9f5c9ccdf5d73188b7
Author: Raag Jadav <raag.jadav@intel.com>
drm/ras: Cancel and free message on get counter failure
doit_reply_value() directly returns on get counter failure, which results
in stale sk_buff and genetlink header that aren't cleaned up. Fix it and
while at it, consolidate error handling using goto.
> diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c
> index d6eab29a1394c..467a169026fc1 100644
> --- a/drivers/gpu/drm/drm_ras.c
> +++ b/drivers/gpu/drm/drm_ras.c
> @@ -201,25 +201,28 @@ static int doit_reply_value(struct genl_info *info, u32 node_id,
>
> hdr = genlmsg_iput(msg, info);
> if (!hdr) {
> - nlmsg_free(msg);
> - return -EMSGSIZE;
> + ret = -EMSGSIZE;
> + goto free_msg;
> }
>
> ret = get_node_error_counter(node_id, error_id,
> &error_name, &value);
[Severity: High]
This is a pre-existing issue, but is there a missing RCU read lock around
these node accesses?
Since drm_ras_nl_family uses parallel_ops = true, callbacks execute
concurrently without the global genl_lock(). Looking at
get_node_error_counter(), it retrieves the node using xa_load() and then
dereferences it:
get_node_error_counter() {
node = xa_load(&drm_ras_xa, node_id);
if (!node || !node->query_error_counter)
return -ENOENT;
...
return node->query_error_counter(node, error_id, name, value);
}
Because xa_load() only holds the RCU read lock internally and drops it
before returning, the node pointer is unprotected here. If a driver
concurrently unregisters and frees the node memory, could this lead to a
use-after-free when the callback dereferences node->query_error_counter?
A similar issue appears to exist in drm_ras_nl_list_nodes_dumpit() where
xa_for_each_start() is used without an encompassing rcu_read_lock().
> if (ret)
> - return ret;
> + goto cancel_msg;
>
> ret = msg_reply_value(msg, error_id, error_name, value);
> - if (ret) {
> - genlmsg_cancel(msg, hdr);
> - nlmsg_free(msg);
> - return ret;
> - }
> + if (ret)
> + goto cancel_msg;
>
> genlmsg_end(msg, hdr);
>
> return genlmsg_reply(msg, info);
> +
> +cancel_msg:
> + genlmsg_cancel(msg, hdr);
> +free_msg:
> + nlmsg_free(msg);
> + return ret;
> }
>
> /**
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722034228.662746-1-raag.jadav@intel.com?part=1
next prev parent reply other threads:[~2026-07-23 3:47 UTC|newest]
Thread overview: 15+ 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 [this message]
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-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
2026-07-22 3:41 ` [PATCH v5 5/5] drm/xe/sysctrl: Reuse xe_sysctrl_create_command() Raag Jadav
2026-07-22 3:53 ` ✗ CI.checkpatch: warning for Introduce error threshold to drm_ras (rev5) Patchwork
2026-07-22 3:54 ` ✓ CI.KUnit: success " Patchwork
2026-07-22 4:34 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-22 18:54 ` ✓ Xe.CI.FULL: " Patchwork
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=20260723034731.E7C961F000E9@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 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.