Mesa (main): mesa: fix misaligned pointer returned by dlist_alloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Feb 6 00:16:38 UTC 2022


Module: Mesa
Branch: main
Commit: 945a1e0b8cd57403c6a0cbf9b2fec112f233075e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=945a1e0b8cd57403c6a0cbf9b2fec112f233075e

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>

---

 src/mesa/main/dlist.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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