]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.123/block-sed-opal-fix-ioc_opal_enable_disable_mbr.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.123 / block-sed-opal-fix-ioc_opal_enable_disable_mbr.patch
CommitLineData
3d4ecfe4
SL
1From bf1a997c22a88b2c3b794c8f085ee1abfe73f2ab Mon Sep 17 00:00:00 2001
2From: David Kozub <zub@linux.fjfi.cvut.cz>
3Date: Thu, 14 Feb 2019 01:15:53 +0100
4Subject: block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR
5
6[ Upstream commit 78bf47353b0041865564deeed257a54f047c2fdc ]
7
8The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value
9opal_mbr_data.enable_disable incorrectly: enable_disable is expected
10to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable
11was passed directly to set_mbr_done and set_mbr_enable_disable where
12is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end
13result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE
14actually disabled the shadow MBR and vice versa.
15
16This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to
17OPAL_FALSE/TRUE. The change affects existing programs using
18IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when
19setting up an Opal drive.
20
21Acked-by: Jon Derrick <jonathan.derrick@intel.com>
22Reviewed-by: Christoph Hellwig <hch@lst.de>
23Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
24Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
25Signed-off-by: Jens Axboe <axboe@kernel.dk>
26Signed-off-by: Sasha Levin <sashal@kernel.org>
27---
28 block/sed-opal.c | 9 ++++++---
29 1 file changed, 6 insertions(+), 3 deletions(-)
30
31diff --git a/block/sed-opal.c b/block/sed-opal.c
32index 4f5e70d4abc3c..c64011cda9fcc 100644
33--- a/block/sed-opal.c
34+++ b/block/sed-opal.c
35@@ -2078,13 +2078,16 @@ static int opal_erase_locking_range(struct opal_dev *dev,
36 static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
37 struct opal_mbr_data *opal_mbr)
38 {
39+ u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ?
40+ OPAL_TRUE : OPAL_FALSE;
41+
42 const struct opal_step mbr_steps[] = {
43 { opal_discovery0, },
44 { start_admin1LSP_opal_session, &opal_mbr->key },
45- { set_mbr_done, &opal_mbr->enable_disable },
46+ { set_mbr_done, &enable_disable },
47 { end_opal_session, },
48 { start_admin1LSP_opal_session, &opal_mbr->key },
49- { set_mbr_enable_disable, &opal_mbr->enable_disable },
50+ { set_mbr_enable_disable, &enable_disable },
51 { end_opal_session, },
52 { NULL, }
53 };
54@@ -2204,7 +2207,7 @@ static int __opal_lock_unlock(struct opal_dev *dev,
55
56 static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
57 {
58- u8 mbr_done_tf = 1;
59+ u8 mbr_done_tf = OPAL_TRUE;
60 const struct opal_step mbrdone_step [] = {
61 { opal_discovery0, },
62 { start_admin1LSP_opal_session, key },
63--
642.20.1
65