[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241227093251.344503-1-chenzhangqi79@163.com>
Date: Fri, 27 Dec 2024 17:32:51 +0800
From: chenzhangqi79@....com
To: chao@...nel.org
Cc: linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
Zhangqi Chen <chenzhangqi@...omi.com>,
Zhijun Li <lizhijun3@...omi.com>
Subject: [PATCH] f2fs: fix error map extent flag while block not allocated
From: Zhangqi Chen <chenzhangqi@...omi.com>
In the function f2fs_fiemap, when returning the file
map extent flag, the flag of the delayed allocation
block is set to FIEMAP_EXTENT_UNWRITTEN . At the same
time, the phy address of the file map extent reassigned
to 0 because it is not a valid address.
In this way, the file map extent with address 0 and
FIEMAP_EXTENT_UNWRITTEN flag returned by ioctl, and
may be used for writing by userspace programs, thereby
destroying the superblock of the file system.
As mentioned in /Documentation/filesystems/fiemap.txt,
FIEMAP_EXTENT_UNWRITTEN should mean that the block has
been allocated but not filled with data. However, the
actual situation in f2fs is that there is no allocated
block, so it should be changed to FIEMAP_EXTENT_UNKNOWN
and FIEMAP_EXTENT_DELALLOC.
Co-developed-by: Zhijun Li <lizhijun3@...omi.com>
Signed-off-by: Zhijun Li <lizhijun3@...omi.com>
Signed-off-by: Zhangqi Chen <chenzhangqi@...omi.com>
---
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 2ec0cfb41260..a945d1f1d40c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2023,7 +2023,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
size += F2FS_BLKSIZE;
}
} else if (map.m_flags & F2FS_MAP_DELALLOC) {
- flags = FIEMAP_EXTENT_UNWRITTEN;
+ flags = FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_DELALLOC;
}
start_blk += F2FS_BYTES_TO_BLK(size);
--
2.20.1
Powered by blists - more mailing lists