Acidanthera UEFI Development Kit based on EDK II edk2-stable202311
Go to file
jljusten e678f9db89 OvmfPkg/SerializeVariablesLib: ignore secure variable restore errors
OvmfPkg's file-based NvVar storage is read back as follows at boot (all
paths under OvmfPkg/Library/):

PlatformBdsPolicyBehavior() [PlatformBdsLib/BdsPlatform.c]
  PlatformBdsRestoreNvVarsFromHardDisk()
    VisitAllInstancesOfProtocol
      for each simple file system:
        VisitingFileSystemInstance()
          ConnectNvVarsToFileSystem() [NvVarsFileLib/NvVarsFileLib.c]
            LoadNvVarsFromFs() [NvVarsFileLib/FsAccess.c]
              ReadNvVarsFile()
+-------------> SerializeVariablesSetSerializedVariables() [SerializeVariablesLib/SerializeVariablesLib.c]
|                 SerializeVariablesIterateInstanceVariables()
|   +-------------> IterateVariablesInBuffer()
|   |                 for each loaded / deserialized variable:
| +-|-----------------> IterateVariablesCallbackSetSystemVariable()
| | |                     gRT->SetVariable()
| | |
| | IterateVariablesInBuffer() stops processing variables as soon as the
| | first error is encountered from the callback function.
| |
| | In this case the callback function is
| IterateVariablesCallbackSetSystemVariable(), selected by
SerializeVariablesSetSerializedVariables().

The result is that no NvVar is restored from the file after the first
gRT->SetVariable() failure.

On my system such a failure
- never happens in an OVMF build with secure boot disabled,
- happens *immediately* with SECURE_BOOT_ENABLE, because the first
  variable to restore is "AuthVarKeyDatabase".

"AuthVarKeyDatabase" has the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
attribute set. Since the loop tries to restore it before any keys (PK, KEK
etc) are enrolled, gRT->SetVariable() rejects it with
EFI_SECURITY_VIOLATION. Consequently the NvVar restore loop terminates
immediately, and we never reach non-authenticated variables such as
Boot#### and BootOrder.

Until work on KVM-compatible flash emulation converges between qemu and
OvmfPkg, improve the SECURE_BOOT_ENABLE boot experience by masking
EFI_SECURITY_VIOLATION in the callback:
- authenticated variables continue to be rejected same as before, but
- at least we allow the loop to progress and restore non-authenticated
  variables, for example boot options.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14390 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-28 17:21:37 +00:00
AppPkg - For writing sin_port, htons() must be used. 2013-02-08 21:34:26 +00:00
ArmPkg ArmPkg/BdsLinuxFdt.c: Fix creation of 'cpu' and 'psci' device tree nodes. 2013-05-12 23:56:35 +00:00
ArmPlatformPkg EmbeddedPkg/SerialPortExtLib.h: Changed SerialPortSetAttributes() prototype to return the set value(s) 2013-05-15 08:44:59 +00:00
BaseTools Roll back the changes for BaseTools 2012-06-25 02:24:12 +00:00
BeagleBoardPkg ArmPlatform/ArmPlatformLib: Introduced ArmPlatformPeiBootAction() 2013-05-10 12:49:10 +00:00
Conf
CryptoPkg The openssl API RSA_public_decrypt() and RSA_private_encrypt() are deprecated, use RSA_sign(), RSA_verify() instead. 2013-04-23 01:52:17 +00:00
DuetPkg Add missing braces around initializer. 2012-10-11 02:15:23 +00:00
EdkCompatibilityPkg Without this fix, the "%r" format specifier prints eg. "0000001A" instead of "Security Violation" for EFI_SECURITY_VIOLATION. 2013-05-24 02:48:40 +00:00
EdkShellBinPkg New EDK Shell binary(r63). 2013-05-17 07:36:14 +00:00
EdkShellPkg EdkShellPkg: Added new patch to support EFI Shell project revision 61 2012-09-27 15:23:33 +00:00
EmbeddedPkg EmbeddedPkg/SerialPortExtLib.h: Changed SerialPortSetAttributes() prototype to return the set value(s) 2013-05-15 08:44:59 +00:00
EmulatorPkg EmulatorPkg: Add SerialPortExtLib library class mapping 2013-05-15 05:18:49 +00:00
FatBinPkg FatBinPkg: Added ARM Binaries 2012-09-27 15:25:52 +00:00
IntelFrameworkModulePkg Move the memory allocation and variable set to BdsEntry, use VariableLock protocol to lock the L”PerfDataMemAddr” variable and prevent malware to update it. 2013-05-23 02:56:41 +00:00
IntelFrameworkPkg Add ASSERT() for BitField operations to make sure the input value is valid. 2012-12-25 02:29:46 +00:00
MdeModulePkg Refine the logic about processing options for oneof opcode. 2013-05-27 07:04:09 +00:00
MdePkg Without this fix, the "%r" format specifier prints eg. "0000001A" instead of "Security Violation" for EFI_SECURITY_VIOLATION. 2013-05-24 02:48:40 +00:00
NetworkPkg Correct the incorrect Copyright or License in EDKII source files. 2013-05-22 02:19:16 +00:00
Nt32Pkg Change the type of NotifyHandle from EFI_HANDLE to VOID * for SimpleTextInEx protocol. 2012-07-30 03:50:42 +00:00
Omap35xxPkg EmbeddedPkg: Introduced a separate SerialPortExtLib library 2013-03-12 00:40:11 +00:00
OptionRomPkg Update Code to pass EBC compiler. 2013-05-13 02:36:09 +00:00
OvmfPkg OvmfPkg/SerializeVariablesLib: ignore secure variable restore errors 2013-05-28 17:21:37 +00:00
PcAtChipsetPkg Raise TPL to high to disable CPU interrupt before 8259 legacy base vector is changed, then restore TPL level at last when 8259 initialization is done. 2012-10-31 08:58:27 +00:00
PerformancePkg Update Code to pass EBC compiler. 2013-05-13 02:36:09 +00:00
SecurityPkg Fix the TOCTOU issue of CommBufferSize itself for SMM communicate handler input. 2013-05-21 02:22:02 +00:00
ShellBinPkg ShellBinPkg: Added ARM Binaries 2012-09-27 15:28:54 +00:00
ShellPkg Correct the incorrect Copyright or License in EDKII source files. 2013-05-22 02:19:16 +00:00
SourceLevelDebugPkg Updated connecting HOST version information from 1.3 to 1.3.1. 2013-05-08 08:29:11 +00:00
StdLib StdLib/LibC/Locale/multibyte_Utf8.c: Fix obscure corner cases in wide to multibyte and multibyte to wide character conversions. The majority of problems center around the interpretation of the Length or Limit parameter when the Destination parameter is NULL. 2013-05-15 01:59:11 +00:00
StdLibPrivateInternalFiles StdLib: Add internal use only header for interactive I/O. 2012-12-11 21:03:57 +00:00
UefiCpuPkg Fix build issue on DDK3790 tool chain. 2013-02-05 01:35:29 +00:00
UnixPkg UnixPkg: Mark as deprecated (replaced by EmulatorPkg) 2012-10-05 07:05:54 +00:00
BuildNotes2.txt Update EDKII BuildNotes to say the default tool chain tag is VS2008 instead of VS2005 2011-12-14 06:15:48 +00:00
edksetup.bat Added VS2010 support in edksetup script. 2012-04-10 07:45:35 +00:00
edksetup.sh Correct copyright year 2011-02-16 12:21:31 +00:00