提交 4d8b7aa8 编写于 作者: P PMheart

ocvalidate: Only known first byte can be set to ProcessorType.

上级 db90ad3d
......@@ -81,6 +81,7 @@ Utility to validate whether a `config.plist` matches requirements and convention
#### Generic
- SystemProductName: Only real Mac models are accepted.
- SystemMemoryStatus: Only `Auto`, `Upgradable`, or `Soldered` are accepted.
- ProcessorType: Only known first byte can be set.
### UEFI
#### APFS
......
......@@ -17,6 +17,47 @@
#include "OcValidateLib.h"
#include <Library/OcMacInfoLib.h>
#include <IndustryStandard/AppleSmBios.h>
STATIC
BOOLEAN
ValidateProcessorType (
IN UINT16 ProcessorType
)
{
UINTN Index;
UINT8 AllowedProcessorType[] = {
AppleProcessorMajorCore,
AppleProcessorMajorCore2,
AppleProcessorMajorXeonPenryn,
AppleProcessorMajorXeonNehalem,
AppleProcessorMajorI5,
AppleProcessorMajorI7,
AppleProcessorMajorI3,
AppleProcessorMajorI9,
AppleProcessorMajorXeonE5,
AppleProcessorMajorM,
AppleProcessorMajorM3,
AppleProcessorMajorM5,
AppleProcessorMajorM7,
AppleProcessorMajorXeonW
};
//
// 0 is allowed.
//
if (ProcessorType == 0U) {
return TRUE;
}
for (Index = 0; Index < ARRAY_SIZE (AllowedProcessorType); ++Index) {
if ((ProcessorType >> 8U) == AllowedProcessorType[Index]) {
return TRUE;
}
}
return FALSE;
}
//
// NOTE: Only PlatformInfo->Generic is checked here. The rest is ignored.
......@@ -33,6 +74,7 @@ CheckPlatformInfoGeneric (
CONST CHAR8 *SystemProductName;
CONST CHAR8 *SystemMemoryStatus;
CONST CHAR8 *AsciiSystemUUID;
UINT16 ProcessorType;
ErrorCount = 0;
UserPlatformInfo = &Config->PlatformInfo;
......@@ -57,6 +99,12 @@ CheckPlatformInfoGeneric (
++ErrorCount;
}
ProcessorType = UserPlatformInfo->Generic.ProcessorType;
if (!ValidateProcessorType (ProcessorType)) {
DEBUG ((DEBUG_WARN, "PlatformInfo->Generic->ProcessorType is borked!\n"));
++ErrorCount;
}
//
// TODO: Sanitise MLB, ProcessorType, and SystemSerialNumber if possible...
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册