block: Fix regression in sed-opal for a saved key.
Subsystems (3)
PATCH 1/1 block: Fix regression in sed-opal for a saved key.
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.
--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
block/sed-opal.c +3 -4
@@ -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;
Signature · 1 line
2.42.0
Quoted 11 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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
Quoted 28 lines
Fixes 3bfeb6125664 ("block: sed-opal: keyring support for SED keys")Tested-by Ondrej Kozina <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +3
-4@@ -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;
Jens Axboe
maintainerQuoted 11 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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.
Signature · 1 line
Jens Axboe
Quoted 27 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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 <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +0
-0@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct opal_dev *dev, if (lk_unlk->session.who > OPAL_USER9) return -EINVAL;
block/sed-opal.c static int opal_lock_unlock(struct opal_dev · line 2896
Quoted 10 lines
block/sed-opal.c +3
-4- 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.
Quoted 3 lines
block/sed-opal.c +0
-0mutex_unlock (&dev->dev_lock);return ret;
Quoted 29 lines · Greg Joyce
Quoted 28 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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 <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +0
-0@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct opal_dev *dev, if (lk_unlk->session.who > OPAL_USER9) return -EINVAL;
Quoted 14 lines
block/sed-opal.c static int opal_lock_unlock(struct opal_dev *dev, · line 2895
Quoted 9 lines
block/sed-opal.c +3
-4- 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 ifopal_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
Quoted 5 lines
Quoted 4 lines
block/sed-opal.c +0
-0mutex_unlock (&dev->dev_lock);return ret;
Quoted 55 lines · Milan Broz
Quoted 31 lines · Greg Joyce
Quoted 30 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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 SEDkeys")
Tested-by Ondrej Kozina <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +0
-0@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct
opal_dev
*dev,
if (lk_unlk->session.who>OPAL_USER9)
return-EINVAL;Quoted 15 lines
block/sed-opal.c static int opal_lock_unlock(struct opal_dev *dev, · line 2895
Quoted 9 lines
block/sed-opal.c +3
-4- 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 ifopal_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 subsequentopal_get_key()does nothing, returning 0.
Quoted 9 lines
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
Quoted 6 lines
Milan
Quoted 3 lines
Quoted 3 lines
mutex_unlock(&dev->dev_lock);return ret;
Quoted 66 lines · Greg Joyce
Quoted 55 lines · Milan Broz
Quoted 31 lines · Greg Joyce
Quoted 30 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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 SEDkeys")
Tested-by Ondrej Kozina <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +0
-0@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct
opal_dev
*dev,
if (lk_unlk->session.who>OPAL_USER9)
return-EINVAL;Quoted 15 lines
block/sed-opal.c static int opal_lock_unlock(struct opal_dev *dev, · line 2895
Quoted 9 lines
block/sed-opal.c +3
-4- 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 ifopal_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 subsequentopal_get_key()does nothing, returning 0.Quoted 9 lines
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 :-)
Quoted 2 lines
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/[email protected]/
#regzbot ^introduced 3bfeb6125664
Thanks,
Milan
Jens Axboe
maintainerQuoted 71 lines · Milan Broz
Quoted 66 lines · Greg Joyce
Quoted 55 lines · Milan Broz
Quoted 31 lines · Greg Joyce
Quoted 30 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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 SEDkeys")
Tested-by Ondrej Kozina <[email protected]>Signed-off-by Milan Broz <[email protected]>--- block/sed-opal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)block/sed-opal.c +0
-0@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct
opal_dev
*dev,if (lk_unlk->session.who > OPAL_USER9) return -EINVAL;Quoted 15 lines
block/sed-opal.c static int opal_lock_unlock(struct opal_dev *dev, · line 2895
Quoted 9 lines
block/sed-opal.c +3
-4- 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 ifopal_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 subsequentopal_get_key()does nothing, returning 0.Quoted 9 lines
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 :-)Quoted 2 lines
Okay, if the key is such that
opal_get_key()always returns 0, then I agree there isn't an issue.
Quoted 7 lines
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/[email protected]/
#regzbot ^introduced3bfeb6125664
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.
Signature · 1 line
Jens Axboe
[TLDR: This mail in primarily relevant for Linux kernel regression tracking. See link in footer if these mails annoy you.]
Quoted 3 lines · Jens Axboe
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.
Hi Jens,
Quoted 1 line · Milan Broz
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.
Quoted 10 lines · Milan Broz
The commit
3bfeb61256643281ac4be5b8a57e9d9da3db4335introduced 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,
Signature · 1 line
Jens Axboe