cp_payload is not sanity checked from input image. A invalid size
can cause buffer overflow when reading checkpoint blks into memory.
Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
crafted malicious f2fs partition can fill an out of bound blk_off,
which cause overflow when accessing summary block entries.
Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We must guarantee that current segments should be different between different
logs.
This should resolve xfstests/generic/015 panic.
Fixes: 8f9327c0c0 ("mkfs.f2fs: use noheap by default")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
make sure segment count in super block doesn't exceed F2FS_MAX_SEGMENT.
Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
blk_off is read from image. Attacker can construct an image with big
blk_off that trigger overflow on se->cur_valid_map.
Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Libraries are built in builddir, not srcdir, fix Makefile.am
accordingly.
Signed-off-by: Yong, Jonathan <jonathan.yong@intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
For multiple devices, the c.start_sector will be overwrite by the non-root devices.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
It seems the new created directory always includes inline dentries,
let sload.f2fs supporting it.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The dir_level in the filesystem maybe larger than zero,
supports it.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
An encrypted directory under an unencrypted directory, the filename isn't encrypted.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The following messages is better than before.
Before,
# fsck.f2fs -d 1
Error: Need argument for -d
Now,
# fsck.f2fs -d 1
Info: Debug level = 1
Error: Device not specified
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Showing directory tree reuses dbg_lv that if setting "-t",
fsck.f2fs does not show any others.
Users may want much information include the debug info and directory tree.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
It's migrated from e4crypt.
Adds an example to the f2fscrypt manpages.
v3, add /tools/f2fscrypt to .gitignore
v2, migrate those micro defines for encrypt to f2fs internal,
drop unless of libsha etc.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The crc_offset towards or beyond the end of block is wrong,
sanity check it.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch fix a resize faill for sector size mismatch.
The initial fs comes from an image file, with sector size
512KB, and the block device sector size is equal to block
size.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Mkfs.f2fs doesn't check the overwrite of exist filesystem.
Avoid formatting an exist filesystem by mistake, a notice is important.
The code is modified from xfsprogs.
v3, add the missing update of SYNOPSIS
v2, add the manpages description of -f.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Add some missing options in manpages, also order those options.
v3, add the missing update of SYNOPSIS
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
memset(raw_node, 0, F2FS_BLKSIZE) sets the next_blkaddr to zero,
so that, only one reset dnode is cleaned always.
Fixes: ad042d9194 "mkfs.f2fs: reset dnode with zeros",
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The using of c.overprovision when it equal zero as,
c.reserved_segments =
(2 * (100 / c.overprovision + 1) + 6)
* c.segs_per_sec;
may cause problem, although it doesn't happen.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
resize.f2fs rebuilds a new checkpoint at the new position. Its
checkpoint_ver should be increased.
Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Signed-off-by: Weichao Guo <guoweichao@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This release includes:
- enhance fsck.f2fs mostly.
- retrieve lost files from dump.f2fs.
- support zoned device and multiple devices.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
wanted_total_sectors is introduced instead total_sectors,
so that, the initialize is a fault, drop it.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch removes stale dentries remained by hash conversion issue which
happened long time ago.
Fixes: aafe2ca3dc ("fsck.f2fs: fix wrong hash_code made by previous buggy code")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If the segment type and sum footer type are node, but its
sit type is corrupted as cold data, this will always trigger
type error crash in do_garbage_collect but not get fixed by fsck,
so fix seg entry type when it is not DATA.
Reported-by: KARBOWSKI Piotr <piotr.karbowski@gmail.com>
Signed-off-by: Liu Xue <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch allows fsck run -p without argument. So we could use -p as
-p, -p 0, -p 1. '-p' and '-p 0' have the same meaning as '-a'. '-p 1'
check more meta data than '-a'.
Reported-by: KARBOWSKI Piotr <piotr.karbowski@gmail.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
It is reported that fsck.f2fs behaves abnormally when running on MIPS32
rel 2 big endian cpu, since incorrect endianness. So let's correct all
endianess issues of f2fs-tools.
Reported-by: <k@vodka.home.kg>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
./configure --without-selinux :: unconditionally disable SELinux support
./configure --with-selinux :: enable SELinux support and abort if
libselinux is not found
When no configure option is specified the current libselinux
autodetection behaviour is preserved.
Signed-off-by: Sergey Kvachonok <ravenexp@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We should not check the consistency between i_name and its dentry for directory.
The i_name is used only for normal file recovery when conducting roll-forward
recovery.
Moreover, this condition was totally missing encryption case which is breaking by
1. encrypt ./test
2. mkdir ./test/a
3. mkdir ./test/b
4. rename ./test/a ./test/b
-> fsck.f2fs reports wrong inconsistency in terms of i_name.
Reported-by: liushuoran <liushuoran@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch remove unused parameters in these three functions:
get_new_sb, migrate_main and rebuild_superblock
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If the offset passed in migrate_ssa is not zero, it means that there're
offset segments of old main will disappear after migrating, then there're
offset blocks of old ssa should be invalidated and removed accordingly.
So, the number of moved ssa blocks should be: TOTAL_SEGS(sbi) - offset,
and the expanded summary, which is filled with zero_blocks, should start
from: new_sum_blkaddr + TOTAL_SEGS(sbi) - offset.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We should avoid zero overprovision ratio or # of segments caused by too small
device.
Reported-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Flush curseg sit entries, since type of sit entries may
be changed after move_curseg_info.
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch add a simple check orphan inodes in -p 1 mode
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch adds an option to specify multiple devices for an f2fs instance.
Up to 7 devices in addition to the default device can be added.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Refactor build_nat_area_bitmap, move out lookup_nat_in_journal from the
dual loops. Instead of looking up all nids in journals, we traverse nat
journals, whose entries are used to replace the NAT entries with the
corresponding nid to reduce the time build_nat_area_bitmap costs.
For "fsck -p 1", it reduces over half of the time.
Empty Fragmented Entirely
32G(ms):
original 625.8 727.3
improved 226.3 298.2
64G(ms):
original 1159 1637.7
improved 515.8 676.7
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch add a judgment after calloc avoid memory alloc
failure
Signed-off-by: Yunlei He <heyunlei@huawei.com>
[Jaegeuk Kim: remove unneeded memset to avoid build warning]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>