summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2021-01-07 10:50:51 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-01-07 14:13:44 +0000
commite9c5ff3d2730433ff9ffadf6eb2ab1f47708bc18 (patch)
tree051d8fea9b4442db20cf60522c73899182dd37e3 /OvmfPkg/VirtioFsDxe
parentd8d1f6661d672c0a01bc46e67a29d8714db9dcb2 (diff)
downloadedk2-e9c5ff3d2730433ff9ffadf6eb2ab1f47708bc18.tar.gz
edk2-e9c5ff3d2730433ff9ffadf6eb2ab1f47708bc18.tar.bz2
edk2-e9c5ff3d2730433ff9ffadf6eb2ab1f47708bc18.zip
OvmfPkg/VirtioFsDxe: call IsTimeValid() before EfiTimeToEpoch()
EmbeddedPkg/TimeBaseLib provides a verification function called IsTimeValid(), for enforcing the UEFI spec requirements on an EFI_TIME object. When EFI_FILE_PROTOCOL.SetInfo() is called in order to update the timestamps on the file, let's invoke IsTimeValid() first, before passing the new EFI_FILE_INFO.{CreateTime,LastAccessTime,ModificationTime} values to EfiTimeToEpoch(). This patch is not expected to make a practical difference, but it's better to ascertain the preconditions of EfiTimeToEpoch() on the EFI_FILE_PROTOCOL.SetInfo() caller. The FAT driver (EnhancedFatDxe) has a similar check, namely in FatSetFileInfo() -> FatIsValidTime(). Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20210107095051.22715-1-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe')
-rw-r--r--OvmfPkg/VirtioFsDxe/Helpers.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/OvmfPkg/VirtioFsDxe/Helpers.c b/OvmfPkg/VirtioFsDxe/Helpers.c
index 443bbdc616..b81c04e0a4 100644
--- a/OvmfPkg/VirtioFsDxe/Helpers.c
+++ b/OvmfPkg/VirtioFsDxe/Helpers.c
@@ -2244,12 +2244,19 @@ VirtioFsGetFuseSizeUpdate (
since the Epoch). Otherwise, Mtime is not written
to.
- @retval EFI_SUCCESS Output parameters have been set successfully.
-
- @retval EFI_ACCESS_DENIED NewInfo requests changing both CreateTime and
- ModificationTime, but to values that differ from
- each other. The Virtio Filesystem device does not
- support this.
+ @retval EFI_SUCCESS Output parameters have been set successfully.
+
+ @retval EFI_INVALID_PARAMETER At least one of the CreateTime, LastAccessTime
+ and ModificationTime fields in NewInfo
+ represents an actual update relative to the
+ current state of the file (expressed in Info),
+ but does not satisfy the UEFI spec
+ requirements on EFI_TIME.
+
+ @retval EFI_ACCESS_DENIED NewInfo requests changing both CreateTime and
+ ModificationTime, but to values that differ
+ from each other. The Virtio Filesystem device
+ does not support this.
**/
EFI_STATUS
VirtioFsGetFuseTimeUpdates (
@@ -2285,6 +2292,9 @@ VirtioFsGetFuseTimeUpdates (
CompareMem (NewTime[Idx], Time[Idx], sizeof (EFI_TIME)) == 0) {
Change[Idx] = FALSE;
} else {
+ if (!IsTimeValid (NewTime[Idx])) {
+ return EFI_INVALID_PARAMETER;
+ }
Change[Idx] = TRUE;
Seconds[Idx] = EfiTimeToEpoch (NewTime[Idx]);
}