All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: heyunlei <heyunlei@hihonor.com>
Cc: Chao Yu <chao@kernel.org>,
	jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	bintian.wang@hihonor.com, linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH] f2fs: fsverity: Truncate cache pages if set verity failed
Date: Wed, 24 Feb 2021 15:11:12 -0800	[thread overview]
Message-ID: <YDbdEEcEV5bzgtL6@sol.localdomain> (raw)
In-Reply-To: <YDbbGSsd6ibKOpzT@sol.localdomain>

On Wed, Feb 24, 2021 at 03:02:52PM -0800, Eric Biggers wrote:
> Hi Yunlei,
> 
> On Wed, Feb 24, 2021 at 09:16:24PM +0800, Chao Yu wrote:
> > Hi Yunlei,
> > 
> > On 2021/2/23 19:24, heyunlei wrote:
> > > If file enable verity failed, should truncate anything wrote
> > > past i_size, including cache pages.
> > 
> > +Cc Eric,
> > 
> > After failure of enabling verity, we will see verity metadata if we truncate
> > file to larger size later?
> > 
> > Thanks,
> > 
> > > 
> > > Signed-off-by: heyunlei <heyunlei@hihonor.com>
> > > ---
> > >   fs/f2fs/verity.c | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
> > > index 054ec852b5ea..f1f9b9361a71 100644
> > > --- a/fs/f2fs/verity.c
> > > +++ b/fs/f2fs/verity.c
> > > @@ -170,8 +170,10 @@ static int f2fs_end_enable_verity(struct file *filp, const void *desc,
> > >   	}
> > >   	/* If we failed, truncate anything we wrote past i_size. */
> > > -	if (desc == NULL || err)
> > > +	if (desc == NULL || err) {
> > > +		truncate_inode_pages(inode->i_mapping, inode->i_size);
> > >   		f2fs_truncate(inode);
> > > +	}
> > >   	clear_inode_flag(inode, FI_VERITY_IN_PROGRESS);
> > > 
> 
> This looks good; thanks for finding this.  You can add:
> 
> 	Reviewed-by: Eric Biggers <ebiggers@google.com>
> 
> I thought that f2fs_truncate() would truncate pagecache pages too, but in fact
> that's not the case.
> 
> ext4_end_enable_verity() has the same bug too.  Can you please send a patch for
> that too (to linux-ext4)?
> 

Also please include the following tags in the f2fs patch:

	Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
	Cc: <stable@vger.kernel.org> # v5.4+

and in the ext4 patch:

	Fixes: c93d8f885809 ("ext4: add basic fs-verity support")
	Cc: <stable@vger.kernel.org> # v5.4+

- Eric

WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: heyunlei <heyunlei@hihonor.com>
Cc: jaegeuk@kernel.org, linux-fscrypt@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fsverity: Truncate cache pages if set verity failed
Date: Wed, 24 Feb 2021 15:11:12 -0800	[thread overview]
Message-ID: <YDbdEEcEV5bzgtL6@sol.localdomain> (raw)
In-Reply-To: <YDbbGSsd6ibKOpzT@sol.localdomain>

On Wed, Feb 24, 2021 at 03:02:52PM -0800, Eric Biggers wrote:
> Hi Yunlei,
> 
> On Wed, Feb 24, 2021 at 09:16:24PM +0800, Chao Yu wrote:
> > Hi Yunlei,
> > 
> > On 2021/2/23 19:24, heyunlei wrote:
> > > If file enable verity failed, should truncate anything wrote
> > > past i_size, including cache pages.
> > 
> > +Cc Eric,
> > 
> > After failure of enabling verity, we will see verity metadata if we truncate
> > file to larger size later?
> > 
> > Thanks,
> > 
> > > 
> > > Signed-off-by: heyunlei <heyunlei@hihonor.com>
> > > ---
> > >   fs/f2fs/verity.c | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
> > > index 054ec852b5ea..f1f9b9361a71 100644
> > > --- a/fs/f2fs/verity.c
> > > +++ b/fs/f2fs/verity.c
> > > @@ -170,8 +170,10 @@ static int f2fs_end_enable_verity(struct file *filp, const void *desc,
> > >   	}
> > >   	/* If we failed, truncate anything we wrote past i_size. */
> > > -	if (desc == NULL || err)
> > > +	if (desc == NULL || err) {
> > > +		truncate_inode_pages(inode->i_mapping, inode->i_size);
> > >   		f2fs_truncate(inode);
> > > +	}
> > >   	clear_inode_flag(inode, FI_VERITY_IN_PROGRESS);
> > > 
> 
> This looks good; thanks for finding this.  You can add:
> 
> 	Reviewed-by: Eric Biggers <ebiggers@google.com>
> 
> I thought that f2fs_truncate() would truncate pagecache pages too, but in fact
> that's not the case.
> 
> ext4_end_enable_verity() has the same bug too.  Can you please send a patch for
> that too (to linux-ext4)?
> 

Also please include the following tags in the f2fs patch:

	Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
	Cc: <stable@vger.kernel.org> # v5.4+

and in the ext4 patch:

	Fixes: c93d8f885809 ("ext4: add basic fs-verity support")
	Cc: <stable@vger.kernel.org> # v5.4+

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2021-02-24 23:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210223112425.19180-1-heyunlei@hihonor.com>
2021-02-24 13:16 ` [f2fs-dev] [PATCH] f2fs: fsverity: Truncate cache pages if set verity failed Chao Yu
2021-02-24 23:02   ` Eric Biggers
2021-02-24 23:11     ` Eric Biggers [this message]
2021-02-24 23:11       ` Eric Biggers
2021-02-26  1:42       ` heyunlei 00015531
2021-02-26  1:42         ` [f2fs-dev] " heyunlei 00015531
2021-02-26  2:15         ` Eric Biggers
2021-02-26  2:15           ` [f2fs-dev] " Eric Biggers
2021-02-28  4:52           ` Jaegeuk Kim
2021-02-28  4:52             ` [f2fs-dev] " Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YDbdEEcEV5bzgtL6@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=bintian.wang@hihonor.com \
    --cc=chao@kernel.org \
    --cc=heyunlei@hihonor.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fscrypt@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.