1
0

1761145081.v9-9-g0179988.CVE-2025-11568.fix-handling-of-large-metadata.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Subject: Fix handling of large metadata
  2. ID: CVE-2025-11568
  3. Origin: upstream, commit v9-9-g0179988 <https://github.com/latchset/luksmeta/commit/v9-9-g0179988>
  4. Author: Sergio Correia <scorreia@redhat.com>
  5. Date: Wed Oct 22 15:58:01 2025 +0100
  6. Bug-Debian: https://bugs.debian.org/111828
  7. Prevent metadata from being written beyond the gap between the LUKS
  8. header and encrypted data. The overflow check now correctly validates
  9. that the end position of new metadata does not exceed the hard limit,
  10. preventing corruption of encrypted data.
  11. Also add upfront size validation to reject metadata larger than the
  12. total available space.
  13. Fix: CVE-2025-11568
  14. Signed-off-by: Sergio Correia <scorreia@redhat.com>
  15. --- a/libluksmeta.c
  16. +++ b/libluksmeta.c
  17. @@ -69,8 +69,12 @@
  18. }
  19. static inline bool
  20. -overlap(const lm_t *lm, uint32_t start, size_t end)
  21. +overlap(const lm_t *lm, uint32_t start, size_t end, uint32_t hard_limit)
  22. {
  23. + /* Make sure the data fits the available area in the gap. */
  24. + if (end > hard_limit)
  25. + return true;
  26. +
  27. for (int i = 0; i < LUKS_NSLOTS; i++) {
  28. const lm_slot_t *s = &lm->slots[i];
  29. uint32_t e = s->offset + s->length;
  30. @@ -90,8 +94,13 @@
  31. {
  32. size = ALIGN(size, true);
  33. + /* Make sure the data is not larger than the total available
  34. + * area in the gap. */
  35. + if (length < size)
  36. + return 0;
  37. +
  38. for (uint32_t off = ALIGN(1, true); off < length; off += ALIGN(1, true)) {
  39. - if (!overlap(lm, off, off + size))
  40. + if (!overlap(lm, off, off + size, lm->slots[0].offset + length))
  41. return off;
  42. }
  43. --- a/test-luksmeta
  44. +++ b/test-luksmeta
  45. @@ -3,9 +3,12 @@
  46. trap 'exit' ERR
  47. export tmp=`mktemp /tmp/luksmeta.XXXXXXXXXX`
  48. +export tmpdata=`mktemp /tmp/luksmeta.XXXXXXXXXX`
  49. +
  50. function onexit() {
  51. rm -f $tmp
  52. + rm -f "${tmpdata}"
  53. }
  54. trap 'onexit' EXIT
  55. @@ -56,3 +59,16 @@
  56. test "`./luksmeta load -s 0 -d $tmp`" == "hi"
  57. ./luksmeta init -n -f -d $tmp
  58. ! ./luksmeta load -s 0 -d $tmp
  59. +
  60. +# CVE-2025-11568 - test attempt to store extremely large amount of data in a slot.
  61. +./luksmeta init -f -d "${tmp}"
  62. +dd bs=1024k count=1 </dev/zero >"${tmpdata}"
  63. +! ./luksmeta save -s 1 -u 23149359-1b61-4803-b818-774ab730fbec -d "${tmp}" < "${tmpdata}"
  64. +
  65. +# Additional test for CVE-2025-11568 boundary conditions.
  66. +# Verify overflow protection with multiple existing slots at various offsets.
  67. +./luksmeta init -f -d "${tmp}"
  68. +echo "a" | ./luksmeta save -s 0 -u 11111111-1111-1111-1111-111111111111 -d "${tmp}"
  69. +echo "b" | ./luksmeta save -s 1 -u 22222222-2222-2222-2222-222222222222 -d "${tmp}"
  70. +dd bs=1024 count=900 </dev/zero >"${tmpdata}"
  71. +! ./luksmeta save -s 2 -u 33333333-3333-3333-3333-333333333333 -d "${tmp}" < "${tmpdata}"