CVE-2019-7664.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 3ed05376e7b2c96c1d6eb24d2842cc25b79a4f07 Mon Sep 17 00:00:00 2001
  2. From: Mark Wielaard <mark@klomp.org>
  3. Date: Wed, 16 Jan 2019 12:25:57 +0100
  4. Subject: [PATCH] CVE: CVE-2019-7664
  5. Upstream-Status: Backport
  6. libelf: Correct overflow check in note_xlate.
  7. We want to make sure the note_len doesn't overflow and becomes shorter
  8. than the note header. But the namesz and descsz checks got the note header
  9. size wrong). Replace the wrong constant (8) with a sizeof cvt_Nhdr (12).
  10. https://sourceware.org/bugzilla/show_bug.cgi?id=24084
  11. Signed-off-by: Mark Wielaard <mark@klomp.org>
  12. Signed-off-by: Ubuntu <lisa@shuagr-yocto-build.mdn4q2lr1oauhmizmzsslly3ad.xx.internal.cloudapp.net>
  13. ---
  14. libelf/ChangeLog | 13 +++++++++++++
  15. libelf/note_xlate.h | 4 ++--
  16. 2 files changed, 15 insertions(+), 2 deletions(-)
  17. diff --git a/libelf/ChangeLog b/libelf/ChangeLog
  18. index 68c4fbd..892e6e7 100644
  19. --- a/libelf/ChangeLog
  20. +++ b/libelf/ChangeLog
  21. @@ -1,3 +1,16 @@
  22. +<<<<<<< HEAD
  23. +=======
  24. +2019-01-16 Mark Wielaard <mark@klomp.org>
  25. +
  26. + * note_xlate.h (elf_cvt_note): Check n_namesz and n_descsz don't
  27. + overflow note_len into note header.
  28. +
  29. +2018-11-17 Mark Wielaard <mark@klomp.org>
  30. +
  31. + * elf32_updatefile.c (updatemmap): Make sure to call convert
  32. + function on a properly aligned destination.
  33. +
  34. +>>>>>>> e65d91d... libelf: Correct overflow check in note_xlate.
  35. 2018-11-16 Mark Wielaard <mark@klomp.org>
  36. * libebl.h (__elf32_msize): Mark with const attribute.
  37. diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h
  38. index 9bdc3e2..bc9950f 100644
  39. --- a/libelf/note_xlate.h
  40. +++ b/libelf/note_xlate.h
  41. @@ -46,13 +46,13 @@ elf_cvt_note (void *dest, const void *src, size_t len, int encode,
  42. /* desc needs to be aligned. */
  43. note_len += n->n_namesz;
  44. note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len);
  45. - if (note_len > len || note_len < 8)
  46. + if (note_len > len || note_len < sizeof *n)
  47. break;
  48. /* data as a whole needs to be aligned. */
  49. note_len += n->n_descsz;
  50. note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len);
  51. - if (note_len > len || note_len < 8)
  52. + if (note_len > len || note_len < sizeof *n)
  53. break;
  54. /* Copy or skip the note data. */
  55. --
  56. 2.7.4