diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fedc8a..d4b71bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [6.2.3] + +### Fixed + - Linux: pick libmei 1.8.3 - empty kind fix + - Linux: return NOT_SUPPORTED on ENODATA + - Linux: use the right side of cancel pipe + - EFI: error out on wrong type + - EFI: add missed status to prints + - Windows: limit buffer size + +### Removed + - drop conan support + ## [6.2.2] ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c40745e..d6ec017 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,6 @@ Details for each point and good commit message examples can be found on https:// - CMake: changes in the cmake build configuration. - tests: changes in tests. - samples: changes in samples. - - conan: changes in conan configuration. - doc: changes in documentation. ### Sign your work diff --git a/VERSION b/VERSION index ca06394..bee9433 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.2.2 +6.2.3 diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 09cb002..0000000 --- a/conanfile.py +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2020-2023 Intel Corporation -from conans import ConanFile, CMake, tools -from conans.tools import load -from conans.model.version import Version -import os - -class MeteeConan(ConanFile): - name = "metee" - license = "SPDX-License-Identifier: Apache-2.0" - url = "https://github.com/intel/metee" - description = "Cross-platform access library for Intel(R) CSME HECI interface." - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False]} - default_options = {"shared": False} - generators = "cmake", "visual_studio" - exports_sources = "*" - - def configure(self): - del self.settings.compiler.libcxx - - def package_id(self): - v = Version(str(self.settings.compiler.version)) - if self.settings.compiler == "gcc" and (v >= "6" and v <= "12"): - self.info.settings.compiler.version = "GCC version between 6 and 12" - if self.settings.compiler == "clang" and (v >= "6" and v <= "15"): - self.info.settings.compiler.version = "clang version between 6 and 15" - - def set_version(self): - content = load(os.path.join(self.recipe_folder, "VERSION")) - self.version = content - - def _configure_cmake(self): - cmake = CMake(self) - if self.settings.os == "Windows" and "MT" in self.settings.compiler.runtime: - cmake.definitions["BUILD_MSVC_RUNTIME_STATIC"]="on" - cmake.configure(source_folder="") - return cmake - - def build(self): - cmake = self._configure_cmake() - cmake.build() - - def package(self): - cmake = self._configure_cmake() - cmake.install() - - def package_info(self): - self.cpp_info.components["libmetee"].libs = ["metee"] diff --git a/src/Windows/metee_win.c b/src/Windows/metee_win.c index ead5a9f..1f7ca74 100644 --- a/src/Windows/metee_win.c +++ b/src/Windows/metee_win.c @@ -362,7 +362,7 @@ TEESTATUS TEEAPI TeeRead(IN PTEEHANDLE handle, IN OUT void* buffer, IN size_t bu goto Cleanup; } - status = BeginOverlappedInternal(ReadOperation, handle, buffer, (ULONG)bufferSize, impl_handle->evt[METEE_WIN_EVT_READ]); + status = BeginOverlappedInternal(ReadOperation, handle, buffer, bufferSize, impl_handle->evt[METEE_WIN_EVT_READ]); if (status) { ERRPRINT(handle, "Error in BeginOverlappedInternal, error: %d\n", status); impl_handle->state = METEE_CLIENT_STATE_FAILED; @@ -422,7 +422,7 @@ TEESTATUS TEEAPI TeeWrite(IN PTEEHANDLE handle, IN const void* buffer, IN size_t goto Cleanup; } - status = BeginOverlappedInternal(WriteOperation, handle, (PVOID)buffer, (ULONG)bufferSize, impl_handle->evt[METEE_WIN_EVT_WRITE]); + status = BeginOverlappedInternal(WriteOperation, handle, (PVOID)buffer, bufferSize, impl_handle->evt[METEE_WIN_EVT_WRITE]); if (status) { ERRPRINT(handle, "Error in BeginOverlappedInternal, error: %d\n", status); impl_handle->state = METEE_CLIENT_STATE_FAILED; diff --git a/src/Windows/metee_win.h b/src/Windows/metee_win.h index 9310613..907d4e1 100644 --- a/src/Windows/metee_win.h +++ b/src/Windows/metee_win.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2014-2025 Intel Corporation + * Copyright (C) 2014-2026 Intel Corporation */ #ifndef __TEELIBWIN_H #define __TEELIBWIN_H @@ -49,7 +49,7 @@ typedef enum _TEE_OPERATION **********************************************************************/ TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation, IN PTEEHANDLE handle, IN PVOID buffer, - IN ULONG bufferSize, OUT EVENTHANDLE evt); + IN size_t bufferSize, OUT EVENTHANDLE evt); TEESTATUS EndOverlapped(IN PTEEHANDLE handle, IN EVENTHANDLE evt, IN DWORD milliseconds, OUT OPTIONAL LPDWORD pNumberOfBytesTransferred); TEESTATUS GetDevicePath(IN PTEEHANDLE handle, IN LPCGUID InterfaceGuid, diff --git a/src/Windows/metee_winhelpers.c b/src/Windows/metee_winhelpers.c index 503a256..628e0b3 100644 --- a/src/Windows/metee_winhelpers.c +++ b/src/Windows/metee_winhelpers.c @@ -46,7 +46,7 @@ void CallbackPrintHelper(IN PTEEHANDLE handle, bool is_error, const char* args, ** TEE_INTERNAL_ERROR */ TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation, IN PTEEHANDLE handle, - IN PVOID buffer, IN ULONG bufferSize, OUT EVENTHANDLE evt) + IN PVOID buffer, IN size_t bufferSize, OUT EVENTHANDLE evt) { TEESTATUS status; DWORD bytesTransferred= 0; @@ -61,13 +61,19 @@ TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation, IN PTEEHANDLE hand goto Cleanup; } + if (bufferSize > MAXDWORD) { + status = TEE_INVALID_PARAMETER; + ERRPRINT(handle, "Buffer size is too big: %zu\n", bufferSize); + goto Cleanup; + } + if (operation == ReadOperation) { - if (ReadFile(impl_handle->handle, buffer, bufferSize, &bytesTransferred, evt)) { + if (ReadFile(impl_handle->handle, buffer, (DWORD)bufferSize, &bytesTransferred, evt)) { optSuccesed = TRUE; } } else if (operation == WriteOperation) { - if (WriteFile(impl_handle->handle, buffer, bufferSize, &bytesTransferred, evt)) { + if (WriteFile(impl_handle->handle, buffer, (DWORD)bufferSize, &bytesTransferred, evt)) { optSuccesed = TRUE; } } diff --git a/src/linux/mei.c b/src/linux/mei.c index 6b52191..16a69fe 100644 --- a/src/linux/mei.c +++ b/src/linux/mei.c @@ -376,6 +376,12 @@ static inline int __mei_getkind(struct mei *me, const char *device, char *kind, return -me->last_err; } + if (len == 0) { + me->last_err = ENODATA; + close(fd); + return -me->last_err; + } + close(fd); if ((size_t)len > *kind_size || !kind) { me->last_err = ENOSPC; diff --git a/src/linux/metee_linux.c b/src/linux/metee_linux.c index 6720d92..0e4bc0f 100644 --- a/src/linux/metee_linux.c +++ b/src/linux/metee_linux.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2014-2025 Intel Corporation + * Copyright (C) 2014-2026 Intel Corporation */ #include #include @@ -73,6 +73,7 @@ static inline TEESTATUS errno2status(ssize_t err) case -ETIME : return TEE_TIMEOUT; case -EACCES: return TEE_PERMISSION_DENIED; case -EOPNOTSUPP: return TEE_NOTSUPPORTED; + case -ENODATA: return TEE_NOTSUPPORTED; case -ECANCELED: return TEE_UNABLE_TO_COMPLETE_OPERATION; case -ENOSPC: return TEE_INSUFFICIENT_BUFFER; default : return TEE_INTERNAL_ERROR; @@ -327,7 +328,7 @@ TEESTATUS TEEAPI TeeRead(IN PTEEHANDLE handle, IN OUT void *buffer, IN size_t bu ltimeout = (timeout) ? (int)timeout : -1; - rc = __mei_select(me, intl->cancel_pipe[1], true, ltimeout); + rc = __mei_select(me, intl->cancel_pipe[0], true, ltimeout); if (rc) { status = errno2status(rc); ERRPRINT(handle, "select failed with status %zd %s\n", @@ -390,7 +391,7 @@ TEESTATUS TEEAPI TeeWrite(IN PTEEHANDLE handle, IN const void *buffer, IN size_t ltimeout = (timeout) ? (int)timeout : -1; - rc = __mei_select(me, intl->cancel_pipe[1], false, ltimeout); + rc = __mei_select(me, intl->cancel_pipe[0], false, ltimeout); if (rc) { status = errno2status(rc); ERRPRINT(handle, "select failed with status %zd %s\n", @@ -724,4 +725,4 @@ TEESTATUS TEEAPI TeeGetKind(IN PTEEHANDLE handle, IN OUT char *kind, IN OUT size End: FUNC_EXIT(handle, status); return status; -} \ No newline at end of file +} diff --git a/src/uefi/heci_efi.c b/src/uefi/heci_efi.c index cb1b5aa..f95d418 100644 --- a/src/uefi/heci_efi.c +++ b/src/uefi/heci_efi.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2024-2025 Intel Corporation + * Copyright (C) 2024-2026 Intel Corporation */ #include @@ -318,13 +318,13 @@ EfiTeeHeciUninitialize( status = heciSendMsg(Handle, (UINT32 *)&disconnectMsg, (UINT32)sizeof(disconnectMsg), (UINT8)BIOS_FIXED_HOST_ADDR, (UINT8)HECI_HBM_MSG_ADDR); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "####Failed to send HBM_CLIENT_DISCONNECT_REQUEST. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "####Failed to send HBM_CLIENT_DISCONNECT_REQUEST. Status: %llu\n", (unsigned long long)status); goto End; } status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&disconnectMsgReply, sizeof(disconnectMsgReply), &msgReplyLen); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "####Failed with ReadMsg, Status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "####Failed with ReadMsg, Status: %llu.\n", (unsigned long long)status); goto End; } DBGPRINT(Handle->TeeHandle, "#### disconnectMsgReply Command %02X , Status: %02X.\n", disconnectMsgReply.Command, disconnectMsgReply.Status); @@ -382,7 +382,7 @@ heciFwToHostFlowControl( status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&flowCtrlMsg, sizeof(HBM_FLOW_CONTROL), &msgLen); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "#####Flow control: wait for FW failed with status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "#####Flow control: wait for FW failed with status: %llu.\n", (unsigned long long)status); goto End; } @@ -427,7 +427,7 @@ heciHostToSecFlowControl( status = heciSendMsg(Handle, (UINT32 *)&flowCtrlMsg, sizeof(flowCtrlMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "#####Flow control: send to FW failed with status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "#####Flow control: send to FW failed with status: %llu.\n", (unsigned long long)status); goto End; } @@ -464,7 +464,7 @@ HeciDeviceEnumerateClients( status = heciReset(Handle); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Failed to send HECI reset. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "Failed to send HECI reset. Status: %llu\n", (unsigned long long)status); status = EFI_DEVICE_ERROR; goto End; } @@ -488,7 +488,7 @@ HeciDeviceEnumerateClients( status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&enumMsgReply, sizeof(HBM_HOST_ENUMERATION_RESPONSE), &msgReplyLen); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %llu\n", (unsigned long long)status); if (EFI_TIMEOUT == status) { continue; @@ -501,7 +501,7 @@ HeciDeviceEnumerateClients( if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %llu.\n", (unsigned long long)status); goto End; } DBGPRINT(Handle->TeeHandle, "HBM_HOST_ENUMERATION_RESPONSE: [Command: %d]\n", enumMsgReply.Command); @@ -530,7 +530,7 @@ HeciDeviceEnumerateClients( status = heciSendMsg(Handle, (UINT32 *)&propMsg, sizeof(propMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Failed to send HBM_CLIENT_PROP_MSG. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "Failed to send HBM_CLIENT_PROP_MSG. Status: %llu\n", (unsigned long long)status); goto End; } @@ -538,7 +538,7 @@ HeciDeviceEnumerateClients( status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&propMsgReply, sizeof(HBM_CLIENT_PROP_MSG_REPLY), &msgReplyLen); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "heciReadMsg failed to read HBM_CLIENT_PROP_MSG response. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "heciReadMsg failed to read HBM_CLIENT_PROP_MSG response. Status: %llu\n", (unsigned long long)status); goto End; } @@ -620,7 +620,7 @@ EfiTeeHeciConnectClient( status = HeciDeviceEnumerateClients(Handle, lib); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Could not HeciDeviceEnumerateClients, Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "Could not HeciDeviceEnumerateClients, Status: %llu\n", (unsigned long long)status); status = EFI_DEVICE_ERROR; goto End; } @@ -664,7 +664,7 @@ EfiTeeHeciConnectClient( } if (host_client_id == TEE_MAX_FW_CLIENTS) { - DBGPRINT(Handle->TeeHandle, "Max client count reached\n", status); + DBGPRINT(Handle->TeeHandle, "Max client count reached\n"); status = EFI_DEVICE_ERROR; goto End; } @@ -690,14 +690,14 @@ EfiTeeHeciConnectClient( status = heciSendMsg(Handle, (UINT32 *)&connectMsg, sizeof(connectMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Connect Send failed with status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "Connect Send failed with status: %llu.\n", (unsigned long long)status); goto End; } status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&connectMsgReply, sizeof(HBM_CLIENT_CONNECT_RESPONSE), &msgReplyLen); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Connect Recv failed with status: %d.\n", status); + DBGPRINT(Handle->TeeHandle, "Connect Recv failed with status: %llu.\n", (unsigned long long)status); goto End; } @@ -799,7 +799,7 @@ EfiTeeHeciSendMessage( status = heciHostToSecFlowControl(Handle, client, fwAddress); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "heciHostToSecFlowControl Failed. Status: %d", status); + DBGPRINT(Handle->TeeHandle, "heciHostToSecFlowControl Failed. Status: %llu", (unsigned long long)status); goto End; } @@ -811,7 +811,7 @@ EfiTeeHeciSendMessage( status = heciSendMsg(Handle, (UINT32 *)buffer, bufferLength, hostAddress, fwAddress); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "SendMessage: failed to send message. Status: %d.", status); + DBGPRINT(Handle->TeeHandle, "SendMessage: failed to send message. Status: %llu.", (unsigned long long)status); goto End; } *BytesWritten = bufferLength; @@ -882,7 +882,8 @@ EfiTeeHeciReceiveMessage( status = heciReadMsg(Handle, BLOCKING, (UINT32 *)Buffer, BufferSize, &bytes_read); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "\nReadMsg: first reply read failed. bytesRead: %d. Status: %d\n", bytes_read, status); + DBGPRINT(Handle->TeeHandle, "\nReadMsg: first reply read failed. bytesRead: %d. Status: %llu\n", + bytes_read, (unsigned long long)status); goto End; } @@ -899,7 +900,7 @@ EfiTeeHeciReceiveMessage( status = heciReadMsg(Handle, BLOCKING, (UINT32 *)Buffer, BufferSize, &bytes_read); if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "heciReadMsg. Status: %d\n"); + DBGPRINT(Handle->TeeHandle, "heciReadMsg. Status: %llu\n", (unsigned long long)status); if (EFI_TIMEOUT == status) { DBGPRINT(Handle->TeeHandle, "Detected EFI_TIMEOUT.\n"); @@ -911,7 +912,7 @@ EfiTeeHeciReceiveMessage( if (EFI_ERROR(status)) { - DBGPRINT(Handle->TeeHandle, "Retry failed. Status: %d\n", status); + DBGPRINT(Handle->TeeHandle, "Retry failed. Status: %llu\n", (unsigned long long)status); goto End; } } @@ -930,7 +931,7 @@ EfiTeeHeciReceiveMessage( { EFIPRINT(Handle->TeeHandle, "FixedAddress: %d\n", client->properties.FixedAddress); status = heciFwToHostFlowControl(Handle, client); - DBGPRINT(Handle->TeeHandle, "heciFwToHostFlowControl. Status: %d\n"); + DBGPRINT(Handle->TeeHandle, "heciFwToHostFlowControl. Status: %llu\n", (unsigned long long)status); goto End; } diff --git a/src/uefi/metee_efi.c b/src/uefi/metee_efi.c index 0b9b783..93eb7b7 100644 --- a/src/uefi/metee_efi.c +++ b/src/uefi/metee_efi.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2024-2025 Intel Corporation + * Copyright (C) 2024-2026 Intel Corporation */ #ifdef METEE_EFI_STDLIB_SUPPORT @@ -137,7 +137,7 @@ SetHwInfo( status = TEE_SUCCESS; End: FUNC_EXIT(Handle->TeeHandle, status); - return 0; + return status; } /*! Initializes TEE_DEVICE_TYPE_BDF connection specific properties @@ -171,7 +171,12 @@ TeeInitFullTypeEfiDevice( efi_impl->ClientGuid = *guid; efi_impl->State = METEE_CLIENT_STATE_NONE; efi_impl->HwType = device->data.bdf.hw_type; - SetHwInfo(device, efi_impl); + status = SetHwInfo(device, efi_impl); + if (status != TEE_SUCCESS) + { + FreePool(efi_impl); + goto Cleanup; + } *impl_handle = efi_impl; status = TEE_SUCCESS;