summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharmaine Lee <charmainel@vmware.com>2022-02-02 15:12:12 -0800
committerDylan Baker <dylan.c.baker@intel.com>2022-02-07 21:36:05 -0800
commit5ff5f3cbf79ac40d49605a93304e8ed01d5001e4 (patch)
tree4f14062d0907f38ed21bce032888bafbaf84a353
parent5a7a564d7c4bbc33f863f3653c8eb8b35b25f486 (diff)
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@alum.mit.edu> Reviewed-by: Neha Bhende <bhenden@vmware.com> Tested-by: Neha Bhende <bhenden@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14871> (cherry picked from commit 945a1e0b8cd57403c6a0cbf9b2fec112f233075e)
-rw-r--r--.pick_status.json2
-rw-r--r--src/mesa/main/dlist.c3
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++;