Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\verity\verify.c Create Date:2022-07-28 20:24:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Verify a single data page against the file's Merkle tree

Proto:static bool verify_page(struct inode *inode, const struct fsverity_info *vi, struct ahash_request *req, struct page *data_page)

Type:bool

Parameter:

TypeParameterName
struct inode *inode
const struct fsverity_info *vi
struct ahash_request *req
struct page *data_page
89  params = tree_params
90  hsize = same as hash_alg->digest_size
91  index = Our offset within mapping.
100  If WARN_ON_ONCE(!PageLocked(data_page) || PageUptodate(data_page)) Then Return false
103  pr_debug_ratelimited("Verifying data page %lu...\n", index)
110  When level < umber of levels in Merkle tree cycle
115  hash_at_level() - compute the location of the block's hash at the given level*@params: (in) the Merkle tree parameters*@dindex: (in) the index of the data block being verified*@level: (in) the level of hash we want (0 is leaf level)*@hindex: (out) the
117  pr_debug_ratelimited("Level %d: hindex=%lu, hoffset=%u\n", level, hindex, hoffset)
120  hpage = read_merkle_tree_page(inode, hindex)
122  If IS_ERR(hpage) Then
123  err = PTR_ERR(hpage)
124  fsverity_err(inode, "Error %d reading Merkle tree page %lu", err, hindex)
127  Go to out
130  If PageChecked(hpage) Then
134  pr_debug_ratelimited("Hash page already checked, want %s:%*phN\n", crypto API name, e.g. sha256 , hsize, want_hash)
137  Go to descend
139  pr_debug_ratelimited("Hash page not yet checked\n")
140  hpages[level] = hpage
141  hoffsets[level] = hoffset
144  want_hash = root_hash
145  pr_debug("Want root hash: %s:%*phN\n", crypto API name, e.g. sha256 , hsize, want_hash)
147  descend :
149  When level > 0 cycle
150  hpage = hpages[level - 1]
151  hoffset = hoffsets[level - 1]
153  err = sverity_hash_page() - hash a single data or hash page*@params: the Merkle tree's parameters*@inode: inode for which the hashing is being done*@req: preallocated hash request*@page: the page to hash*@out: output digest, size 'params->digest_size' bytes
154  If err Then Go to out
156  err = cmp_hashes(vi, want_hash, real_hash, index, level - 1)
157  If err Then Go to out
159  SetPageChecked(hpage)
160  Extract a hash from a hash page
161  want_hash = _want_hash
162  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
163  pr_debug("Verified hash page at level %d, now want %s:%*phN\n", level - 1, crypto API name, e.g. sha256 , hsize, want_hash)
168  err = sverity_hash_page() - hash a single data or hash page*@params: the Merkle tree's parameters*@inode: inode for which the hashing is being done*@req: preallocated hash request*@page: the page to hash*@out: output digest, size 'params->digest_size' bytes
169  If err Then Go to out
171  err = cmp_hashes(vi, want_hash, real_hash, index, - 1)
172  out :
173  When level > 0 cycle Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
176  Return err == 0
Caller
NameDescribe
fsverity_verify_pagesverity_verify_page() - verify a data page* Verify a page that has just been read from a verity file. The page must be a* pagecache page that is still locked and not yet uptodate.* Return: true if the page is valid, else false.
fsverity_verify_biosverity_verify_bio() - verify a 'read' bio that has just completed* Verify a set of pages that have just been read from a verity file. The pages* must be pagecache pages that are still locked and not yet uptodate. Pages