From patchwork Sun Dec 10 01:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10103859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 953C160325 for ; Sun, 10 Dec 2017 01:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 814E828FFE for ; Sun, 10 Dec 2017 01:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74CB82907F; Sun, 10 Dec 2017 01:15:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53D5228FFE for ; Sun, 10 Dec 2017 01:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281AbdLJBON (ORCPT ); Sat, 9 Dec 2017 20:14:13 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:38638 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbdLJBOM (ORCPT ); Sat, 9 Dec 2017 20:14:12 -0500 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Sat, 09 Dec 2017 18:14:06 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, hadrian2002@googlemail.com Subject: [PATCH] btrfs: disk-io: Allow 0 as tree block bytenr Date: Sun, 10 Dec 2017 09:14:03 +0800 Message-Id: <20171210011403.14452-1-wqu@suse.com> X-Mailer: git-send-email 2.15.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some btrfs created by old mkfs.btrfs can have tree block with 0 bytenr. In fact, any aligned bytenr is allowed in btrfs, and in some case it can cause problem if the valid tree block at 0 bytenr can't be read. Currently, the superblock checker and bytenr alignment checker can already handle the case so there is no need to check bytenr < sectorsize in read_tree_block(). Reported-by: Benjamin Beichler Fixes: 6cca2ea9bea9 ("btrfs-progs: more sanity checks in read_tree_block_fs_info") Signed-off-by: Qu Wenruo --- disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-io.c b/disk-io.c index f5edc4796619..7f13f05ac600 100644 --- a/disk-io.c +++ b/disk-io.c @@ -318,7 +318,7 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, * Such unaligned tree block will free overlapping extent buffer, * causing use-after-free bugs for fuzzed images. */ - if (bytenr < sectorsize || !IS_ALIGNED(bytenr, sectorsize)) { + if (!IS_ALIGNED(bytenr, sectorsize)) { error("tree block bytenr %llu is not aligned to sectorsize %u", bytenr, sectorsize); return ERR_PTR(-EIO);