Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9941708ybi; Wed, 24 Jul 2019 12:44:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB004j7KJygU1gIjCQdfNHKJNUup10DUDjgrnCl0KBiNonB03UVZE3m2Nap7s1MamUrFJO X-Received: by 2002:a17:902:20e9:: with SMTP id v38mr88404011plg.62.1563997464668; Wed, 24 Jul 2019 12:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997464; cv=none; d=google.com; s=arc-20160816; b=nRNjHjWMJLubB8Gwjdhe1sKh75nQX0vBsrW8l6Ybb7CWxa7tH0HEdwZA9IJqzjBA2G WdiMde7kk/SIsjnSzcK2D4tOcKsXH+/uWZsR7572cDyyaJYdmL5Onidl1DZnvxBbWwtC HFLDQx2XAIsjNTNPwy8ZLktzi2ImnYdIWmcLw7XpnJK1sW0bRi5dpYzrT0TT86tO1dg3 0yeDmHhtChECUCrH7bK6Qidozh4F0WIlLftCW8NawI2H4tbvpzH7501JK2Bu55kbuMNf Y5bMPd5nF0B002sisYxCrG12YOAEYxvPoHxiNZ/FlHaep+tjgCdxqru1ZVaVofl9UP+A Nv3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HARWxBEFvYSGyDewNDqFkRF98nTLyLltLExpZLe+lEI=; b=PUQlddmDHcNWvEE1ZgaCMBRiZVYsjlmYzoi8HOFMtjH0vGp0ZcLKvbrWvgwbmPmVld /TgaHOJ5WERH7TkHZilOwDFcD6PWFb2IsIeR8O4T6Q7QBb3NvBHV+DpRQ9j5KKhEPj84 c71VX9JNTkqukbFAR6/MD6aTCio8lTtS9IxO+KRSX/My+Q8YO4+3VHXE2Hfy11UoWSS3 9rdN3lEFt+xzRoT9qQzgKlRXbnX5OhrzymSTDDVa7C41kfspPnCFKiccjvilZ/IZ3L/l 89TM+GD9yQZcnaWLclvlmBVaW121SLtnbNhFV7mxF3Y5VVPzeyalPtpNsia+tuIiKqbA 5W2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ND+TGw9F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si14719840pfm.238.2019.07.24.12.44.09; Wed, 24 Jul 2019 12:44:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ND+TGw9F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390420AbfGXTmt (ORCPT + 99 others); Wed, 24 Jul 2019 15:42:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388240AbfGXTms (ORCPT ); Wed, 24 Jul 2019 15:42:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDC9D21873; Wed, 24 Jul 2019 19:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997367; bh=+lOX/j8rmFpbITJk8sqtfGSUAEVYNwcy0C/BvfZ8d78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ND+TGw9FdWgICiAupfV3+EuZwFdOH1czUw+Uk/AoiglPEZdfUYRWx34x/PJh7iIC9 b1qHq9XzvjwlSs5Y8hSpQgSkM890jgI4mhcVHsBJma1L6CYzhfr26//VpiXX7uc0Hp 1IwCl6wQF6/U1syPqI7WqOX46QZjMNVI4G0xXLnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zdenek Kabelac , Mike Snitzer Subject: [PATCH 5.2 412/413] dm thin metadata: check if in fail_io mode when setting needs_check Date: Wed, 24 Jul 2019 21:21:43 +0200 Message-Id: <20190724191803.972802548@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Snitzer commit 54fa16ee532705985e6c946da455856f18f63ee1 upstream. Check if in fail_io mode at start of dm_pool_metadata_set_needs_check(). Otherwise dm_pool_metadata_set_needs_check()'s superblock_lock() can crash in dm_bm_write_lock() while accessing the block manager object that was previously destroyed as part of a failed dm_pool_abort_metadata() that ultimately set fail_io to begin with. Also, update DMERR() message to more accurately describe superblock_lock() failure. Cc: stable@vger.kernel.org Reported-by: Zdenek Kabelac Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-thin-metadata.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -2046,16 +2046,19 @@ int dm_pool_register_metadata_threshold( int dm_pool_metadata_set_needs_check(struct dm_pool_metadata *pmd) { - int r; + int r = -EINVAL; struct dm_block *sblock; struct thin_disk_superblock *disk_super; pmd_write_lock(pmd); + if (pmd->fail_io) + goto out; + pmd->flags |= THIN_METADATA_NEEDS_CHECK_FLAG; r = superblock_lock(pmd, &sblock); if (r) { - DMERR("couldn't read superblock"); + DMERR("couldn't lock superblock"); goto out; }