Commit Graph

2873 Commits (7f26e64ddd17e04c0d8d7ce5cffdc9d1dbdfadfc)
 

Author SHA1 Message Date
adduxa 7f26e64ddd btrfs-progs: docs: fix typos in btrfs-subvolume
[ Documentation fix, github pull request 16 ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:13 +02:00
Omar Sandoval 02a9b6cbef Revert "btrfs-progs: fix compat_ro mask for free space tree"
btrfs-progs can't mount space_cache=v2 filesystems read-write, which is
why the compat bit wasn't added to the supported mask in the first
place. Remove it.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:09 +02:00
David Sterba da64ae3a0f btrfs-progs: reorganize extent_buffer and fix alignment of data
Reported by UBSAN, the checksum code tries to access unaligned data that
come from the extent_buffer.

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u32                        len;                  /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        struct extent_io_tree *    tree;                 /*    72     8 */
        struct list_head           lru;                  /*    80    16 */
        struct list_head           recow;                /*    96    16 */
        int                        refs;                 /*   112     4 */
        u32                        flags;                /*   116     4 */
        int                        fd;                   /*   120     4 */
        char                       data[0];              /*   124     0 */

        /* size: 128, cachelines: 2, members: 11 */
        /* sum members: 120, holes: 1, sum holes: 4 */
        /* padding: 4 */
};

Add explicit alignment to data.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156471
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:05 +02:00
Wang Xiaoguang f9309584bf btrfs-progs: tests: add 021-partially-dropped-snapshot-case
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:01 +02:00
Wang Xiaoguang ac80fca06c btrfs-progs: check: make low memory mode support partially dropped snapshots
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:49:57 +02:00
David Sterba 3f100c5251 btrfs-progs: better error report in btrfs_scan_fs_devices
Print the found sizes.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:49:48 +02:00
David Sterba 2125a65533 btrfs-progs: tests: add fuzzed images for bad block group offset
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:49:41 +02:00
Jeff Mahoney 70c3306d38 btrfs-progs: avoid looping forever when a bad blockgroup key is found
If we discover a bad BLOCK_GROUP_ITEM_KEY with offset = 0, we'll end up looping
forever when we read the block groups in.  This is due to the search for the
next block group starting at the current object + the offset.  If offset is 0,
we'll just get the same key over and over and never advance.  This patch
ensures that we'll advance at least one objectid per iteration.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:49:36 +02:00
David Sterba db7b7cd95f btrfs-progs: remove stray newline from message in check_super
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:48 +02:00
David Sterba 5150103fcf btrfs-progs: tests: run check with various options on the fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:41 +02:00
David Sterba faaeee5bf3 btrfs-progs: tests: add fuzz test to try btrfs-image on all images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:37 +02:00
David Sterba 9fc5aefe45 btrfs-progs: tests: rename test 001 to mention check
Make it more clear that the test does 'btrfs check'.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:24 +02:00
David Sterba 05b6d8b187 btrfs-progs: tests: add fuzzed image for a bad backref
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:16 +02:00
David Sterba 253cd12f41 btrfs-progs: tree-stats: check and report mount status
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:55 +02:00
David Sterba 67786272ea btrfs-progs: docs: update flushoncommit default value
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:38 +02:00
Qu Wenruo f04db96f61 btrfs-progs: docs: Add warning for build RAID btrfs on partions from the same device
Quite a common sense for any RAID-like multi-device setup, just in case.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:35 +02:00
Qu Wenruo 53c4e289c2 btrfs-progs: mkfs: Warn user for minimal RAID5/6 devices setup
For RAID5, 2 devices setup is just RAID1 with more overhead.
For RAID6, 3 devices setup is RAID1 with 3 copies, not what most user
want.

So warn user at mkfs time for such case, and add explain in man pages.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:31 +02:00
Lakshmipathi.G c2f3212502 btrfs-progs: tests: post btrfs-convert verify permissions and ACLs
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:24 +02:00
David Sterba 9cc6e92972 btrfs-progs: build: add UBSAN to debugging features
usage: make D=ubsan

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:46:47 +02:00
David Sterba a5bd848719 btrfs-progs: dump-super: changes in options to specify superblocks
Some tools (check, select-super, dump-super) can use the alternate
superblocks, but the options are not consistent. To make it less
confusing, change the meaning of option -s in 'dump-super' to specify
the superblock copy, instead of taking the offset.

Though this is a change in UI, the old usage is detected and the result
would be the same, no breakage in existing scripts.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:46:33 +02:00
David Sterba bde687343b
Btrfs progs v4.7.2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:21:24 +02:00
David Sterba 8a1f48df02 btrfs-progs: update CHANGES for 4.7.2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 50882c447d Revert "btrfs-progs: check: supplement extent backref list with rbtree"
This reverts commit 31d8235410.

False report of backref mismatches, lots of messages similar to:

Incorrect local backref count on 12713984 root 5 owner 257 offset 12845056 found 1 wanted 0 back 0x7b3ed0
backpointer mismatch on [12713984 131072]

Repairing will make things worse. A fix has been proposed, but is not
finalized so we go with a revert.

