Skip to contentSkip to conversation

fsverity: remove fsverity_verify_page()

PATCH Superseded Eric Biggers 2 participants 6 messages Feb 14

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

cover fsverity: remove fsverity_verify_page()

This series removes the non-large-folio-aware function fsverity_verify_page(), which is no longer needed.

Eric Biggers (2):
f2fs: use fsverity_verify_blocks() instead of fsverity_verify_page()
fsverity: remove fsverity_verify_page()

 fs/f2fs/compress.c       | 3 ++-
 fs/verity/verify.c       | 4 ++--
 include/linux/fsverity.h | 6 ------
 3 files changed, 4 insertions(+), 9 deletions(-)

base-commit: 3e48a11675c50698374d4ac596fb506736eb1c53

Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/2 f2fs: use fsverity_verify_blocks() instead of fsverity_verify_page()

Replace the only remaining caller of fsverity_verify_page() with the equivalent direct call to fsverity_verify_blocks(). No functional change. This will allow fsverity_verify_page() to be removed.

---
 fs/f2fs/compress.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/compress.c +2 -1
index 006a80acd1de..6d688835387d 100644
@@ -1815,11 +1815,12 @@ static void f2fs_verify_cluster(struct work_struct *work)
 		struct page *rpage = dic->rpages[i];
 
 		if (!rpage)
 			continue;
 
-		if (fsverity_verify_page(dic->vi, rpage))
+		if (fsverity_verify_blocks(dic->vi, page_folio(rpage),
+					   PAGE_SIZE, 0))
 			SetPageUptodate(rpage);
 		else
 			ClearPageUptodate(rpage);
 		unlock_page(rpage);
 	}
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/2] f2fs: use fsverity_verify_blocks() instead of fsverity_verify_page()

fs/f2fs/compress.c static void f2fs_verify_cluster(struct work_struct *work) · line 1821

Quoted 4 lines · Eric Biggers
fs/f2fs/compress.c +2 -1
-               if (fsverity_verify_page(dic->vi, rpage))
+               if (fsverity_verify_blocks(dic->vi, page_folio(rpage),
+                                          PAGE_SIZE, 0))

This really is very wrong. It may be equivalent to the old code, but the old code was *also* wrong.

If you use "page_folio()", you need to do the proper offsetting of the page inside the folio, unless the filesystem is purely using the old legacy "folio is the same as page", which is simply not true in f2fs.

It might be true in this particular case, but considering that it was *NOT* true in another case I fixed up, I really don't want to see this same mistake done over and over again.

So either it's the whole folio, in which case PAGE_SIZE is wrong.

Or it really is PAGE_SIZE, in which case you need to use the proper offset within the folio.

Don't take the old buggy garbage that was fsverity_verify_page() and repeat the bug when you remove it.

Linus

author maintainer
#3 lore raw

Re: [PATCH 1/2] f2fs: use fsverity_verify_blocks() instead of fsverity_verify_page()

Quoted 17 lines · Linus Torvalds

fs/f2fs/compress.c static void f2fs_verify_cluster(struct work_struct *work) · line 1821

Quoted 4 lines · Eric Biggers
fs/f2fs/compress.c +2 -1
-               if (fsverity_verify_page(dic->vi, rpage))
+               if (fsverity_verify_blocks(dic->vi, page_folio(rpage),
+                                          PAGE_SIZE, 0))

This really is very wrong. It may be equivalent to the old code, but the old code was *also* wrong.

If you use "page_folio()", you need to do the proper offsetting of the page inside the folio, unless the filesystem is purely using the old legacy "folio is the same as page", which is simply not true in f2fs.

It might be true in this particular case, but considering that it was *NOT* true in another case I fixed up, I really don't want to see this same mistake done over and over again.

Quoted 7 lines

So either it's the whole folio, in which case PAGE_SIZE is wrong.

Or it really is PAGE_SIZE, in which case you need to use the proper offset within the folio.

Don't take the old buggy garbage that was fsverity_verify_page() and repeat the bug when you remove it.

The reason I went with the direct conversion is that f2fs_verify_cluster() clearly assumes small folios already, and indeed it's called only with small folios. But sure, we can make that specific line in it large-folio-aware.

- Eric

#4 lore raw

Re: [PATCH 1/2] f2fs: use fsverity_verify_blocks() instead of fsverity_verify_page()

Quoted 3 lines · Eric Biggers

The reason I went with the direct conversion is that f2fs_verify_cluster() clearly assumes small folios already

... and that was exactly the same thinking that led to the other bug - "it's fine when folios and pages are the same".

And then when the caller was then changed to know about large folios, the code silently became buggy even when it visually *looked* right, because the page-to-folio translation had cut corners.

Linus

author maintainer
#5 lore raw

PATCH 2/2 fsverity: remove fsverity_verify_page()

In reply to Eric Biggers

Now that fsverity_verify_page() has no callers, remove it.

---
 fs/verity/verify.c       | 4 ++--
 include/linux/fsverity.h | 6 ------
 2 files changed, 2 insertions(+), 8 deletions(-)
fs/verity/verify.c +2 -2
index 31797f9b24d0..3e38749fbc82 100644
@@ -431,12 +431,12 @@ EXPORT_SYMBOL_GPL(fsverity_verify_blocks);
  * verification, then bio->bi_status is set to an error status.
  *
  * This is a helper function for use by the ->readahead() method of filesystems
  * that issue bios to read data directly into the page cache.  Filesystems that
  * populate the page cache without issuing bios (e.g. non block-based
- * filesystems) must instead call fsverity_verify_page() directly on each page.
- * All filesystems must also call fsverity_verify_page() on holes.
+ * filesystems) must instead call fsverity_verify_blocks() directly.  All
+ * filesystems must also call fsverity_verify_blocks() on holes.
  */
 void fsverity_verify_bio(struct fsverity_info *vi, struct bio *bio)
 {
 	struct fsverity_verification_context ctx;
 	struct folio_iter fi;
include/linux/fsverity.h +0 -6
index fed91023bea9..6de3ddf0b148 100644
@@ -280,16 +280,10 @@ static inline bool fsverity_verify_folio(struct fsverity_info *vi,
 					 struct folio *folio)
 {
 	return fsverity_verify_blocks(vi, folio, folio_size(folio), 0);
 }
 
-static inline bool fsverity_verify_page(struct fsverity_info *vi,
-					struct page *page)
-{
-	return fsverity_verify_blocks(vi, page_folio(page), PAGE_SIZE, 0);
-}
-
 /**
  * fsverity_file_open() - prepare to open a verity file
  * @inode: the inode being opened
  * @filp: the struct file being set up
  *
Signature · 1 line
2.53.0