Commit 9234f319 authored by Jan Kara's avatar Jan Kara Committed by Jaegeuk Kim
Browse files

f2fs: fix possible data corruption in f2fs_write_begin()

f2fs_write_begin() doesn't initialize the 'dn' variable if the inode has
inline data. However it uses its contents to decide whether it should
just zero out the page or load data to it. Thus if we are unlucky we can
zero out page contents instead of loading inline data into a page.

CC: Changman Lee <>
Signed-off-by: default avatarJan Kara <>
Signed-off-by: default avatarJaegeuk Kim <>
parent 2cc22186
......@@ -1017,21 +1017,19 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
goto out;
if (dn.data_blkaddr == NEW_ADDR) {
zero_user_segment(page, 0, PAGE_CACHE_SIZE);
} else {
if (f2fs_has_inline_data(inode)) {
err = f2fs_read_inline_data(inode, page);
if (err) {
goto fail;
} else if (dn.data_blkaddr == NEW_ADDR) {
zero_user_segment(page, 0, PAGE_CACHE_SIZE);
} else {
err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
if (err)
goto fail;
if (unlikely(!PageUptodate(page))) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment