From patchwork Fri May 10 11:15:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10938659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B012B76 for ; Fri, 10 May 2019 11:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F71D28C74 for ; Fri, 10 May 2019 11:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9414628C76; Fri, 10 May 2019 11:16:11 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 4FDB228C74 for ; Fri, 10 May 2019 11:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbfEJLQH (ORCPT ); Fri, 10 May 2019 07:16:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:50570 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727261AbfEJLPy (ORCPT ); Fri, 10 May 2019 07:15:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4E5C4AF95 for ; Fri, 10 May 2019 11:15:52 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH 10/17] btrfs: check for supported superblock checksum type before checksum validation Date: Fri, 10 May 2019 13:15:40 +0200 Message-Id: <20190510111547.15310-11-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190510111547.15310-1-jthumshirn@suse.de> References: <20190510111547.15310-1-jthumshirn@suse.de> 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 Check for supported superblock checksum type before doing the actual checksum validation of the superblock read from disk. Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ab13282d91d2..74937effaed4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2822,6 +2822,14 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } + if (!btrfs_supported_super_csum((struct btrfs_super_block *) + bh->b_data)) { + btrfs_err(fs_info, "unsupported checksum algorithm"); + err = -EINVAL; + brelse(bh); + goto fail_alloc; + } + /* * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).