* [f2fs-dev] [PATCH 4.4] f2fs crypto: avoid unneeded memory allocation in ->readdir
@ 2020-10-31 19:58 Eric Biggers
2020-11-01 10:31 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2020-10-31 19:58 UTC (permalink / raw)
To: stable; +Cc: Jaegeuk Kim, linux-fscrypt, linux-f2fs-devel
From: Chao Yu <yuchao0@huawei.com>
commit e06f86e61d7a67fe6e826010f57aa39c674f4b1b upstream.
[This backport fixes a regression in 4.4-stable caused by commit
11a6e8f89521 ("f2fs: check memory boundary by insane namelen"), which
depended on this missing commit. This bad backport broke f2fs
encryption because it moved the incrementing of 'bit_pos' to earlier in
f2fs_fill_dentries() without accounting for it being used in the
encrypted dir case. This caused readdir() on encrypted directories to
start failing. Tested with 'kvm-xfstests -c f2fs -g encrypt'.]
When decrypting dirents in ->readdir, fscrypt_fname_disk_to_usr won't
change content of original encrypted dirent, we don't need to allocate
additional buffer for storing mirror of it, so get rid of it.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/dir.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index e2ff0eb16f89c..c1130914d6ed7 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -820,15 +820,8 @@ bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
int save_len = fstr->len;
int ret;
- de_name.name = kmalloc(de_name.len, GFP_NOFS);
- if (!de_name.name)
- return false;
-
- memcpy(de_name.name, d->filename[bit_pos], de_name.len);
-
ret = f2fs_fname_disk_to_usr(d->inode, &de->hash_code,
&de_name, fstr);
- kfree(de_name.name);
if (ret < 0)
return true;
--
2.29.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH 4.4] f2fs crypto: avoid unneeded memory allocation in ->readdir
2020-10-31 19:58 [f2fs-dev] [PATCH 4.4] f2fs crypto: avoid unneeded memory allocation in ->readdir Eric Biggers
@ 2020-11-01 10:31 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2020-11-01 10:31 UTC (permalink / raw)
To: Eric Biggers; +Cc: Jaegeuk Kim, linux-fscrypt, stable, linux-f2fs-devel
On Sat, Oct 31, 2020 at 12:58:09PM -0700, Eric Biggers wrote:
> From: Chao Yu <yuchao0@huawei.com>
>
> commit e06f86e61d7a67fe6e826010f57aa39c674f4b1b upstream.
> [This backport fixes a regression in 4.4-stable caused by commit
> 11a6e8f89521 ("f2fs: check memory boundary by insane namelen"), which
> depended on this missing commit. This bad backport broke f2fs
> encryption because it moved the incrementing of 'bit_pos' to earlier in
> f2fs_fill_dentries() without accounting for it being used in the
> encrypted dir case. This caused readdir() on encrypted directories to
> start failing. Tested with 'kvm-xfstests -c f2fs -g encrypt'.]
>
> When decrypting dirents in ->readdir, fscrypt_fname_disk_to_usr won't
> change content of original encrypted dirent, we don't need to allocate
> additional buffer for storing mirror of it, so get rid of it.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> fs/f2fs/dir.c | 7 -------
> 1 file changed, 7 deletions(-)
Now queued up, thanks.
greg k-h
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-01 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-31 19:58 [f2fs-dev] [PATCH 4.4] f2fs crypto: avoid unneeded memory allocation in ->readdir Eric Biggers
2020-11-01 10:31 ` Greg KH
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).