linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: Fix regression in sed-opal for a saved key.
@ 2023-10-03 10:02 Milan Broz
  2023-10-04 14:07 ` Milan Broz
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Milan Broz @ 2023-10-03 10:02 UTC (permalink / raw)
  To: linux-block
  Cc: gjoyce, jonathan.derrick, axboe, linux-kernel, Milan Broz,
	Ondrej Kozina

The commit 3bfeb61256643281ac4be5b8a57e9d9da3db4335
introduced the use of keyring for sed-opal.

Unfortunately, there is also a possibility to save
the Opal key used in opal_lock_unlock().

This patch switches the order of operation, so the cached
key is used instead of failure for opal_get_key.

The problem was found by the cryptsetup Opal test recently
added to the cryptsetup tree.

Fixes: 3bfeb6125664 ("block: sed-opal: keyring support for SED keys")
Tested-by: Ondrej Kozina <okozina@redhat.com>
Signed-off-by: Milan Broz <gmazyland@gmail.com>
---
 block/sed-opal.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/sed-opal.c b/block/sed-opal.c
index 6d7f25d1711b..04f38a3f5d95 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct opal_dev *dev,
 	if (lk_unlk->session.who > OPAL_USER9)
 		return -EINVAL;
 
-	ret = opal_get_key(dev, &lk_unlk->session.opal_key);
-	if (ret)
-		return ret;
 	mutex_lock(&dev->dev_lock);
 	opal_lock_check_for_saved_key(dev, lk_unlk);
-	ret = __opal_lock_unlock(dev, lk_unlk);
+	ret = opal_get_key(dev, &lk_unlk->session.opal_key);
+	if (!ret)
+		ret = __opal_lock_unlock(dev, lk_unlk);
 	mutex_unlock(&dev->dev_lock);
 
 	return ret;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-10-13 14:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 10:02 [PATCH] block: Fix regression in sed-opal for a saved key Milan Broz
2023-10-04 14:07 ` Milan Broz
2023-10-04 20:28 ` Jens Axboe
2023-10-04 20:54 ` Greg Joyce
2023-10-05  6:58   ` Milan Broz
2023-10-05 17:58     ` Greg Joyce
2023-10-11  8:30       ` Milan Broz
2023-10-13 14:17         ` Jens Axboe
2023-10-13 14:38           ` Linux regression tracking #update (Thorsten Leemhuis)
2023-10-13  9:39 ` Ondrej Kozina
2023-10-13 14:17 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).