grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 0/2] cryptodisk: Allows UUIDs to be compared in a dash-insensi


From: Glenn Washburn
Subject: [PATCH v2 0/2] cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner
Date: Sun, 21 Mar 2021 15:06:20 -0500

Since this has been on the shelf a while, I forgot that a null termination of
the UUID field in LUKS 1/2 headers can be enforced as it is required by the
spec[1][2]. So there's no need to preserve the last byte of the UUID field, as
was done in the first version of the patch. I'll repeat here my comments taking
into account this change.

There was also an issue in v1 that prevented it from building, which has been
fixed.

--
I have another version of grub_uuidcasecmp which is more efficient by not
copying the UUID bytes to another buffer to strip out the dashes. This also
implies that it does not require null-terminated strings as inputs because
one can use the n parameter to prevent access beyond length of array.

However, I'm not sure we're so memory constrained that the added complexity
(its not trivial to verify correctness) is worth it here, so I've chosen to
submit this simpler version. If that assumption isn't valid, I can submit
the more complex version. This current version uses an extra buffer copy in
grub_uuidcasecmp to strip out dashes so that grub_strncasecmp can be called.

Another benefit of this is that the complexity of UUID processing is moved
into one place as opposed to each cryptodisk module potentially having that
complexity (eg. current code duplication in LUKS1 and LUKS2 modules).
--

Glenn

[1] 
https://mirrors.edge.kernel.org/pub/linux/utils/cryptsetup/LUKS_docs/on-disk-format.pdf#7
[2] https://gitlab.com/cryptsetup/LUKS2-docs/blob/master/luks2_doc_wip.pdf

Glenn Washburn (2):
  luks, luks2: Force header.uuid to be NULL terminated
  cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner

 grub-core/disk/cryptodisk.c |  4 ++--
 grub-core/disk/geli.c       |  2 +-
 grub-core/disk/luks.c       | 24 +++++++-----------------
 grub-core/disk/luks2.c      | 16 ++++++----------
 include/grub/misc.h         | 27 +++++++++++++++++++++++++++
 5 files changed, 43 insertions(+), 30 deletions(-)

-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]