Drivers may want to avoid requiring CAP_NET_ADMIN for subsequent
drm-ras operations. However, userspace must still be able to access
the list of RAS nodes to determine the node IDs. So, drop the
CAP_NET_ADMIN requirement for dumping RAS nodes so that drivers
with different permission requirements are still able to use the
interface.

Additionally, initialize the return value to zero in
drm_ras_nl_list_nodes_dumpit to avoid leaking uninitialized kernel
memory (especailly now that this function no longer requires admin
permissions).

This prepares the interface to be used for telemetry by the qaic
driver.

Reviewed-by: Rodrigo Vivi <[email protected]>
Signed-off-by: Zack McKevitt <[email protected]>
---
 Documentation/netlink/specs/drm_ras.yaml | 1 -
 drivers/gpu/drm/drm_ras.c                | 2 +-
 drivers/gpu/drm/drm_ras_nl.c             | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Documentation/netlink/specs/drm_ras.yaml 
b/Documentation/netlink/specs/drm_ras.yaml
index 4c2ac9a1ba3f..a88fdab7a1c7 100644
--- a/Documentation/netlink/specs/drm_ras.yaml
+++ b/Documentation/netlink/specs/drm_ras.yaml
@@ -112,7 +112,6 @@ operations:
            the node IDs. These IDs are required for all subsequent
            operations on nodes, such as querying error counters.
       attribute-set: node-attrs
-      flags: [admin-perm]
       dump:
         reply:
           attributes:
diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c
index b099eb67836e..4f4777060a4e 100644
--- a/drivers/gpu/drm/drm_ras.c
+++ b/drivers/gpu/drm/drm_ras.c
@@ -130,7 +130,7 @@ int drm_ras_nl_list_nodes_dumpit(struct sk_buff *skb,
        struct drm_ras_node *node;
        struct nlattr *hdr;
        unsigned long id;
-       int ret;
+       int ret = 0;
 
        xa_for_each_start(&drm_ras_xa, id, node, ctx->restart) {
                hdr = genlmsg_iput(skb, info);
diff --git a/drivers/gpu/drm/drm_ras_nl.c b/drivers/gpu/drm/drm_ras_nl.c
index c9f5e0ceb3b5..ff0dc406c27c 100644
--- a/drivers/gpu/drm/drm_ras_nl.c
+++ b/drivers/gpu/drm/drm_ras_nl.c
@@ -46,7 +46,7 @@ static const struct genl_split_ops drm_ras_nl_ops[] = {
        {
                .cmd    = DRM_RAS_CMD_LIST_NODES,
                .dumpit = drm_ras_nl_list_nodes_dumpit,
-               .flags  = GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
+               .flags  = GENL_CMD_CAP_DUMP,
        },
        {
                .cmd            = DRM_RAS_CMD_GET_ERROR_COUNTER,
-- 
2.43.0

Reply via email to