From 61d6ed4fe7eff80033562380df536351b7ad6e66 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 15 Dec 2015 10:04:01 +0800 Subject: btrfs-progs: Enhance chunk validation check Enhance chunk validation: 1) Num_stripes We already have such check but it's only in super block sys chunk array. Now check all on-disk chunks. 2) Chunk logical It should be aligned to sector size. This behavior should be *DOUBLE CHECKED* for 64K sector size like PPC64 or AArch64. Maybe we can found some hidden bugs. 3) Chunk length Same as chunk logical, should be aligned to sector size. 4) Stripe length It should be power of 2. 5) Chunk type Any bit out of TYPE_MAS | PROFILE_MASK is invalid. With all these much restrict rules, several fuzzed image reported in mail list should no longer cause btrfsck error. Reported-by: Vegard Nossum Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- disk-io.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'disk-io.c') diff --git a/disk-io.c b/disk-io.c index 7a63b91..83bdb27 100644 --- a/disk-io.c +++ b/disk-io.c @@ -40,8 +40,6 @@ #define BTRFS_BAD_LEVEL (-3) #define BTRFS_BAD_NRITEMS (-4) -#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) - /* Calculate max possible nritems for a leaf/node */ static u32 max_nritems(u8 level, u32 nodesize) { -- cgit v1.2.1