Skip to content

Commit d1f0c5e

Browse files
committed
fsverity: don't use bio_first_page_all() in fsverity_verify_bio()
bio_first_page_all(bio)->mapping->host is not compatible with large folios, since the first page of the bio is not necessarily the head page of the folio, and therefore it might not have the mapping pointer set. Therefore, move the dereference of ->mapping->host into verify_data_blocks(), which works with a folio. (Like the commit that this Fixes, this hasn't actually been tested with large folios yet, since the filesystems that use fs/verity/ don't support that yet. But based on code review, I think this is needed.) Fixes: 5d0f0e5 ("fsverity: support verifying data from large folios") Link: https://lore.kernel.org/r/20230604022101.48342-1-ebiggers@kernel.org Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Eric Biggers <ebiggers@google.com>
1 parent 32ab3c5 commit d1f0c5e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/verity/verify.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ verify_data_block(struct inode *inode, struct fsverity_info *vi,
256256
}
257257

258258
static bool
259-
verify_data_blocks(struct inode *inode, struct folio *data_folio,
260-
size_t len, size_t offset, unsigned long max_ra_pages)
259+
verify_data_blocks(struct folio *data_folio, size_t len, size_t offset,
260+
unsigned long max_ra_pages)
261261
{
262+
struct inode *inode = data_folio->mapping->host;
262263
struct fsverity_info *vi = inode->i_verity_info;
263264
const unsigned int block_size = vi->tree_params.block_size;
264265
u64 pos = (u64)data_folio->index << PAGE_SHIFT;
@@ -298,7 +299,7 @@ verify_data_blocks(struct inode *inode, struct folio *data_folio,
298299
*/
299300
bool fsverity_verify_blocks(struct folio *folio, size_t len, size_t offset)
300301
{
301-
return verify_data_blocks(folio->mapping->host, folio, len, offset, 0);
302+
return verify_data_blocks(folio, len, offset, 0);
302303
}
303304
EXPORT_SYMBOL_GPL(fsverity_verify_blocks);
304305

@@ -319,7 +320,6 @@ EXPORT_SYMBOL_GPL(fsverity_verify_blocks);
319320
*/
320321
void fsverity_verify_bio(struct bio *bio)
321322
{
322-
struct inode *inode = bio_first_page_all(bio)->mapping->host;
323323
struct folio_iter fi;
324324
unsigned long max_ra_pages = 0;
325325

@@ -337,7 +337,7 @@ void fsverity_verify_bio(struct bio *bio)
337337
}
338338

339339
bio_for_each_folio_all(fi, bio) {
340-
if (!verify_data_blocks(inode, fi.folio, fi.length, fi.offset,
340+
if (!verify_data_blocks(fi.folio, fi.length, fi.offset,
341341
max_ra_pages)) {
342342
bio->bi_status = BLK_STS_IOERR;
343343
break;

0 commit comments

Comments
 (0)