dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Timur Tabi <ttabi@nvidia.com>
To: Dave Airlie <airlied@redhat.com>, <nouveau@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>
Subject: [PATCH] nouveau/gsp: fix UBSAN array bounds warning in PACKED_REGISTRY_TABLE
Date: Tue, 7 Nov 2023 17:47:26 -0600	[thread overview]
Message-ID: <20231107234726.854248-1-ttabi@nvidia.com> (raw)

Change PACKED_REGISTRY_TABLE so that its last member is a variable-length
array instead of a zero-length array.  UBSAN treats zero-length arrays
literally and warns if they are dereferenced.  Changing the "[0]" to "[]"
tells the compiler that the array is variable-length.

This fixes the following warning in function r535_gsp_rpc_set_registry
when CONFIG_UBSAN_BOUNDS is enabled:

UBSAN: array-index-out-of-bounds in drivers/gpu/drm/nouveau/nvkm/
subdev/gsp/r535.c:1066:33
index 2 is out of range for type 'PACKED_REGISTRY_ENTRY [*]'

Fixes: b5bad8c16b9b ("nouveau/gsp: move to 535.113.01")
Signed-off-by: Timur Tabi <ttabi@nvidia.com>
---
 .../include/nvrm/535.113.01/nvidia/generated/g_os_nvoc.h        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvrm/535.113.01/nvidia/generated/g_os_nvoc.h b/drivers/gpu/drm/nouveau/include/nvrm/535.113.01/nvidia/generated/g_os_nvoc.h
index 754c6af42f30..1d236c68fa30 100644
--- a/drivers/gpu/drm/nouveau/include/nvrm/535.113.01/nvidia/generated/g_os_nvoc.h
+++ b/drivers/gpu/drm/nouveau/include/nvrm/535.113.01/nvidia/generated/g_os_nvoc.h
@@ -38,7 +38,7 @@ typedef struct PACKED_REGISTRY_TABLE
 {
     NvU32                   size;
     NvU32                   numEntries;
-    PACKED_REGISTRY_ENTRY   entries[0];
+    PACKED_REGISTRY_ENTRY   entries[];
 } PACKED_REGISTRY_TABLE;
 
 #endif
-- 
2.34.1


             reply	other threads:[~2023-11-07 23:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 23:47 Timur Tabi [this message]
2023-11-07 23:52 ` [Nouveau] [PATCH] nouveau/gsp: fix UBSAN array bounds warning in PACKED_REGISTRY_TABLE Danilo Krummrich
2023-11-08  0:00   ` Timur Tabi

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=20231107234726.854248-1-ttabi@nvidia.com \
    --to=ttabi@nvidia.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    /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