Fix potential stack corruption in DebugSessionImp

- allocate 64 bytes on stack when accessing registers

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-06-14 17:32:28 +00:00
committed by Compute-Runtime-Automation
parent b5ee204d9c
commit 31ebf37091
3 changed files with 44 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ struct MockDebugSession : public L0::DebugSessionImp {
using L0::DebugSessionImp::generateEventsAndResumeStoppedThreads;
using L0::DebugSessionImp::generateEventsForPendingInterrupts;
using L0::DebugSessionImp::generateEventsForStoppedThreads;
using L0::DebugSessionImp::getRegisterSize;
using L0::DebugSessionImp::getStateSaveAreaHeader;
using L0::DebugSessionImp::markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention;
using L0::DebugSessionImp::newAttentionRaised;
@@ -1717,6 +1718,17 @@ TEST_F(DebugSessionRegistersAccessTest, givenTypeToRegsetDescCalledThenCorrectRe
EXPECT_NE(session->typeToRegsetDesc(ZET_DEBUG_REGSET_TYPE_SBA_INTEL_GPU), nullptr);
}
TEST_F(DebugSessionRegistersAccessTest, givenValidRegisterWhenGettingSizeThenCorrectSizeIsReturned) {
session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
auto pStateSaveAreaHeader = session->getStateSaveAreaHeader();
EXPECT_EQ(pStateSaveAreaHeader->regHeader.grf.bytes, session->getRegisterSize(ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU));
}
TEST_F(DebugSessionRegistersAccessTest, givenInvalidRegisterWhenGettingSizeThenZeroSizeIsReturned) {
session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
EXPECT_EQ(0u, session->getRegisterSize(ZET_DEBUG_REGSET_TYPE_INVALID_INTEL_GPU));
}
TEST_F(DebugSessionRegistersAccessTest, givenUnsupportedRegisterTypeWhenReadRegistersCalledThenErrorInvalidArgumentIsReturned) {
session->areRequestedThreadsStoppedReturnValue = 1;
session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);