Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1304)

Unified Diff: drivers/md/dm-bht.c

Issue 6835032: CHROMIUM: verity: don't call page_address on unmapped highmem pages (Closed) Base URL: http://git.chromium.org/git/kernel-next.git@chromeos-2.6.37
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | drivers/md/dm-verity.c » ('j') | include/linux/dm-bht.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: drivers/md/dm-bht.c
diff --git a/drivers/md/dm-bht.c b/drivers/md/dm-bht.c
index e3da9c55f25eb30bf3212b04e638548e29630512..d150b867fefc1c4ba2ebdbd11ef036b7900a546d 100644
--- a/drivers/md/dm-bht.c
+++ b/drivers/md/dm-bht.c
@@ -95,24 +95,14 @@ typedef int (*dm_bht_compare_cb)(struct dm_bht *, u8 *, u8 *);
/**
* dm_bht_compute_hash: hashes a page of data
*/
-static int dm_bht_compute_hash(struct dm_bht *bht, const void *block,
- u8 *digest)
+static int dm_bht_compute_hash(struct dm_bht *bht, struct page *pg,
+ unsigned int offset, u8 *digest)
{
struct hash_desc *hash_desc = &bht->hash_desc[smp_processor_id()];
struct scatterlist sg;
- /* TODO(msb): Once we supporting block_size < PAGE_SIZE, change this to:
- * offset_into_page + length < page_size
- * For now just check that block is page-aligned.
- */
- /*
- * TODO(msb): Re-enable once user-space code is modified to use
- * aligned buffers.
- * BUG_ON(!IS_ALIGNED((uintptr_t)block, PAGE_SIZE));
- */
-
sg_init_table(&sg, 1);
- sg_set_buf(&sg, block, PAGE_SIZE);
+ sg_set_page(&sg, pg, PAGE_SIZE, 0);
Will Drewry 2011/04/13 20:19:30 should 0 be the new offset argument? Then the comm
/* Note, this is synchronous. */
if (crypto_hash_init(hash_desc)) {
DMCRIT("failed to reinitialize crypto hash (proc:%d)",
@@ -653,7 +643,7 @@ static int dm_bht_verify_root(struct dm_bht *bht,
* Verifies the path. Returns 0 on ok.
*/
static int dm_bht_verify_path(struct dm_bht *bht, unsigned int block_index,
- const void *block)
+ struct page *pg, unsigned int offset)
{
unsigned int depth = bht->depth;
struct dm_bht_entry *entry;
@@ -674,14 +664,15 @@ static int dm_bht_verify_path(struct dm_bht *bht, unsigned int block_index,
BUG_ON(state < DM_BHT_ENTRY_READY);
node = dm_bht_get_node(bht, entry, depth, block_index);
- if (dm_bht_compute_hash(bht, block, digest) ||
+ if (dm_bht_compute_hash(bht, pg, offset, digest) ||
dm_bht_compare_hash(bht, digest, node))
goto mismatch;
/* Keep the containing block of hashes to be verified in the
* next pass.
*/
- block = entry->nodes;
+ pg = virt_to_page(entry->nodes);
Will Drewry 2011/04/13 20:19:30 Hrm should we yet-again convert nodes back to a st
Mandeep Singh Baines 2011/04/13 21:11:16 The virt_to_page here is safe because we did not u
+ offset = 0;
} while (--depth > 0 && state != DM_BHT_ENTRY_VERIFIED);
/* Mark path to leaf as verified. */
@@ -776,7 +767,7 @@ int dm_bht_store_block(struct dm_bht *bht, unsigned int block_index,
return 1;
}
- dm_bht_compute_hash(bht, block_data,
+ dm_bht_compute_hash(bht, virt_to_page(block_data), 0,
Olof Johansson 2011/04/13 21:11:57 Currently block_data is guaranteed to be page alig
dm_bht_node(bht, entry, node_index));
return 0;
}
@@ -846,10 +837,10 @@ int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx)
if (count == 0)
count = bht->node_count;
for (j = 0; j < count; j++, child++) {
- u8 *block = child->nodes;
+ struct page *pg = virt_to_page(child->nodes);
u8 *digest = dm_bht_node(bht, entry, j);
- r = dm_bht_compute_hash(bht, block, digest);
+ r = dm_bht_compute_hash(bht, pg, 0, digest);
Olof Johansson 2011/04/13 21:11:57 Same here, should probably compute offset?
if (r) {
DMERR("Failed to update (d=%u,i=%u)",
depth, i);
@@ -1026,7 +1017,7 @@ EXPORT_SYMBOL(dm_bht_populate);
* should return similarly.
*/
int dm_bht_verify_block(struct dm_bht *bht, unsigned int block_index,
- const void *block)
+ struct page *pg, unsigned int offset)
{
int r = 0;
@@ -1040,7 +1031,7 @@ int dm_bht_verify_block(struct dm_bht *bht, unsigned int block_index,
}
/* Now check levels in between */
- r = dm_bht_verify_path(bht, block_index, block);
+ r = dm_bht_verify_path(bht, block_index, pg, offset);
if (r)
DMERR_LIMIT("Failed to verify block: %u (%d)", block_index, r);
« no previous file with comments | « no previous file | drivers/md/dm-verity.c » ('j') | include/linux/dm-bht.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698