Message ID | 20231003100209.380037-1-gmazyland@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1972301vqb; Tue, 3 Oct 2023 03:02:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESlog6TY62hwBY9uRHftsNH+XWQDIh5AC4MP8z4f5P4ymHooDspj8ws1CAl4WDRz62THVr X-Received: by 2002:a05:6870:4723:b0:1dc:9714:e2b3 with SMTP id b35-20020a056870472300b001dc9714e2b3mr17316364oaq.7.1696327356030; Tue, 03 Oct 2023 03:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696327355; cv=none; d=google.com; s=arc-20160816; b=d84HrI6QOyTkJ2s/Uq9H6pEKl2xE0mXCnl/4NQ2VvXo+0q9sUPXa9mA/gZIpkg/H/j QH/P5CYlyKO73qOpUYNU8kdGrk+5LRr7B+u9/rGZAlO8ZGGmeAwGDlFCAS4GW0le1gTK Ub7VTxpcSeAxTrswNGhJZUjt27p7LPgHOkWnZ4yRwGitNgkrtqR+5FbRo5kdFwYNqX8P oBWmrc6L9TAKclaKt3mjMVLEy9oZpoj5quYSuWvP0q2nA41WxpGUrXe94PWUXu/vVJRL 1rmBwvdDLkZdkBikfiQ6f9r66uoR41DBDRKHS6mxPzFEmKbei7OWDj44QtLLTQitedZV f39A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0D9ErtnzA2GpIpQYRTV/PEhl9qcHXadLDJ8uRkyriWg=; fh=aWCOBBtuQlyA/CZs9XelPuihwauvedRX/YQ+q2tyN20=; b=EyUVBe563LGxfXxHWYirYZo2fuERq3qqKKpKs4tqWr5NtRwg/aey4msYxUHtw3e/eu k/LbDmZjplqLhLahowEcnPiHe+P0Fd2gWJ/2thXw63S0lIko5AWhHoXRtMHTp6dVHe6b A29RUCdMoQ0ahnqhqhp8zwbIu9G8aGuzlEKDOLAr51CjE/4nZLOWeRO2xs6tTkgm8vGh ApLnawAAWbd6ktlIDh1kAUcD+Deyu3M7ppFLc7D4i9wU4O1RwNEsYa/OYtbxAADe7eJl ww2f/+e4pZM3vzRQV9iB8VvDt0Fr4lh7PwSokONkI8tWHaC1+9Vh3SqOVdsXQ3hIwgg6 PZvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="c7/VYGxg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h128-20020a636c86000000b00573ff14b9e0si1030565pgc.763.2023.10.03.03.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 03:02:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="c7/VYGxg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D6F36815D7D9; Tue, 3 Oct 2023 03:02:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239820AbjJCKCe (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Tue, 3 Oct 2023 06:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjJCKCd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Oct 2023 06:02:33 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66A191; Tue, 3 Oct 2023 03:02:30 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-533c8f8f91dso1139507a12.0; Tue, 03 Oct 2023 03:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696327349; x=1696932149; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0D9ErtnzA2GpIpQYRTV/PEhl9qcHXadLDJ8uRkyriWg=; b=c7/VYGxgZ0CqBogVAf9FH8yWKciLCMyxiT1iAy2uaE/2n7pmYp6pKvY8WGaQhxHY6k 3TMHbTaKDiDYEZ/EgxWsmWgVorfWrWsWgye3DCh1T+gp0P3rPdd/rTVNj88IAra21Hx1 Qf8cROXy3nEi3/QK5DGNNDyKOvR3QuIJc7aD7sBy8Hhz/ic+0RyLxgFVOxGTGtdN0nFd mT4YjS5c9MSJlsw732OURb3Rne5f6DtfVE0E9oPjKd40a2oeIv1EVw0TtDKgddN0Vxud xxU0Cqbz0l2AjrzkwXT/g+4oJfpfdXxEUZCTxP8z7PgUa1Y8QR95M3XFotco9uZ2P8cK B2gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696327349; x=1696932149; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0D9ErtnzA2GpIpQYRTV/PEhl9qcHXadLDJ8uRkyriWg=; b=wHXu4Lbr+n9+4HnI2QObbs+D7ojWx6V6r0hhKvLLgvXf02FvrsgsF7ljO2PL/osgEG Jyx35vWGSVgC4u6ZcOxGfSsEIxA+RkSkeH7ly/QAb2BwJySJCf5migN3+iJMc17tRCYQ yn6TeTCT1FMQ3S1UGOCMu07YEb2opSqFUtxjFcRhJcLfuuSdgCq8WfHGpsotT91m0Sl2 9dKMRtCn0CiaBvG6h36OyRbEvwYPPyDbECPatCagRFlfX/cmDb6098IPUpuLtbcoYKCA p5ZME9x6XDidXhbfC8BOpLOtNmGeajLQ5i1Ue1prMdPNmKw0zSF+ms5xyVZbQpPy6Bc0 +YgQ== X-Gm-Message-State: AOJu0Yz6A2MOWFG2BSUuUiOCmjVlqixloTh9G9mMFfpKIyHhvqCgmHoU 9Uh7TVkmpVj8Q7CWZq0l1XdLQno2/ws= X-Received: by 2002:a05:6402:1257:b0:530:77e6:849f with SMTP id l23-20020a056402125700b0053077e6849fmr12709177edw.27.1696327348717; Tue, 03 Oct 2023 03:02:28 -0700 (PDT) Received: from sauvignon.fi.muni.cz (laomedon.fi.muni.cz. [147.251.42.107]) by smtp.gmail.com with ESMTPSA id s7-20020aa7c547000000b0052595b17fd4sm607137edr.26.2023.10.03.03.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 03:02:28 -0700 (PDT) From: Milan Broz <gmazyland@gmail.com> To: linux-block@vger.kernel.org Cc: gjoyce@linux.vnet.ibm.com, jonathan.derrick@linux.dev, axboe@kernel.dk, linux-kernel@vger.kernel.org, Milan Broz <gmazyland@gmail.com>, Ondrej Kozina <okozina@redhat.com> Subject: [PATCH] block: Fix regression in sed-opal for a saved key. Date: Tue, 3 Oct 2023 12:02:09 +0200 Message-ID: <20231003100209.380037-1-gmazyland@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 03:02:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778728153753540434 X-GMAIL-MSGID: 1778728153753540434 |
Series |
block: Fix regression in sed-opal for a saved key.
|
|
Commit Message
Milan Broz
Oct. 3, 2023, 10:02 a.m. UTC
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(-)
Comments
On 10/3/23 12:02, 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. Just forgot to mention - this is regression in 6.6-rc, breaking our OPAL cryptsetup support, so I think this should go into next 6.6 rc. Stable versions are ok, only 6.6-rc is affected currently. Milan > > 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;
On 10/3/23 4:02 AM, 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. Greg, please review this.
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. > mutex_unlock(&dev->dev_lock); > > return ret;
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 :-) Milan > >> mutex_unlock(&dev->dev_lock); >> >> return ret; >
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. Greg > > Milan > > > > mutex_unlock(&dev->dev_lock); > > > > > > return ret;
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 Thanks, Milan
Hi Jens,
On 03/10/2023 12:02, Milan Broz wrote:
> Fixes: 3bfeb6125664 ("block: sed-opal: keyring support for SED keys")
could we please get this in 6.6 in time for final release? This
regression blocks cryptsetup from correctly locking sed-opal locaking
range when device needs to be deactivated.
Is there anything that needs to be done for it to get it in 6.6?
Thank you
O.
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.
On Tue, 03 Oct 2023 12:02:09 +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. > > [...] Applied, thanks! [1/1] block: Fix regression in sed-opal for a saved key. commit: 4eaf0932c69bdc56d2c2af30404f9c918b1f6295 Best regards,
Linux regression tracking (Thorsten Leemhuis)
Oct. 13, 2023, 2:38 p.m. UTC |
#10
Addressed
Unaddressed
[TLDR: This mail in primarily relevant for Linux kernel regression tracking. See link in footer if these mails annoy you.] On 13.10.23 16:17, Jens Axboe wrote: > 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. #regzbot fix: block: Fix regression in sed-opal for a saved key. #regzbot ignore-activity Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) -- Everything you wanna know about Linux kernel regression tracking: https://linux-regtracking.leemhuis.info/about/#tldr That page also explains what to do if mails like this annoy you.
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;