linux-fscrypt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
@ 2019-12-09 20:00 Eric Biggers
  2019-12-09 22:28 ` Jaegeuk Kim
  2019-12-10  2:08 ` Chao Yu
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Biggers @ 2019-12-09 20:00 UTC (permalink / raw)
  To: linux-f2fs-devel, Jaegeuk Kim; +Cc: linux-fscrypt

From: Eric Biggers <ebiggers@google.com>

META_MAPPING is used to move blocks for both encrypted and verity files.
So the META_MAPPING invalidation condition in do_checkpoint() should
consider verity too, not just encrypt.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/f2fs/checkpoint.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index ffdaba0c55d29..44e84ac5c9411 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	f2fs_wait_on_all_pages_writeback(sbi);
 
 	/*
-	 * invalidate intermediate page cache borrowed from meta inode
-	 * which are used for migration of encrypted inode's blocks.
+	 * invalidate intermediate page cache borrowed from meta inode which are
+	 * used for migration of encrypted or verity inode's blocks.
 	 */
-	if (f2fs_sb_has_encrypt(sbi))
+	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
 		invalidate_mapping_pages(META_MAPPING(sbi),
 				MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
 
-- 
2.24.0.393.g34dc348eaf-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 20:00 [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks Eric Biggers
@ 2019-12-09 22:28 ` Jaegeuk Kim
  2019-12-09 22:40   ` Eric Biggers
  2019-12-10  2:08 ` Chao Yu
  1 sibling, 1 reply; 7+ messages in thread
From: Jaegeuk Kim @ 2019-12-09 22:28 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-f2fs-devel, linux-fscrypt

On 12/09, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> META_MAPPING is used to move blocks for both encrypted and verity files.
> So the META_MAPPING invalidation condition in do_checkpoint() should
> consider verity too, not just encrypt.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/f2fs/checkpoint.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index ffdaba0c55d29..44e84ac5c9411 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  	f2fs_wait_on_all_pages_writeback(sbi);
>  
>  	/*
> -	 * invalidate intermediate page cache borrowed from meta inode
> -	 * which are used for migration of encrypted inode's blocks.
> +	 * invalidate intermediate page cache borrowed from meta inode which are
> +	 * used for migration of encrypted or verity inode's blocks.
>  	 */
> -	if (f2fs_sb_has_encrypt(sbi))
> +	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))

Do we need f2fs_post_read_required() aligned to the condition of
move_data_block()?

>  		invalidate_mapping_pages(META_MAPPING(sbi),
>  				MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
>  
> -- 
> 2.24.0.393.g34dc348eaf-goog

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 22:28 ` Jaegeuk Kim
@ 2019-12-09 22:40   ` Eric Biggers
  2019-12-09 22:48     ` Jaegeuk Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Biggers @ 2019-12-09 22:40 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-fscrypt

On Mon, Dec 09, 2019 at 02:28:28PM -0800, Jaegeuk Kim wrote:
> On 12/09, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > META_MAPPING is used to move blocks for both encrypted and verity files.
> > So the META_MAPPING invalidation condition in do_checkpoint() should
> > consider verity too, not just encrypt.
> > 
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > ---
> >  fs/f2fs/checkpoint.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > index ffdaba0c55d29..44e84ac5c9411 100644
> > --- a/fs/f2fs/checkpoint.c
> > +++ b/fs/f2fs/checkpoint.c
> > @@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> >  	f2fs_wait_on_all_pages_writeback(sbi);
> >  
> >  	/*
> > -	 * invalidate intermediate page cache borrowed from meta inode
> > -	 * which are used for migration of encrypted inode's blocks.
> > +	 * invalidate intermediate page cache borrowed from meta inode which are
> > +	 * used for migration of encrypted or verity inode's blocks.
> >  	 */
> > -	if (f2fs_sb_has_encrypt(sbi))
> > +	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
> 
> Do we need f2fs_post_read_required() aligned to the condition of
> move_data_block()?
> 

I think you're asking why verity files have to be moved via META_MAPPING?  The
reason is that we have to be super careful not to read pages of a verity file
into its own address_space without doing the fs-verity data verification, as
then unverified data would be available to userspace.

In theory, F2FS's garbage collector could do the data verification.  But it's
tricky because ->i_verity_info may not have been set up yet.  So it might be
easiest to continue to treat verity files like encrypted files.

- Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 22:40   ` Eric Biggers
@ 2019-12-09 22:48     ` Jaegeuk Kim
  2019-12-09 22:53       ` Eric Biggers
  0 siblings, 1 reply; 7+ messages in thread
From: Jaegeuk Kim @ 2019-12-09 22:48 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-f2fs-devel, linux-fscrypt

On 12/09, Eric Biggers wrote:
> On Mon, Dec 09, 2019 at 02:28:28PM -0800, Jaegeuk Kim wrote:
> > On 12/09, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > > 
> > > META_MAPPING is used to move blocks for both encrypted and verity files.
> > > So the META_MAPPING invalidation condition in do_checkpoint() should
> > > consider verity too, not just encrypt.
> > > 
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > ---
> > >  fs/f2fs/checkpoint.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > > index ffdaba0c55d29..44e84ac5c9411 100644
> > > --- a/fs/f2fs/checkpoint.c
> > > +++ b/fs/f2fs/checkpoint.c
> > > @@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> > >  	f2fs_wait_on_all_pages_writeback(sbi);
> > >  
> > >  	/*
> > > -	 * invalidate intermediate page cache borrowed from meta inode
> > > -	 * which are used for migration of encrypted inode's blocks.
> > > +	 * invalidate intermediate page cache borrowed from meta inode which are
> > > +	 * used for migration of encrypted or verity inode's blocks.
> > >  	 */
> > > -	if (f2fs_sb_has_encrypt(sbi))
> > > +	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
> > 
> > Do we need f2fs_post_read_required() aligned to the condition of
> > move_data_block()?
> > 
> 
> I think you're asking why verity files have to be moved via META_MAPPING?  The
> reason is that we have to be super careful not to read pages of a verity file
> into its own address_space without doing the fs-verity data verification, as
> then unverified data would be available to userspace.
> 
> In theory, F2FS's garbage collector could do the data verification.  But it's
> tricky because ->i_verity_info may not have been set up yet.  So it might be
> easiest to continue to treat verity files like encrypted files.

I meant to ask why not just checking f2fs_post_read_required() here so that we
could sync the check across multiple places.

> 
> - Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 22:48     ` Jaegeuk Kim
@ 2019-12-09 22:53       ` Eric Biggers
  2019-12-09 22:58         ` Jaegeuk Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Biggers @ 2019-12-09 22:53 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-fscrypt

On Mon, Dec 09, 2019 at 02:48:57PM -0800, Jaegeuk Kim wrote:
> On 12/09, Eric Biggers wrote:
> > On Mon, Dec 09, 2019 at 02:28:28PM -0800, Jaegeuk Kim wrote:
> > > On 12/09, Eric Biggers wrote:
> > > > From: Eric Biggers <ebiggers@google.com>
> > > > 
> > > > META_MAPPING is used to move blocks for both encrypted and verity files.
> > > > So the META_MAPPING invalidation condition in do_checkpoint() should
> > > > consider verity too, not just encrypt.
> > > > 
> > > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > > ---
> > > >  fs/f2fs/checkpoint.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > > > index ffdaba0c55d29..44e84ac5c9411 100644
> > > > --- a/fs/f2fs/checkpoint.c
> > > > +++ b/fs/f2fs/checkpoint.c
> > > > @@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> > > >  	f2fs_wait_on_all_pages_writeback(sbi);
> > > >  
> > > >  	/*
> > > > -	 * invalidate intermediate page cache borrowed from meta inode
> > > > -	 * which are used for migration of encrypted inode's blocks.
> > > > +	 * invalidate intermediate page cache borrowed from meta inode which are
> > > > +	 * used for migration of encrypted or verity inode's blocks.
> > > >  	 */
> > > > -	if (f2fs_sb_has_encrypt(sbi))
> > > > +	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
> > > 
> > > Do we need f2fs_post_read_required() aligned to the condition of
> > > move_data_block()?
> > > 
> > 
> > I think you're asking why verity files have to be moved via META_MAPPING?  The
> > reason is that we have to be super careful not to read pages of a verity file
> > into its own address_space without doing the fs-verity data verification, as
> > then unverified data would be available to userspace.
> > 
> > In theory, F2FS's garbage collector could do the data verification.  But it's
> > tricky because ->i_verity_info may not have been set up yet.  So it might be
> > easiest to continue to treat verity files like encrypted files.
> 
> I meant to ask why not just checking f2fs_post_read_required() here so that we
> could sync the check across multiple places.
> 

We can't use f2fs_post_read_required() here because f2fs_post_read_required()
deals with a specific inode, but do_checkpoint() is dealing with the entire
filesystem.  It's checking whether the filesystem might have *any* files that
were moved via META_MAPPING.

- Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 22:53       ` Eric Biggers
@ 2019-12-09 22:58         ` Jaegeuk Kim
  0 siblings, 0 replies; 7+ messages in thread
From: Jaegeuk Kim @ 2019-12-09 22:58 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-f2fs-devel, linux-fscrypt

On 12/09, Eric Biggers wrote:
> On Mon, Dec 09, 2019 at 02:48:57PM -0800, Jaegeuk Kim wrote:
> > On 12/09, Eric Biggers wrote:
> > > On Mon, Dec 09, 2019 at 02:28:28PM -0800, Jaegeuk Kim wrote:
> > > > On 12/09, Eric Biggers wrote:
> > > > > From: Eric Biggers <ebiggers@google.com>
> > > > > 
> > > > > META_MAPPING is used to move blocks for both encrypted and verity files.
> > > > > So the META_MAPPING invalidation condition in do_checkpoint() should
> > > > > consider verity too, not just encrypt.
> > > > > 
> > > > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > > > ---
> > > > >  fs/f2fs/checkpoint.c | 6 +++---
> > > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > > > > index ffdaba0c55d29..44e84ac5c9411 100644
> > > > > --- a/fs/f2fs/checkpoint.c
> > > > > +++ b/fs/f2fs/checkpoint.c
> > > > > @@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> > > > >  	f2fs_wait_on_all_pages_writeback(sbi);
> > > > >  
> > > > >  	/*
> > > > > -	 * invalidate intermediate page cache borrowed from meta inode
> > > > > -	 * which are used for migration of encrypted inode's blocks.
> > > > > +	 * invalidate intermediate page cache borrowed from meta inode which are
> > > > > +	 * used for migration of encrypted or verity inode's blocks.
> > > > >  	 */
> > > > > -	if (f2fs_sb_has_encrypt(sbi))
> > > > > +	if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
> > > > 
> > > > Do we need f2fs_post_read_required() aligned to the condition of
> > > > move_data_block()?
> > > > 
> > > 
> > > I think you're asking why verity files have to be moved via META_MAPPING?  The
> > > reason is that we have to be super careful not to read pages of a verity file
> > > into its own address_space without doing the fs-verity data verification, as
> > > then unverified data would be available to userspace.
> > > 
> > > In theory, F2FS's garbage collector could do the data verification.  But it's
> > > tricky because ->i_verity_info may not have been set up yet.  So it might be
> > > easiest to continue to treat verity files like encrypted files.
> > 
> > I meant to ask why not just checking f2fs_post_read_required() here so that we
> > could sync the check across multiple places.
> > 
> 
> We can't use f2fs_post_read_required() here because f2fs_post_read_required()
> deals with a specific inode, but do_checkpoint() is dealing with the entire
> filesystem.  It's checking whether the filesystem might have *any* files that
> were moved via META_MAPPING.

Ah, I misread the code. Thank you for refreshing me.

> 
> - Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks
  2019-12-09 20:00 [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks Eric Biggers
  2019-12-09 22:28 ` Jaegeuk Kim
@ 2019-12-10  2:08 ` Chao Yu
  1 sibling, 0 replies; 7+ messages in thread
From: Chao Yu @ 2019-12-10  2:08 UTC (permalink / raw)
  To: Eric Biggers, linux-f2fs-devel, Jaegeuk Kim; +Cc: linux-fscrypt

On 2019/12/10 4:00, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> META_MAPPING is used to move blocks for both encrypted and verity files.
> So the META_MAPPING invalidation condition in do_checkpoint() should
> consider verity too, not just encrypt.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-12-10  2:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 20:00 [PATCH] f2fs: don't keep META_MAPPING pages used for moving verity file blocks Eric Biggers
2019-12-09 22:28 ` Jaegeuk Kim
2019-12-09 22:40   ` Eric Biggers
2019-12-09 22:48     ` Jaegeuk Kim
2019-12-09 22:53       ` Eric Biggers
2019-12-09 22:58         ` Jaegeuk Kim
2019-12-10  2:08 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).