Mesa (staging/22.0): mesa: fix misaligned pointer returned by dlist_alloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 8 05:53:11 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 5ff5f3cbf79ac40d49605a93304e8ed01d5001e4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ff5f3cbf79ac40d49605a93304e8ed01d5001e4

Author: Charmaine Lee <charmainel at vmware.com>
Date:   Wed Feb  2 15:12:12 2022 -0800

mesa: fix misaligned pointer returned by dlist_alloc

In cases where the to-be-allocated node size with padding exceeds BLOCK_SIZE
but without padding doesn't, a new block is not created and no padding is done
to the previous instruction, causing a misaligned pointer to be returned.

v2: Per Ilia Mirkin's suggestion, remove the extra condition in the first
    if statement, let it unconditionally pad the last instruction if needed.
    The updated currentPos will then be taken into account in the
    block size checking.

This fixes crash seen with lightsmark and Optuma apitraces

Fixes:  05605d7f537c4 (' mesa: remove display list OPCODE_NOP')

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Neha Bhende <bhenden at vmware.com>
Tested-by: Neha Bhende <bhenden at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14871>
(cherry picked from commit 945a1e0b8cd57403c6a0cbf9b2fec112f233075e)

---

 .pick_status.json     | 2 +-
 src/mesa/main/dlist.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 845df6e1571..b46b6c5ad18 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -301,7 +301,7 @@
         "description": "mesa: fix misaligned pointer returned by dlist_alloc",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "05605d7f537c4463cc5471f26fb2226a065561a8"
     },
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index fcf6b2e7588..64070b68d0d 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1506,8 +1506,7 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8)
 
    /* If this node needs to start on an 8-byte boundary, pad the last node. */
    if (sizeof(void *) == 8 && align8 &&
-       ctx->ListState.CurrentPos % 2 == 1 &&
-       ctx->ListState.CurrentPos + 1 + numNodes + contNodes <= BLOCK_SIZE) {
+       ctx->ListState.CurrentPos % 2 == 1) {
       Node *last = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos -
                    ctx->ListState.LastInstSize;
       last->InstSize++;



More information about the mesa-commit mailing list