All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <dkiper@net-space.pl>
To: Patrick Steinhardt <ps@pks.im>
Cc: grub-devel@gnu.org
Subject: Re: [PATCH] luks2: Improve error reporting when decrypting/verifying key
Date: Thu, 16 Apr 2020 14:57:14 +0200	[thread overview]
Message-ID: <20200416125714.pfpfas7zbsyebtrh@tomti.i.net-space.pl> (raw)
In-Reply-To: <20200416123610.GB277885@tanuki.pks.im>

On Thu, Apr 16, 2020 at 02:36:10PM +0200, Patrick Steinhardt wrote:
> On Thu, Apr 16, 2020 at 02:27:02PM +0200, Daniel Kiper wrote:
> > On Thu, Apr 16, 2020 at 12:19:55PM +0200, Patrick Steinhardt wrote:
> > > While we already set up error messages in both `luks2_verify_key()` and
> > > `luks2_decrypt_key()`, we do not ever print them. This makes it really
> > > hard to discover why a given key actually failed to decrypt a disk.
> > >
> > > Improve this by including the error message in the user-visible output.
> > >
> > > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > > ---
> > >  grub-core/disk/luks2.c | 8 +++++---
> > >  1 file changed, 5 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
> > > index 65c4f0aac..a48bddf5d 100644
> > > --- a/grub-core/disk/luks2.c
> > > +++ b/grub-core/disk/luks2.c
> > > @@ -487,7 +487,7 @@ luks2_decrypt_key (grub_uint8_t *out_key,
> > >    ret = grub_disk_read (disk, 0, k->area.offset, k->area.size, split_key);
> > >    if (ret)
> > >      {
> > > -      grub_dprintf ("luks2", "Read error: %s\n", grub_errmsg);
> > > +      grub_error (GRUB_ERR_IO, "Read error: %s\n", grub_errmsg);
> > >        goto err;
> > >      }
> >
> > AIUI the commit message says about this change but...
> >
> > > @@ -610,14 +610,16 @@ luks2_recover_key (grub_disk_t disk,
> > >  			       (const grub_uint8_t *) passphrase, grub_strlen (passphrase));
> > >        if (ret)
> > >  	{
> > > -	  grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" failed\n", i);
> > > +	  grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" failed: %s\n",
> > > +			i, grub_errmsg);
> > >  	  continue;
> > >  	}
> > >
> > >        ret = luks2_verify_key (&digest, candidate_key, keyslot.key_size);
> > >        if (ret)
> > >  	{
> > > -	  grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE"\n", i);
> > > +	  grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE": %s\n",
> > > +			i, grub_errmsg);
> > >  	  continue;
> >
> > ...it does not say anything about these changes. If you update commit
> > message you can add Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
> >
> > Daniel
>
> Does the following commit message clear things up?
>
>     luks2: Improve error reporting when recovering keys
>
>     While we already set up error messages in both `luks2_verify_key()` and
>     `luks2_decrypt_key()`, we do not ever print them in the calling function
>     `luks2_recover_key()`. This makes it really hard to discover why a given
>     key actually failed to decrypt a disk.
>
>     Improve this by including the error message in the user-visible output.
>     While at it, fix one error path in `luks2_decrypt_key()` that printed
>     the error directly instead of returning it.
>
>     Signed-off-by: Patrick Steinhardt <ps@pks.im>

Much better. However, after seeing this I think that this patch should
be split into two separate ones. If you do that and split the commit
message accordingly feel free to add Reviewed-by: Daniel Kiper
<daniel.kiper@oracle.com>.

Daniel


  reply	other threads:[~2020-04-16 12:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 10:19 [PATCH] luks2: Improve error reporting when decrypting/verifying key Patrick Steinhardt
2020-04-16 12:27 ` Daniel Kiper
2020-04-16 12:36   ` Patrick Steinhardt
2020-04-16 12:57     ` Daniel Kiper [this message]
2020-04-16 17:15 ` [PATCH v2 0/2] Improve LUKS2 error reporting Patrick Steinhardt
2020-04-16 17:15   ` [PATCH v2 1/2] luks2: Propagate error when reading area key fails Patrick Steinhardt
2020-04-16 17:15   ` [PATCH v2 2/2] luks2: Improve error reporting when recovering keys Patrick Steinhardt
2020-04-17 13:54   ` [PATCH v2 0/2] Improve LUKS2 error reporting Daniel Kiper
2020-05-30 10:16     ` Patrick Steinhardt

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=20200416125714.pfpfas7zbsyebtrh@tomti.i.net-space.pl \
    --to=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.