sbvarsign: fix "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" assignment
According to UEFI-2.8, section 8.3 "Time Services" / GetTime(), the
"EFI_TIME.Year" field must be in the range [1900, 9999] (both bounds
inclusive). It is not stated or even implied that "EFI_TIME.Year" would
not be an absolute year number.
According to POSIX, the "tm_year" field of "struct tm" is defined as
"Years since 1900". In other words, "tm_year" is relative to 1900.
In set_timestamp(), time() and gmtime() are suitable for populating
"EFI_VARIABLE_AUTHENTICATION_2.TimeStamp", as the UEFI spec specifically
requires a stamp expressed in the GMT (UTC) zone. But we still need to
offset "tm->tm_year" by 1900 for filling in "timestamp->Year". So let's do
that now.
While this issue does not seem to affect upstream edk2, SetVariable()
calls with payloads containing an invalid
"EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" value do seem to be
rejected at least on some Dell Inspiron machines (using a UEFI
implementation from AMI).
Reported-by: Eugene Khoruzhenko <ekhoruzhenko@absolute.com>
Reported-by: Paulo Henrique Lacerda de Amorim <phlamorim@riseup.net>
Ref: https://edk2.groups.io/g/devel/message/49402
Fixes: 953b00481f
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
parent
0dc3d4b521
commit
2ed8eebcc5
1 changed files with 1 additions and 1 deletions
|
@ -212,7 +212,7 @@ static int set_timestamp(EFI_TIME *timestamp)
|
||||||
/* copy to our EFI-specific time structure. Other fields (Nanosecond,
|
/* copy to our EFI-specific time structure. Other fields (Nanosecond,
|
||||||
* TimeZone, Daylight and Pad) are defined to be zero */
|
* TimeZone, Daylight and Pad) are defined to be zero */
|
||||||
memset(timestamp, 0, sizeof(*timestamp));
|
memset(timestamp, 0, sizeof(*timestamp));
|
||||||
timestamp->Year = tm->tm_year;
|
timestamp->Year = 1900 + tm->tm_year;
|
||||||
timestamp->Month = tm->tm_mon;
|
timestamp->Month = tm->tm_mon;
|
||||||
timestamp->Day = tm->tm_mday;
|
timestamp->Day = tm->tm_mday;
|
||||||
timestamp->Hour = tm->tm_hour;
|
timestamp->Hour = tm->tm_hour;
|
||||||
|
|
Loading…
Reference in a new issue