[PATCH] D158725: [NFC][AMDGPU] Guard the custom fixups kind array from invalid access

Georgi Mirazchiyski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 04:43:56 PDT 2023


gmirazchiyski created this revision.
Herald added subscribers: foad, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
gmirazchiyski requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Verify the possibility of accidental passing of an invalid MCFixupKind value which can cause an out-of-bounds access in the array.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158725

Files:
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp


Index: llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -185,6 +185,8 @@
   if (Kind < FirstTargetFixupKind)
     return MCAsmBackend::getFixupKindInfo(Kind);
 
+  assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
+         "Invalid kind!");
   return Infos[Kind - FirstTargetFixupKind];
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158725.553076.patch
Type: text/x-patch
Size: 513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/06b64564/attachment.bin>


More information about the llvm-commits mailing list