diff options
author | Daniel Axtens <dja@axtens.net> | 2021-06-23 19:41:54 +1000 |
---|---|---|
committer | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2021-07-20 10:47:16 +0530 |
commit | d722dc185bcf86a28ad8710ccc0b5a02b4ea0fc2 (patch) | |
tree | 9bb65220ed21b18f5f3ea830c4dff9abebc482f2 /libstb | |
parent | 7c4862ebd8de5d13243c6a3dc2bfb9ef7b3ab174 (diff) | |
download | skiboot-d722dc185bcf86a28ad8710ccc0b5a02b4ea0fc2.zip skiboot-d722dc185bcf86a28ad8710ccc0b5a02b4ea0fc2.tar.gz skiboot-d722dc185bcf86a28ad8710ccc0b5a02b4ea0fc2.tar.bz2 |
secvar/backend: use endian-aware types in edk2.h
Recently we had an issue where we did the following:
uint16_t year = le32_to_cpu(timestamp->year);
This is wrong and will break on BE. However, we didn't catch this
with sparse because there was a whole slew of warnings.
The reason for the slew of warnings is that we didn't annotate the
types that store little-endian specific data in edk2.h.
Provide the appropriate annotations.
We now get a single sparse warning for the file, which correctly
identifies the issue:
edk2-compat-process.c:374:46: warning: incorrect type in argument 1 (different base types)
edk2-compat-process.c:374:46: expected restricted leint32_t [usertype] le_val
edk2-compat-process.c:374:46: got restricted leint16_t const [usertype] year
We do lose the signedness of efi_time->timezone, but that's probably OK:
we never use the timezone anyway and the comment above the data structure
makes the signedness pretty clear.
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Diffstat (limited to 'libstb')
-rw-r--r-- | libstb/secvar/backend/edk2.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libstb/secvar/backend/edk2.h b/libstb/secvar/backend/edk2.h index ef6d7c7..d762514 100644 --- a/libstb/secvar/backend/edk2.h +++ b/libstb/secvar/backend/edk2.h @@ -125,15 +125,15 @@ static const uuid_t EFI_CERT_RSA2048_GUID = {{ 0xe8, 0x66, 0x57, 0x3c, 0x9c, 0x2 * TimeZone: -1440 to 1440 or 2047 */ struct efi_time { - u16 year; + le16 year; u8 month; u8 day; u8 hour; u8 minute; u8 second; u8 pad1; - u32 nanosecond; - s16 timezone; + le32 nanosecond; + le16 timezone; u8 daylight; u8 pad2; }; @@ -163,15 +163,15 @@ typedef struct __packed { /// /// Total size of the signature list, including this header. /// - uint32_t SignatureListSize; + leint32_t SignatureListSize; /// /// Size of the signature header which precedes the array of signatures. /// - uint32_t SignatureHeaderSize; + leint32_t SignatureHeaderSize; /// /// Size of each signature. /// - uint32_t SignatureSize; + leint32_t SignatureSize; /// /// Header before the array of signatures. The format of this header is specified /// by the SignatureType. @@ -191,18 +191,18 @@ struct win_certificate { * The length of the entire certificate, including the length of the * header, in bytes. */ - u32 dw_length; + le32 dw_length; /* * The revision level of the WIN_CERTIFICATE structure. The current * revision level is 0x0200. */ - u16 w_revision; + le16 w_revision; /* * The certificate type. See WIN_CERT_TYPE_xxx for the UEFI certificate * types. The UEFI specification reserves the range of certificate type * values from 0x0EF0 to 0x0EFF. */ - u16 w_certificate_type; + le16 w_certificate_type; /* * The following is the actual certificate. The format of * the certificate depends on wCertificateType. |