Skip to content

Commit f365d3c

Browse files
committed
add overflow checks for IPC handle size
1 parent 3270fa6 commit f365d3c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/ipc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023-2025 Intel Corporation
3+
* Copyright (C) 2023-2026 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -45,6 +45,11 @@ umf_result_t umfPoolGetIPCHandleSize(umf_memory_pool_handle_t hPool,
4545
return ret;
4646
}
4747

48+
if (providerIPCHandleSize > SIZE_MAX - sizeof(umf_ipc_data_t)) {
49+
LOG_ERR("IPC handle size is too large.");
50+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
51+
}
52+
4853
*size = sizeof(umf_ipc_data_t) + providerIPCHandleSize;
4954

5055
return ret;

src/provider/provider_tracking.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023-2025 Intel Corporation
3+
* Copyright (C) 2023-2026 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -1108,6 +1108,11 @@ static umf_result_t trackingGetIpcHandle(void *provider, const void *ptr,
11081108
return ret;
11091109
}
11101110

1111+
if (ipcDataSize > SIZE_MAX - sizeof(ipc_cache_value_t)) {
1112+
LOG_ERR("upstream provider IPC handle size is too large");
1113+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
1114+
}
1115+
11111116
size_t value_size = sizeof(ipc_cache_value_t) + ipcDataSize;
11121117
cache_value = umf_ba_global_alloc(value_size);
11131118
if (!cache_value) {

0 commit comments

Comments
 (0)