You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

  1. From c59279437eda91841b9d26079c70b8a540d41204 Mon Sep 17 00:00:00 2001
  2. From: Samuel Thibault <samuel.thibault@ens-lyon.org>
  3. Date: Mon, 26 Aug 2019 00:55:03 +0200
  4. Subject: [PATCH] ip_reass: Fix use after free
  5. Using ip_deq after m_free might read pointers from an allocation reuse.
  6. This would be difficult to exploit, but that is still related with
  7. CVE-2019-14378 which generates fragmented IP packets that would trigger this
  8. issue and at least produce a DoS.
  9. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
  10. ---
  11. Taken from https://gitlab.freedesktop.org/slirp/libslirp/commit/c5927943
  12. slirp/src/ip_input.c | 6 ++++--
  13. 1 file changed, 4 insertions(+), 2 deletions(-)
  14. diff --git a/slirp/src/ip_input.c b/slirp/src/ip_input.c
  15. index 7364ce0..aa514ae 100644
  16. --- a/slirp/src/ip_input.c
  17. +++ b/slirp/src/ip_input.c
  18. @@ -292,6 +292,7 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
  19. */
  20. while (q != (struct ipasfrag *)&fp->frag_link &&
  21. ip->ip_off + ip->ip_len > q->ipf_off) {
  22. + struct ipasfrag *prev;
  23. i = (ip->ip_off + ip->ip_len) - q->ipf_off;
  24. if (i < q->ipf_len) {
  25. q->ipf_len -= i;
  26. @@ -299,9 +300,10 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
  27. m_adj(dtom(slirp, q), i);
  28. break;
  29. }
  30. + prev = q;
  31. q = q->ipf_next;
  32. - m_free(dtom(slirp, q->ipf_prev));
  33. - ip_deq(q->ipf_prev);
  34. + ip_deq(prev);
  35. + m_free(dtom(slirp, prev));
  36. }
  37. insert:
  38. --
  39. 2.22.0