From c9bd29e124aedc91e623095c5794f545cb8b84a9 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 25 Jan 2017 14:54:46 -0800 Subject: [PATCH] loader: verity-hash.h fixups o Add some comments. o Change image buffer type to (const void *). o Add new macro VERITY_CMDLINE_LENGTH. Signed-off-by: Geoff Levand --- include/grub/verity-hash.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/include/grub/verity-hash.h b/include/grub/verity-hash.h index afbfd14d6..7222d5b87 100644 --- a/include/grub/verity-hash.h +++ b/include/grub/verity-hash.h @@ -1,13 +1,26 @@ +/* CoreOS verity hash */ + #define VERITY_ARG " verity.usrhash=" #define VERITY_ARG_LENGTH (sizeof (VERITY_ARG) - 1) -#define VERITY_HASH_OFFSET 0x40 #define VERITY_HASH_LENGTH 64 +#define VERITY_CMDLINE_LENGTH ((VERITY_ARG_LENGTH)+(VERITY_HASH_LENGTH)) +#define VERITY_HASH_OFFSET 0x40 -static inline void grub_pass_verity_hash(struct linux_kernel_header *lh, + +/** + * grub_pass_verity_hash - Reads the CoreOS verity hash value from a well known + * kernel image offset and adds a kernel command line argument for it. + * + * @pImage: Kernel image buffer. + * @cmdline: Kernel command line buffer. + * @cmdline_max_len: Kernel command line buffer length. + */ + +static inline void grub_pass_verity_hash(const void *pImage, char *cmdline, grub_size_t cmdline_max_len) { - char *buf = (char *)lh; + const char *buf = pImage; grub_size_t cmdline_len; int i; @@ -19,7 +32,7 @@ static inline void grub_pass_verity_hash(struct linux_kernel_header *lh, } cmdline_len = grub_strlen(cmdline); - if (cmdline_len + VERITY_ARG_LENGTH + VERITY_HASH_LENGTH > cmdline_max_len) + if (cmdline_len + VERITY_CMDLINE_LENGTH > cmdline_max_len) return; grub_memcpy (cmdline + cmdline_len, VERITY_ARG, VERITY_ARG_LENGTH);