Skip to content

Commit 8ec05ad

Browse files
committed
Add memory protection to IPC handle
devdax_open_ipc_handle() has to use also the memory protection got from the IPC handle, so let's add the memory protection to the IPC handle. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 659e6c6 commit 8ec05ad

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ static umf_result_t devdax_allocation_merge(void *provider, void *lowPtr,
371371
typedef struct devdax_ipc_data_t {
372372
char path[PATH_MAX]; // path to the /dev/dax
373373
size_t size; // size of the /dev/dax
374+
unsigned protection; // combination of OS-specific memory protection flags
374375
size_t offset; // offset of the data
375376
} devdax_ipc_data_t;
376377

@@ -401,6 +402,7 @@ static umf_result_t devdax_get_ipc_handle(void *provider, const void *ptr,
401402
strncpy(devdax_ipc_data->path, devdax_provider->path, PATH_MAX - 1);
402403
devdax_ipc_data->path[PATH_MAX - 1] = '\0';
403404
devdax_ipc_data->size = devdax_provider->size;
405+
devdax_ipc_data->protection = devdax_provider->protection;
404406

405407
return UMF_RESULT_SUCCESS;
406408
}
@@ -438,8 +440,6 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
438440
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
439441
}
440442

441-
devdax_memory_provider_t *devdax_provider =
442-
(devdax_memory_provider_t *)provider;
443443
devdax_ipc_data_t *devdax_ipc_data = (devdax_ipc_data_t *)providerIpcData;
444444

445445
umf_result_t ret = UMF_RESULT_SUCCESS;
@@ -454,22 +454,22 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
454454

455455
// mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
456456
char *base = utils_mmap_file(NULL, devdax_ipc_data->size,
457-
devdax_provider->protection, map_sync_flag, fd,
457+
devdax_ipc_data->protection, map_sync_flag, fd,
458458
0 /* offset */);
459459
if (base == NULL) {
460460
devdax_store_last_native_error(UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED,
461461
errno);
462462
LOG_PERR("devdax mapping failed (path: %s, size: %zu, protection: %i, "
463463
"fd: %i)",
464464
devdax_ipc_data->path, devdax_ipc_data->size,
465-
devdax_provider->protection, fd);
465+
devdax_ipc_data->protection, fd);
466466
ret = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
467467
}
468468

469469
LOG_DEBUG("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
470470
"offset: %zu)",
471471
devdax_ipc_data->path, devdax_ipc_data->size,
472-
devdax_provider->protection, fd, devdax_ipc_data->offset);
472+
devdax_ipc_data->protection, fd, devdax_ipc_data->offset);
473473

474474
(void)utils_close_fd(fd);
475475

0 commit comments

Comments
 (0)