-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dm-verity parser from kernel command line #217
Conversation
We will use this message to parse the command line passed from the bootloader.
This supports reading the kernel cmdline from all of the GRUB commands.
DmVerityState will contain the attested dm-verity hash algorithms, root digests, and salts required for validating a dm-verity mounted device (e.g., root fs).
This uses much of what the kernel does for a cmdline string, except it does not actually parse the args into kernel_param structs. Rather, parseArgs returns a map of param strings to val strings. parseArg uses nextArg, which should copy the exact behavior of the kernel in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/cmdline.c.
The server package now supports reading the kernel command line and parsing it, using the same parsing logic as the kernel. This functionality currently only supports parsing a single root hash; multiple dm entries will cause undefined behavior.
// nextArgs must receive a null-terminated string. | ||
if len(commandline) == 0 || commandline[len(commandline)-1] != 0 { | ||
args = make([]byte, len(commandline)+1) | ||
args[len(args)-1] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from @jkl73:
Can directly append() a 0 at the end? args = append(args, byte(0))
seen = true | ||
cmdline = command[suffixAt:] | ||
|
||
verity, err = tryGetDmVerityStateFromCmdline(parseArgs(cmdBytes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernel.commandline, err = getKernelCMDFromGRUB...
kernel.verity, err = getDmVerityFromGRUB...
digests, and salts required for validating a dm-verity mounted device
(e.g., root fs).
This is currently limited to the syntax of the ChromeOS, non-upstreamed fork of dm-verity. It can currently only parse out one dm-verity hash.