On Mon, Nov 23, 2026 at 03:28:53PM +0000, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Medium] drm/ras: lost NLM_F_DUMP_INTR in > drm_ras_nl_get_retired_pages_dumpit() > - [Medium] drm/ras: missing node type checks in error-counter netlink > handlers
I have a v4 on the pipeline that solves all of these, but to get that right, I first need to quickly land these fixes that I found during this exercise: https://lore.kernel.org/dri-devel/[email protected]/T/#t Please help with review of those and I'll send the v4 soon... > -- > > commit 27c9afd08cd19612592b285ef905e2efcbf77cec > Author: Aravind Iddamsetty <[email protected]> > > drm/ras: Add retired-pages node type > > This commit adds a retired-pages node type to drm-ras along with the > get-retired-pages dump operation and the get-retired-pages-info do > operation. > > > diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c > > index b099eb67836e7..34e5dab997440 100644 > > --- a/drivers/gpu/drm/drm_ras.c > > +++ b/drivers/gpu/drm/drm_ras.c > > [ ... ] > > > @@ -617,6 +637,145 @@ int drm_ras_nl_set_error_threshold_doit(struct > > sk_buff *skb, struct genl_info *i > > return set_node_error_threshold(node_id, error_id, threshold); > > } > > > > +static struct drm_ras_node *get_retired_pages_node(const struct genl_info > > *info) > > +{ > > + struct nlattr *attr = info->attrs[DRM_RAS_A_RETIRED_PAGE_ATTRS_NODE_ID]; > > + struct drm_ras_node *node; > > + > > + node = xa_load(&drm_ras_xa, nla_get_u32(attr)); > > + if (!node || node->type != DRM_RAS_NODE_TYPE_RETIRED_PAGES) { > > + NL_SET_BAD_ATTR(info->extack, attr); > > + return NULL; > > + } > > + > > + return node; > > +} > > + > > +static int msg_put_retired_page(struct sk_buff *msg, u32 node_id, > > + const struct drm_ras_retired_page *page) > > +{ > > + if (nla_put_u32(msg, DRM_RAS_A_RETIRED_PAGE_ATTRS_NODE_ID, node_id) || > > + nla_put_uint(msg, DRM_RAS_A_RETIRED_PAGE_ATTRS_ADDRESS, > > page->address) || > > + nla_put_uint(msg, DRM_RAS_A_RETIRED_PAGE_ATTRS_SIZE, page->size) || > > + nla_put_u32(msg, DRM_RAS_A_RETIRED_PAGE_ATTRS_STATUS, page->status)) > > + return -EMSGSIZE; > > + > > + return 0; > > +} > > + > > +/** > > + * drm_ras_nl_get_retired_pages_dumpit() - Dump the retired pages of a node > > + * @skb: Netlink message buffer > > + * @cb: Callback context for multi-part dumps > > + * > > + * Appends one message per retired page, in increasing address order. The > > + * dump resumes from the next address after a buffer overflow, and is > > flagged > > + * with %NLM_F_DUMP_INTR if the list changed between messages. > > + * > > + * Return: 0 if all pages fit in @skb, -EMSGSIZE if the buffer filled up > > + * (requires multi-part continuation), or a negative error code on > > + * failure. > > + */ > > +int drm_ras_nl_get_retired_pages_dumpit(struct sk_buff *skb, > > + struct netlink_callback *cb) > > +{ > > + const struct genl_info *info = genl_info_dump(cb); > > + struct drm_ras_ctx *ctx = (void *)cb->ctx; > > + struct drm_ras_retired_page page; > > + struct drm_ras_node *node; > > + void *hdr; > > + int ret; > > + > > + if (!info->attrs || GENL_REQ_ATTR_CHECK(info, > > DRM_RAS_A_RETIRED_PAGE_ATTRS_NODE_ID)) > > + return -EINVAL; > > + > > + node = get_retired_pages_node(info); > > + if (!node) > > + return -ENOENT; > > + > > + for (;;) { > > + ret = node->query_retired_page(node, ctx->cursor, &page); > > + if (ret == -ENOENT) > > + return 0; > > + if (ret) > > + return ret; > > + > > + /* Never zero, so the first message is checked as well */ > > + cb->seq = page.generation + 1; > > + > > + hdr = genlmsg_iput(skb, info); > > + if (!hdr) > > + return -EMSGSIZE; > > + > > + genl_dump_check_consistent(cb, hdr); > > + > > + ret = msg_put_retired_page(skb, node->id, &page); > > + if (ret) { > > + genlmsg_cancel(skb, hdr); > > + return ret; > > + } > > + > > + genlmsg_end(skb, hdr); > > + ctx->cursor = page.address + 1; > > + } > > +} > > [Severity: Medium] > Can calling genl_dump_check_consistent(cb, hdr) before > msg_put_retired_page() lose NLM_F_DUMP_INTR across a multi-part dump > boundary? > > genlmsg_iput() only requires 20 bytes of tailroom, while > msg_put_retired_page() needs another 32 to 40 bytes. If the remaining skb > space falls in between when page.generation changes, > genl_dump_check_consistent() sets NLM_F_DUMP_INTR on hdr and updates > cb->prev_seq = cb->seq, after which msg_put_retired_page() fails with > -EMSGSIZE and genlmsg_cancel() discards hdr. When the dump resumes at the > same ctx->cursor in the next skb, cb->seq already matches cb->prev_seq, so > userspace never receives NLM_F_DUMP_INTR. > > Also, page.generation + 1 wraps to 0 in cb->seq when page.generation is > U32_MAX, and if all remaining pages at or above ctx->cursor are removed > between dump batches, query_retired_page() returns -ENOENT before cb->seq > is updated. Moving genl_dump_check_consistent() after > msg_put_retired_page() succeeds avoids consuming the sequence change on a > cancelled message. > > [ ... ] > > > @@ -631,14 +790,18 @@ int drm_ras_node_register(struct drm_ras_node *node) > > if (!node->device_name || !node->node_name) > > return -EINVAL; > > > > - /* Currently, only Error Counter Endpoints are supported */ > > - if (node->type != DRM_RAS_NODE_TYPE_ERROR_COUNTER) > > - return -EINVAL; > > - > > - /* Mandatory entries for Error Counter Node */ > > - if (node->type == DRM_RAS_NODE_TYPE_ERROR_COUNTER && > > - (!node->error_counter_range.last || !node->query_error_counter)) > > + switch (node->type) { > > + case DRM_RAS_NODE_TYPE_ERROR_COUNTER: > > + if (!node->error_counter_range.last || > > !node->query_error_counter) > > + return -EINVAL; > > + break; > > + case DRM_RAS_NODE_TYPE_RETIRED_PAGES: > > + if (!node->query_retired_page) > > + return -EINVAL; > > + break; > > + default: > > return -EINVAL; > > + } > > > > return xa_alloc(&drm_ras_xa, &node->id, node, xa_limit_32b, GFP_KERNEL); > > } > > [Severity: Medium] > Now that drm_ras_node_register() inserts DRM_RAS_NODE_TYPE_RETIRED_PAGES > nodes into drm_ras_xa, should the error-counter netlink handlers verify > that node->type == DRM_RAS_NODE_TYPE_ERROR_COUNTER? > > Without that check, passing a retired-pages node ID to the error-counter > operations causes get_node_error_threshold() and set_node_error_threshold() > to return -EOPNOTSUPP instead of -ENOENT, and causes > drm_ras_nl_get_error_counter_dumpit() to iterate over > node->error_counter_range on a non-error-counter node: > > drivers/gpu/drm/drm_ras.c:get_node_error_threshold() { > node = xa_load(&drm_ras_xa, node_id); > if (!node) > return -ENOENT; > > if (!node->query_error_threshold) > return -EOPNOTSUPP; > ... > } > > drivers/gpu/drm/drm_ras.c:drm_ras_nl_get_error_counter_dumpit() { > ... > node = xa_load(&drm_ras_xa, node_id); > if (!node) > return -ENOENT; > > for (error_id = max(node->error_counter_range.first, ctx->restart); > error_id <= node->error_counter_range.last; > error_id++) { > ... > } > > -- > Sashiko AI review ยท > https://sashiko.dev/#/patchset/[email protected]?part=1
