[client/host] added enforcement of KVMFR versioning

This commit is contained in:
Geoffrey McRae 2020-05-17 11:13:08 +10:00
parent dcce288a98
commit c4bf992c0c
5 changed files with 34 additions and 4 deletions

View File

@ -1 +1 @@
B1-187-gcfd8126e5d+1
B1-188-gdcce288a98+1

View File

@ -413,8 +413,14 @@ int app_main(int argc, char * argv[])
DEBUG_INFO("IVSHMEM Address : 0x%" PRIXPTR, (uintptr_t)shmDev.mem);
DEBUG_INFO("Max Pointer Size : %u KiB", (unsigned int)MAX_POINTER_SIZE / 1024);
KVMFR udata = {
.magic = KVMFR_MAGIC,
.version = KVMFR_VERSION
};
LGMP_STATUS status;
if ((status = lgmpHostInit(shmDev.mem, shmDev.size, &app.lgmp)) != LGMP_OK)
if ((status = lgmpHostInit(shmDev.mem, shmDev.size, &app.lgmp,
sizeof(udata), (uint8_t *)&udata)) != LGMP_OK)
{
DEBUG_ERROR("lgmpHostInit Failed: %s", lgmpStatusString(status));
goto fail;

View File

@ -1446,7 +1446,11 @@ static int lg_run()
LGMP_STATUS status;
while(true)
{
if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp)) == LGMP_OK)
uint32_t udataSize;
KVMFR *udata;
if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp,
&udataSize, (uint8_t **)&udata)) == LGMP_OK)
break;
if (status == LGMP_ERR_INVALID_SESSION || status == LGMP_ERR_INVALID_MAGIC)
@ -1455,6 +1459,16 @@ static int lg_run()
continue;
}
if (udataSize != sizeof(KVMFR) ||
memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) != 0 ||
udata->version != KVMFR_VERSION)
{
DEBUG_ERROR("The host application is not compatible with this client");
DEBUG_ERROR("Expected KVMFR version %d\n", KVMFR_VERSION);
DEBUG_ERROR("This is not a Looking Glass error, do not report this");
return -1;
}
DEBUG_ERROR("lgmpClientInit Failed: %s", lgmpStatusString(status));
return -1;
}

View File

@ -50,6 +50,16 @@ typedef enum CursorType
}
CursorType;
#define KVMFR_MAGIC "KVMFR---"
#define KVMFR_VERSION 1
typedef struct KVMFR
{
char magic[8];
uint32_t version;
}
KVMFR;
typedef struct KVMFRCursor
{
int16_t x, y; // cursor x & y position

@ -1 +1 @@
Subproject commit 1d412a1cf572a341d0d0c9c2714f1107d5376647
Subproject commit 61c9178c87df46f39a817e63eb85afe2a131e51d