* [PATCH] mkfs.f2fs: fix to calculate left space of checkpoint page correctly
@ 2015-12-14 10:06 Chao Yu
0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2015-12-14 10:06 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
We reserved one segment for NAT region at least, so when formatting
fs, calculated maximum size of left space in CP page should be:
CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64 (size of
reserved NAT bitmap).
Fix the incorrect calculated size to avoid potential overflow bug here.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
mkfs/f2fs_format.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index c4b17de..a2f33f9 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -220,7 +220,7 @@ static int f2fs_prepare_super_block(void)
* When sit is too large, we should expand cp area. It requires more pages for cp.
*/
if (max_sit_bitmap_size >
- (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 65)) {
+ (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64)) {
max_nat_bitmap_size = CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1;
set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size));
} else {
--
2.6.3
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-12-14 10:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-14 10:06 [PATCH] mkfs.f2fs: fix to calculate left space of checkpoint page correctly Chao Yu
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).