All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: grub-devel@gnu.org
Cc: Daniel Kiper <dkiper@net-space.pl>,
	Glenn Washburn <development@efficientek.com>,
	Nicholas Vinson <nvinson234@gmail.com>
Subject: [PATCH v6 0/2] luks2: Fix decoding of digests and salts with escaped chars
Date: Mon, 15 Aug 2022 17:52:45 +0200	[thread overview]
Message-ID: <cover.1660578567.git.ps@pks.im> (raw)

[-- Attachment #1: Type: text/plain, Size: 2705 bytes --]

Hi,

this is the sixth version of my patch series which fixes decoding of
digests and salts in LUKS2 headers in case they happen to contain
escaped characters. While modern cryptsetup versions in fact don't
escape any characters part of the Base64 alphabet, old versions of
cryptsetup did this until v2.0.2.

There's only a single change compared to v5, which is a removed type
cast that was not in fact needed. I didn't include the feedback from
Nicholas to make the JSON string parsing more lenient. While sensible,
it's rather a theoretical concern right now as theer was only a single
version of cryptsetup that ever wrote escaped characters, and even then
of the Base64 alphabet only the backslash may have been escaped. So I
think we should rather defer any improvements until there we discover
real-world problems or until there are more usecases for this function.

Patrick

Patrick Steinhardt (2):
  json: Add function to unescape JSON-encoded strings
  luks2: Fix decoding of digests and salts with escaped chars

 grub-core/disk/luks2.c    |  28 +++++++--
 grub-core/lib/json/json.c | 118 ++++++++++++++++++++++++++++++++++++++
 grub-core/lib/json/json.h |  12 ++++
 3 files changed, 154 insertions(+), 4 deletions(-)

Range-diff against v5:
1:  ebab6b092 ! 1:  c44675566 json: Add function to unescape JSON-encoded strings
    @@ Commit message
         Add a new function `grub_json_unescape ()` that takes a potentially
         escaped JSON string as input and returns a new unescaped string.
     
    +    Reviewed-by: Daniel Kiper <dkiper@net-space.pl>
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
      ## grub-core/lib/json/json.c ##
2:  60ccd669d ! 2:  16ae4ef05 luks2: Fix decoding of digests and salts with escaped chars
    @@ Commit message
         that handles unescaping for us.
     
         Reported-by: Afdal
    +    Reviewed-by: Daniel Kiper <dkiper@net-space.pl>
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
      ## grub-core/disk/luks2.c ##
    @@ grub-core/disk/luks2.c: luks2_scan (grub_disk_t disk, grub_cryptomount_args_t ca
     +  if (grub_json_unescape (&unescaped, &unescaped_len, in, inlen) != GRUB_ERR_NONE)
     +    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("could not unescape Base64 string"));
     +
    -+  successful = base64_decode (unescaped, (grub_size_t) unescaped_len, (char *) decoded, decodedlen);
    ++  successful = base64_decode (unescaped, unescaped_len, (char *) decoded, decodedlen);
     +  grub_free (unescaped);
     +  if (!successful)
     +    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("could not decode Base64 string"));
-- 
2.37.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2022-08-15 15:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 15:52 Patrick Steinhardt [this message]
2022-08-15 15:52 ` [PATCH v6 1/2] json: Add function to unescape JSON-encoded strings Patrick Steinhardt
2022-08-15 15:53 ` [PATCH v6 2/2] luks2: Fix decoding of digests and salts with escaped chars Patrick Steinhardt
2022-08-15 20:10 ` [PATCH v6 0/2] " Glenn Washburn

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=cover.1660578567.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=nvinson234@gmail.com \
    /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.