Fix stack-buffer-overflow sanitizer issue in AUIPC_JALR_TO_XQCI.test#922
Fix stack-buffer-overflow sanitizer issue in AUIPC_JALR_TO_XQCI.test#922parth-07 wants to merge 1 commit intoqualcomm:release/22.xfrom
Conversation
This commit fixes stack-buffer-overflow sanitizer issue in AUIPIC_JALR_TO_XQCI.test. The root cause was that the QC_E_J relaxation patch 6 bytes instruction but the 'Instr' parameter of 'RegionFragmentEx::replaceInstruction' that stores the updated instruction is only of 4 bytes. Signed-off-by: Parth Arora <partaror@qti.qualcomm.com>
| static bool classof(const RegionFragmentEx *) { return true; } | ||
|
|
||
| bool replaceInstruction(uint32_t Offset, Relocation *Reloc, uint32_t Instr, | ||
| bool replaceInstruction(uint32_t Offset, Relocation *Reloc, uint64_t Instr, |
There was a problem hiding this comment.
templatized function might be better
There was a problem hiding this comment.
Given this is just doing a memcpy, maybe we can just expose Instr as const char * to avoid templating or issues with sizing, and pass &Instr everywhere we're calling it?
There was a problem hiding this comment.
@quic-seaswara I like @lenary's suggestion. Please let me know your thoughts on it.
There was a problem hiding this comment.
sounds good!, const uint8_t *
There was a problem hiding this comment.
Technically a const uint8_t * isn't the same as a const char * in terms of strict aliasing, BUT you use the former so much in the codebase I'm not going to complain if you keep using it in this interface too.
There was a problem hiding this comment.
I agree, we should be consistent, for now const char * is ok, but we should clean it up when dealing with ELF data as const uint8_t * as much as possible
This commit fixes stack-buffer-overflow sanitizer issue in AUIPIC_JALR_TO_XQCI.test. The root cause was that the QC_E_J relaxation patch 6 bytes instruction but the 'Instr' parameter of 'RegionFragmentEx::replaceInstruction' that stores the updated instruction is only of 4 bytes.