All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/2] luks2: Fix decoding of digests and salts with escaped chars
@ 2022-08-15 15:52 Patrick Steinhardt
  2022-08-15 15:52 ` [PATCH v6 1/2] json: Add function to unescape JSON-encoded strings Patrick Steinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Patrick Steinhardt @ 2022-08-15 15:52 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper, Glenn Washburn, Nicholas Vinson

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-15 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 15:52 [PATCH v6 0/2] luks2: Fix decoding of digests and salts with escaped chars Patrick Steinhardt
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

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.