Reported-by: Chris Murphy <bugzilla@colorremedies.com>
References: https://bugzilla.kernel.org/show_bug.cgi?id=155791
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba b1c0235e11 Revert "btrfs-progs: check: switch to iterating over the backref_tree"
This reverts commit bbebe814c0.
2016-09-05 12:20:24 +02:00
David Sterba 857e55ab02 btrfs-progs: build: add ASAN to debugging features
usage: make D=asan

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 7d6307dcf3 btrfs-progs: tests: add fuzzed image for heap overflow while checking chunk items
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 386cdcd741 btrfs-progs: tests: add fuzzed image for invalid chunk sectorsize
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 083721de5c btrfs-progs: tests: add fuzzed image for invalid sys_array and stripe_len
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 1e4ef75053 btrfs-progs: tests: add fuzzed image for invalid sub_stripe value
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 7903166d94 btrfs-progs: image: more verbose syntax erors for -t and -c
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 57d1cbd867 btrfs-progs: print help test to stdout
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba f919530b3a btrfs-progs: tests: add 015-dump-super-garbage
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:23 +02:00
David Sterba ee7bb45ddc btrfs-progs: dump-super: detect invalid checksum type
The helper btrfs_super_csum_size unconditionally bugs on a bogus value,
the dump-super is supposed to dump even corrupted superblocks so this
must not happen here. Group the checsum values in the output and be more
robust agains garbage values.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:38 +02:00
David Sterba df96f8244d btrfs-progs: drop permission arg from non-creating open
The permissions do not make sense without O_CREATE mode.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:35 +02:00
David Sterba 51d41fac76 btrfs-progs: docs: describe filesystem features
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:30 +02:00
Jeff Mahoney 752d8fda32 btrfs-progs: build: only install udev rules for udev >= 190
Prior to udev v190, there was no btrfs builtin helper.  Installing it on
systems with an older udev will cause problems.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:26 +02:00
David Sterba aa6baa178d btrfs-progs: tests README: fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:08 +02:00
Qu Wenruo 8607100a9b btrfs-progs: fuzz-test: Add test case for unaligned extent item
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:05 +02:00
Qu Wenruo 9a0f2f1e53 btrfs-progs: fsck: Avoid abort and BUG_ON in add_tree_backref
Add_tree_backref() can cause BUG_ON() and abort() in quite a lot of
cases, from the ENOMEM to existing tree backref records.

Change all these BUG_ON() and abort() to return proper values.
And modify all callers to handle such problems.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:01 +02:00
Qu Wenruo 77deae9cb7 btrfs-progs: fsck: Check bytenr alignment for extent item
Check bytenr alignment for extent item to filter invalid items early.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:40 +02:00
Qu Wenruo f51a34696b btrfs-progs: fuzz-test: Add test case for invalid drop level
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:36 +02:00
Qu Wenruo 0d2c2d4809 btrfs-progs: fsck: Check drop level before walking through fs tree
Exposed by fuzzed image from Lukas, which contains invalid drop level
(16), causing segfault when accessing path->nodes[drop_level].

This patch will check drop level against fs tree level and
BTRFS_MAX_LEVEL to avoid such problem.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:32 +02:00
Qu Wenruo ba23b7679f btrfs-progs: fuzz-test: Add image for unaligned tree block ptr
Add test case image for unaligned tree block ptr.
It should lead to BUG_ON in free_extent_buffer().

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:27 +02:00
Qu Wenruo 245cf06dfa btrfs-progs: check: do early check for read_tree_block
Although we have enhanced read_tree_block() from a lot of different
aspects, it lacks the early bytenr/blocksize alignment check.

And the lack of such check can lead to strange use-after-free bugs, due
to the fact that alloc_extent_buffer() will free overlapping extent
buffers, and allocate new eb for the usage.

So we should not allow invalid bytenr/blocksize even passed to
btrfs_find_create_tree_block().

This patch will add such check so we won't trigger use-after-free bug
then.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:24 +02:00
Qu Wenruo 767ae9e348 btrfs-progs: fuzz-test: Add image for wrong chunk item in root tree
Reported by Lukas and the same image from him.

DATA_RELOC tree's key type is modifed to CHUNK_ITEM, causing btrfsck
interpret it as CHUNK_ITEM and cause 0 num_stripes.

Add the image to fuzz-test.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:19 +02:00
Qu Wenruo 2f242115d1 btrfs-progs: Do extra chunk check before processing chunk item
Current we only do chunk validation check at mount time.

It's good for most case, but for fuzzed or manually crafted images, we
can insert a CHUNK_ITEM key into root tree.

Since mount time check will only check chunk tree, it will not check
CHUNK_ITEM in root tree.

Even with previous key type check against leaf owner, it is still
possible to modify the leaf owner to by-pass it.

So we still need to check chunk validation before processing it.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:16 +02:00
Qu Wenruo f1934f4c78 btrfs-progs: check: ignore invalid key in invalid root
Btrfs tree implies a lot of restriction on which key types are allowed
in specific roots.

Like CHUNK_ITEM keys are only valid in chunk root.

This patch will add such check at run_next_block() for original mode.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:13 +02:00
Qu Wenruo 00045ff485 btrfs-progs: Enhance and export print_key_type function
Just the same thing done for print_objectid().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:07 +02:00
Qu Wenruo 7aafabd2b8 btrfs-progs: Enhance and export print_objectid function
This function is quite useful for a lot of error report.
Enhance it to support custom output other than stdout.
And export it for later btrfsck enhancement.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:04 +02:00
David Sterba 6819fbcdca
Btrfs progs v4.7.1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-25 19:33:48 +02:00