Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp262080ybi; Wed, 29 May 2019 20:54:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/gulkM+2gcNzcO4W46cVGBsshRNSVjQoEXInd4sg8YzUL3A3PuwBWZNZLeXe6MtqpW2tf X-Received: by 2002:a17:902:8b8b:: with SMTP id ay11mr1771738plb.63.1559188476638; Wed, 29 May 2019 20:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188476; cv=none; d=google.com; s=arc-20160816; b=046IzUKUmyKcf3oFiam4BtMDXVZ89ziqDTGIVzEgbooG/Z9P4Zu4ez4QYeE2LIWGma 6qLPuP+esunciJDSMU0UdzK3RzIUgmyhCmta7zgDZWBRH7d7ppwsmdcqEAkt3HqK+FQ9 3wF0W/zkjVwQLrlRiYPlfGkYvvzHFLk1bScdJS27TMorPwyDiYLpQU7t7FCULhOWq4v2 eE53DrB77m27FbRov/o+iICRx5A+So8gZBT1VHVPV3eUtGvtUHPtEZGs7+jvA8cCpqvt a60rGqlHoUyTiq7pacGSrqS4zNJJx99YlDHmqWjpPIgcF0O5s0QTZtGlWDOOmlwbbalN SGog== 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=63d/RN7FffWzeytOa4WMoHzb1U3baENTyVExrV1u3sw=; b=yatVbKf8EVjjAIGMJKf53aTEl3Bbq0D7i2BVxQDq7T5YnWlegf1GYaju2wb/P3U+DM s6GQaWNM5n05IN2nzV0ZmvhY3auIFdODRCrXdGt+Ayy5S29potfwaVH34aS4wEttEGBR BS/mElSs3QtqH5gzy1LP/6TRs2G7eITXn1pWaTvvE9u80KZWx/18D00eK2JPqfue7Exq l0mceb5SJ2e8YtyW0dytR4tAuL/qOgxOJtjA64MGj9J3uCekRafkDVIJIeH8QeP1Aahv lz2BpwHvT/S2Xxks1NL4A26U3oAj5jI5k+fbbymG9i8+07i24To+mb7IgbE0SAdGvf4Q B6jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HP00cNMb; 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 n12si1873472plp.114.2019.05.29.20.54.21; Wed, 29 May 2019 20:54:36 -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=HP00cNMb; 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 S1733201AbfE3Dwi (ORCPT + 99 others); Wed, 29 May 2019 23:52:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731942AbfE3DTf (ORCPT ); Wed, 29 May 2019 23:19:35 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 C61DA248AB; Thu, 30 May 2019 03:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186374; bh=s6FEYyvu1TbYUCnhqVfPKx0CXV4TC8zXgKIEs96uMy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HP00cNMbwwhN7sOibAqJUybGwSDy1BiTL7Y1k0EMwc9porAV1lVmppBdLo1+UVP1s absKv86rFbo8u4PRuxvpOK7t2wdxCemVXhYEEkQbXqJ47ZSZwS7dHn2GM9y3/Dv/t3 LQZ4UxBEAreOfiRcaRcgCoIq3U0b8GCz+lAMKvOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Derrick , Christoph Hellwig , Scott Bauer , David Kozub , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 134/193] block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR Date: Wed, 29 May 2019 20:06:28 -0700 Message-Id: <20190530030507.068785313@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 [ Upstream commit 78bf47353b0041865564deeed257a54f047c2fdc ] The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value opal_mbr_data.enable_disable incorrectly: enable_disable is expected to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable was passed directly to set_mbr_done and set_mbr_enable_disable where is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE actually disabled the shadow MBR and vice versa. This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to OPAL_FALSE/TRUE. The change affects existing programs using IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when setting up an Opal drive. Acked-by: Jon Derrick Reviewed-by: Christoph Hellwig Reviewed-by: Scott Bauer Signed-off-by: David Kozub Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/sed-opal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 4f5e70d4abc3c..c64011cda9fcc 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -2078,13 +2078,16 @@ static int opal_erase_locking_range(struct opal_dev *dev, static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, struct opal_mbr_data *opal_mbr) { + u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ? + OPAL_TRUE : OPAL_FALSE; + const struct opal_step mbr_steps[] = { { opal_discovery0, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_done, &opal_mbr->enable_disable }, + { set_mbr_done, &enable_disable }, { end_opal_session, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_enable_disable, &opal_mbr->enable_disable }, + { set_mbr_enable_disable, &enable_disable }, { end_opal_session, }, { NULL, } }; @@ -2204,7 +2207,7 @@ static int __opal_lock_unlock(struct opal_dev *dev, static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key) { - u8 mbr_done_tf = 1; + u8 mbr_done_tf = OPAL_TRUE; const struct opal_step mbrdone_step [] = { { opal_discovery0, }, { start_admin1LSP_opal_session, key }, -- 2.20.1