提交 8be9edec 编写于 作者: J Jaegeuk Kim 提交者: Zheng Zengkai

f2fs: should put a page beyond EOF when preparing a write

stable inclusion
from stable-5.10.67
commit bb8108546da97d7c66a8abe93af5ce04b68b509e
bugzilla: 182619 https://gitee.com/openeuler/kernel/issues/I4EWO7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bb8108546da97d7c66a8abe93af5ce04b68b509e

--------------------------------

[ Upstream commit 9605f75c ]

The prepare_compress_overwrite() gets/locks a page to prepare a read, and calls
f2fs_read_multi_pages() which checks EOF first. If there's any page beyond EOF,
we unlock the page and set cc->rpages[i] = NULL, which we can't put the page
anymore. This makes page leak, so let's fix by putting that page.

Fixes: a949dc5f ("f2fs: compress: fix race condition of overwrite vs truncate")
Reviewed-by: NChao Yu <chao@kernel.org>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1bb8ef3c
...@@ -2219,6 +2219,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, ...@@ -2219,6 +2219,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
continue; continue;
} }
unlock_page(page); unlock_page(page);
if (for_write)
put_page(page);
cc->rpages[i] = NULL; cc->rpages[i] = NULL;
cc->nr_rpages--; cc->nr_rpages--;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册