[f2fs-dev] [PATCH] f2fs: fix double free of unicode map
In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL. Set NULL after free to prevent double freeing when unmount. Signed-off-by: Hyeongseok Kim --- fs/f2fs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 00eff2f51807..fef22e476c52 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) #ifdef CONFIG_UNICODE utf8_unload(sb->s_encoding); + sb->s_encoding = NULL; #endif free_options: #ifdef CONFIG_QUOTA -- 2.27.0.83.g0313f36 ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: fix double free of unicode map
On Thu, Nov 12, 2020 at 05:02:01PM +0900, Hyeongseok Kim wrote: > In case of retrying fill_super with skip_recovery, > s_encoding for casefold would not be loaded again even though it's > already been freed because it's not NULL. > Set NULL after free to prevent double freeing when unmount. > > Signed-off-by: Hyeongseok Kim > --- > fs/f2fs/super.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 00eff2f51807..fef22e476c52 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void > *data, int silent) > > #ifdef CONFIG_UNICODE > utf8_unload(sb->s_encoding); > + sb->s_encoding = NULL; > #endif > free_options: > #ifdef CONFIG_QUOTA > -- This is: Fixes: eca4873ee1b6 ("f2fs: Use generic casefolding support") Right? - Eric ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: fix double free of unicode map
On 11/12/20 5:17 PM, Eric Biggers wrote: On Thu, Nov 12, 2020 at 05:02:01PM +0900, Hyeongseok Kim wrote: In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL. Set NULL after free to prevent double freeing when unmount. Signed-off-by: Hyeongseok Kim --- fs/f2fs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 00eff2f51807..fef22e476c52 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) #ifdef CONFIG_UNICODE utf8_unload(sb->s_encoding); + sb->s_encoding = NULL; #endif free_options: #ifdef CONFIG_QUOTA -- This is: Fixes: eca4873ee1b6 ("f2fs: Use generic casefolding support") Right? - Eric Right. Should I add "Fixes" tag and send v2? ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH v2] f2fs: fix double free of unicode map
In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL. Set NULL after free to prevent double freeing when unmount. Fixes: eca4873ee1b6 ("f2fs: Use generic casefolding support") Signed-off-by: Hyeongseok Kim --- fs/f2fs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 00eff2f51807..fef22e476c52 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) #ifdef CONFIG_UNICODE utf8_unload(sb->s_encoding); + sb->s_encoding = NULL; #endif free_options: #ifdef CONFIG_QUOTA -- 2.27.0.83.g0313f36 ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH v2] f2fs: fix double free of unicode map
On 2020/11/12 17:14, Hyeongseok Kim wrote: In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL. Set NULL after free to prevent double freeing when unmount. Fixes: eca4873ee1b6 ("f2fs: Use generic casefolding support") Signed-off-by: Hyeongseok Kim Reviewed-by: Chao Yu Thanks, ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] fscrypt: fix inline encryption not used on new files
On Tue, Nov 10, 2020 at 05:52:24PM -0800, Eric Biggers wrote: > From: Eric Biggers > > The new helper function fscrypt_prepare_new_inode() runs before > S_ENCRYPTED has been set on the new inode. This accidentally made > fscrypt_select_encryption_impl() never enable inline encryption on newly > created files, due to its use of fscrypt_needs_contents_encryption() > which only returns true when S_ENCRYPTED is set. > > Fix this by using S_ISREG() directly instead of > fscrypt_needs_contents_encryption(), analogous to what > select_encryption_mode() does. > > I didn't notice this earlier because by design, the user-visible > behavior is the same (other than performance, potentially) regardless of > whether inline encryption is used or not. > > Fixes: a992b20cd4ee ("fscrypt: add fscrypt_prepare_new_inode() and > fscrypt_set_context()") > Signed-off-by: Eric Biggers > --- > fs/crypto/inline_crypt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c > index 89bffa82ed74a..c57bebfa48fea 100644 > --- a/fs/crypto/inline_crypt.c > +++ b/fs/crypto/inline_crypt.c > @@ -74,7 +74,7 @@ int fscrypt_select_encryption_impl(struct fscrypt_info *ci) > int i; > > /* The file must need contents encryption, not filenames encryption */ > - if (!fscrypt_needs_contents_encryption(inode)) > + if (!S_ISREG(inode->i_mode)) > return 0; > > /* The crypto mode must have a blk-crypto counterpart */ > > base-commit: 92cfcd030e4b1de11a6b1edb0840e55c26332d31 Applied to fscrypt.git#for-stable for 5.10. - Eric ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [GIT PULL] another fscrypt fix for 5.10-rc4
The following changes since commit 92cfcd030e4b1de11a6b1edb0840e55c26332d31: fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key() (2020-11-06 09:48:55 -0800) are available in the Git repository at: https://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git tags/fscrypt-for-linus for you to fetch changes up to d19d8d345eecd9247cbe6cbf27aef271bd88aba7: fscrypt: fix inline encryption not used on new files (2020-11-11 20:59:07 -0800) Fix a regression where new files weren't using inline encryption when they should be. Eric Biggers (1): fscrypt: fix inline encryption not used on new files fs/crypto/inline_crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [GIT PULL] another fscrypt fix for 5.10-rc4
The pull request you sent on Thu, 12 Nov 2020 15:16:30 -0800: > https://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git tags/fscrypt-for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/585e5b17b92dead8a3aca4e3c9876fbca5f7e0ba Thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH] f2fs: fix the bug in f2fs_direct_IO with inline encryption
Now we have inline encrytion and fs layer encrption in the kernel, when we choose inline encryption, we should not use bufferd IO instead of direct IO. Signed-off-by: Lihong Kou --- fs/f2fs/f2fs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index cb700d797296..ccc5c9734f55 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3889,8 +3889,8 @@ static inline void f2fs_set_encrypted_inode(struct inode *inode) */ static inline bool f2fs_post_read_required(struct inode *inode) { - return f2fs_encrypted_file(inode) || fsverity_active(inode) || - f2fs_compressed_file(inode); + return (f2fs_encrypted_file(inode) && fscrypt_inode_uses_fs_layer_crypto(inode)) + || fsverity_active(inode) || f2fs_compressed_file(inode); } /* -- 2.17.1 ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: fix the bug in f2fs_direct_IO with inline encryption
On Fri, Nov 13, 2020 at 11:43:48AM +0800, Lihong Kou wrote: > Now we have inline encrytion and fs layer encrption in the kernel, when we > choose inline encryption, we should not use bufferd IO instead of direct IO. > > Signed-off-by: Lihong Kou > --- > fs/f2fs/f2fs.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index cb700d797296..ccc5c9734f55 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -3889,8 +3889,8 @@ static inline void f2fs_set_encrypted_inode(struct > inode *inode) > */ > static inline bool f2fs_post_read_required(struct inode *inode) > { > - return f2fs_encrypted_file(inode) || fsverity_active(inode) || > - f2fs_compressed_file(inode); > + return (f2fs_encrypted_file(inode) && > fscrypt_inode_uses_fs_layer_crypto(inode)) > + || fsverity_active(inode) || f2fs_compressed_file(inode); > } This isn't correct for upstream because upstream doesn't support direct I/O with fscrypt inline encryption yet. The patchset to support direct I/O with fscrypt inline encryption was last sent out at https://lkml.kernel.org/linux-fscrypt/20200720233739.824943-1-sat...@google.com. I believe that Satya is planning to send it again soon. On the other hand, downstream, the Android common kernels have the fscrypt direct I/O support already, and f2fs_force_buffered_io() has been updated accordingly. If you're using one of the Android common kernels, can you make sure it's up-to-date? - Eric ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel