Commit Graph

20 Commits

Author SHA1 Message Date
Chong Cai bff58ecaaa Internal change.
PiperOrigin-RevId: 392523879
2021-08-23 14:51:50 -07:00
Chong Cai d43a3ca819 Merge Read calls in verity merkle tree
Read all data into memory in one Read call and verify them block by
block instead of read each block during verification. This is for
performance purpose to avoid invoking multiple syscalls.

PiperOrigin-RevId: 391877937
2021-08-19 17:16:30 -07:00
Chong Cai 57095bd3bd Sort children map before hash
The unordered map may generate different hash due to its order. The
children map needs to be sorted each time before hashing to avoid false
verification failure due to the map.

Store the sorted children map in verity dentry to avoid sorting it each
time verification happens.

Also serialize the whole VerityDescriptor struct to hash now that the
map is removed from it.

PiperOrigin-RevId: 382201560
2021-06-29 17:44:53 -07:00
Chong Cai 669523f7d2 Remove outdated TODOs in verity
PiperOrigin-RevId: 371198372
2021-04-29 14:02:24 -07:00
Chong Cai ffeb2a2f54 Add Children in merkletree generate
This field was missing and should be provided.

PiperOrigin-RevId: 367474481
2021-04-08 11:45:54 -07:00
Zach Koopmans 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
gVisor bot 4314bb0b2b Internal change.
PiperOrigin-RevId: 357090170
2021-02-11 17:12:23 -08:00
gVisor bot be5922fbd2 Internal change.
PiperOrigin-RevId: 347091372
2020-12-11 16:06:01 -08:00
Chong Cai f01f623879 Add children names into verity hash
children names map can be used to verify whether a child is expected
during walking, so that we can detect unexpected modifications that
deleted/renamed both the target file and the corresponding merkle tree
file.

PiperOrigin-RevId: 342170715
2020-11-12 17:56:21 -08:00
Chong Cai a15562c019 Include file size in Merkle hash
The file size can now also be verified. Also, since we are zero-padding
the last block of the data, we cannot differentiate the cases between
zero-padded block from the blocks that are ends with zeroes. With the
size included this can be addressed, as those cases would have different
file size.

PiperOrigin-RevId: 340695510
2020-11-04 11:41:38 -08:00
Chong Cai bc91ae17f6 Add SHA512 to merkle tree library
PiperOrigin-RevId: 339377254
2020-10-27 19:12:35 -07:00
Chong Cai ef90fe1733 Change Merkle tree library to use ReaderAt
Merkle tree library was originally using Read/Seek to access data and
tree, since the parameters are io.ReadSeeker. This could cause race
conditions if multiple threads accesses the same fd to read. Here we
change to use ReaderAt, and implement it with PRead to make it thread
safe.

PiperOrigin-RevId: 336779260
2020-10-12 17:30:14 -07:00
Chong Cai 5389e441a5 Include stat in Verity hash
PiperOrigin-RevId: 336395445
2020-10-09 17:29:34 -07:00
gVisor bot 3dc3fb2375 Fix typo in merkletree
PiperOrigin-RevId: 335709552
2020-10-06 13:35:31 -07:00
Chong Cai 3749e70a69 Implement PRead for verity fs
PRead is implemented by read from the underlying file in blocks, and
verify each block. The verified contents are saved into the output
buffer.

PiperOrigin-RevId: 332092267
2020-09-16 14:45:39 -07:00
gVisor bot 911cecaa34 Implement walk in gvisor verity fs
Implement walk directories in gvisor verity file system. For each step,
the child dentry is verified against a verified parent root hash.

PiperOrigin-RevId: 329358747
2020-08-31 12:52:21 -07:00
gVisor bot ee041b60bf Add check for same source in merkle tree lib
If the data is in the same Reader as the merkle tree, we should verify
from the first layer in the tree, instead of from the beginning.

PiperOrigin-RevId: 328230988
2020-08-24 16:34:15 -07:00
gVisor bot 1b938ba72c Add Verify in merkle tree library
Verify checks input data against the merkle tree, and compares the root
hash with expectation.

PiperOrigin-RevId: 327116711
2020-08-17 15:56:22 -07:00
gVisor bot af6ec7b734 Add Generate method in merkletree
A method is added to generate a merkle tree for data, and store the
generated tree in the output.

PiperOrigin-RevId: 315966571
2020-06-11 13:33:09 -07:00
gVisor bot b39cc6a800 Add merkle tree size measure
This change creates a merkletree package which will be used in the future
for an implementation of file system API.

PiperOrigin-RevId: 315952451
2020-06-11 12:23:25 -07:00