Skip to content

Commit e3a5fcf

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 e3a5fcf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 5 additions & 3 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
}
@@ -454,22 +456,22 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
454456

455457
// mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
456458
char *base = utils_mmap_file(NULL, devdax_ipc_data->size,
457-
devdax_provider->protection, map_sync_flag, fd,
459+
devdax_ipc_data->protection, map_sync_flag, fd,
458460
0 /* offset */);
459461
if (base == NULL) {
460462
devdax_store_last_native_error(UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED,
461463
errno);
462464
LOG_PERR("devdax mapping failed (path: %s, size: %zu, protection: %i, "
463465
"fd: %i)",
464466
devdax_ipc_data->path, devdax_ipc_data->size,
465-
devdax_provider->protection, fd);
467+
devdax_ipc_data->protection, fd);
466468
ret = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
467469
}
468470

469471
LOG_DEBUG("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
470472
"offset: %zu)",
471473
devdax_ipc_data->path, devdax_ipc_data->size,
472-
devdax_provider->protection, fd, devdax_ipc_data->offset);
474+
devdax_ipc_data->protection, fd, devdax_ipc_data->offset);
473475

474476
(void)utils_close_fd(fd);
475477

0 commit comments

Comments
 (0)