-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read the verity hash from the kernel binary and pass it to the running system via the kernel command line
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#define VERITY_ARG " verity.usrhash=" | ||
#define VERITY_HASH_OFFSET 0x40 | ||
#define VERITY_HASH_LENGTH 64 | ||
|
||
static inline void grub_pass_verity_hash(struct linux_kernel_header *lh, | ||
char *cmdline) | ||
{ | ||
char *buf = (char *)lh; | ||
grub_size_t cmdline_len; | ||
int i; | ||
|
||
for (i=VERITY_HASH_OFFSET; i<VERITY_HASH_OFFSET + VERITY_HASH_LENGTH; i++) | ||
{ | ||
if (buf[i] < '0' || buf[i] > '9') // Not a number | ||
if (buf[i] < 'a' || buf[i] > 'f') // Not a hex letter | ||
return; | ||
} | ||
|
||
grub_memcpy (cmdline + grub_strlen(cmdline), VERITY_ARG, | ||
sizeof (VERITY_ARG)); | ||
cmdline_len = grub_strlen(cmdline); | ||
grub_memcpy (cmdline + cmdline_len, buf + VERITY_HASH_OFFSET, | ||
VERITY_HASH_LENGTH); | ||
cmdline[cmdline_len + VERITY_HASH_LENGTH] = '\0'; | ||
} |