From: Jens Axboe <axboe@kernel.dk>
To: Milan Broz <gmazyland@gmail.com>
Cc: jonathan.derrick@linux.dev, linux-kernel@vger.kernel.org,
Ondrej Kozina <okozina@redhat.com>,
regressions@lists.linux.dev, gjoyce@linux.vnet.ibm.com,
linux-block@vger.kernel.org
Subject: Re: [PATCH] block: Fix regression in sed-opal for a saved key.
Date: Fri, 13 Oct 2023 08:17:01 -0600 [thread overview]
Message-ID: <10b46003-2a75-49a7-8c74-cd8e3d4915c3@kernel.dk> (raw)
In-Reply-To: <acf5d5b5-b3d9-403d-ad57-a865774b260f@gmail.com>
On 10/11/23 2:30 AM, Milan Broz wrote:
> On 10/5/23 19:58, Greg Joyce wrote:
>> On Thu, 2023-10-05 at 08:58 +0200, Milan Broz wrote:
>>> On 10/4/23 22:54, Greg Joyce wrote:
>>>> On Tue, 2023-10-03 at 12:02 +0200, Milan Broz wrote:
>>>>> 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);
>>>>
>>>> This is relying on opal_get_key() returning 0 to decide if
>>>> __opal_lock_unlock() is called. Is this really what you want? It
>>>> seems
>>>> that you would want to unlock if the key is a LUKS key, even if
>>>> opal_get_key() returns non-zero.
>>>
>>> I think it is ok. That was logic introduced in your keyring patch
>>> anyway.
>>>
>>> I just fixed that if key is cached (stored in OPAL struct), that key
>>> is used
>>> and subsequent opal_get_key() does nothing, returning 0.
>>>
>>> The story is here that both OPAL lock and unlock need key, while LUKS
>>> logic never required key for lock (deactivation), so we rely on the
>>> cached
>>> OPAL key here. We do not need any key stored for unlocking (that is
>>> always
>>> decrypted from a keyslot)
>>> (I think requiring key for locking range is a design mistake in OPAL
>>> but
>>> that's not relevant for now :-)
>>
>> Okay, if the key is such that opal_get_key() always returns 0, then I
>> agree there isn't an issue.
>
>
> Jens, what's the status of this patch?
>
> It is clear regression in 6.6 (I forgot to add regression list, fixed now.)
>
> For reference, the original report and patch is here
> #regzbot link: https://lore.kernel.org/linux-block/20231003100209.380037-1-gmazyland@gmail.com/
> #regzbot ^introduced 3bfeb6125664
Was waiting on Greg to ack/review it, which it looks like he kind of
has. But would've been nice with a formal ack on it. I've queued it up
now.
--
Jens Axboe
next prev parent reply other threads:[~2023-10-13 14:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 10:02 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10b46003-2a75-49a7-8c74-cd8e3d4915c3@kernel.dk \
--to=axboe@kernel.dk \
--cc=gjoyce@linux.vnet.ibm.com \
--cc=gmazyland@gmail.com \
--cc=jonathan.derrick@linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=okozina@redhat.com \
--cc=regressions@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®