0001-EAP-pwd-server-Fix-reassembly-buffer-handling.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From fe76f487e28bdc61940f304f153a954cf36935ea Mon Sep 17 00:00:00 2001
  2. From: Jouni Malinen <jouni@codeaurora.org>
  3. Date: Wed, 17 Apr 2019 01:55:32 +0300
  4. Subject: [PATCH 1/3] EAP-pwd server: Fix reassembly buffer handling
  5. data->inbuf allocation might fail and if that were to happen, the next
  6. fragment in the exchange could have resulted in NULL pointer
  7. dereference. Unexpected fragment with more bit might also be able to
  8. trigger this. Fix that by explicitly checking for data->inbuf to be
  9. available before using it.
  10. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
  11. ---
  12. src/eap_server/eap_server_pwd.c | 8 +++++++-
  13. 1 file changed, 7 insertions(+), 1 deletion(-)
  14. diff --git a/src/eap_server/eap_server_pwd.c b/src/eap_server/eap_server_pwd.c
  15. index 11bef55..38e2af8 100644
  16. --- a/src/eap_server/eap_server_pwd.c
  17. +++ b/src/eap_server/eap_server_pwd.c
  18. @@ -912,6 +912,12 @@ static void eap_pwd_process(struct eap_sm *sm, void *priv,
  19. * the first and all intermediate fragments have the M bit set
  20. */
  21. if (EAP_PWD_GET_MORE_BIT(lm_exch) || data->in_frag_pos) {
  22. + if (!data->inbuf) {
  23. + wpa_printf(MSG_DEBUG,
  24. + "EAP-pwd: No buffer for reassembly");
  25. + eap_pwd_state(data, FAILURE);
  26. + return;
  27. + }
  28. if ((data->in_frag_pos + len) > wpabuf_size(data->inbuf)) {
  29. wpa_printf(MSG_DEBUG, "EAP-pwd: Buffer overflow "
  30. "attack detected! (%d+%d > %d)",
  31. @@ -932,7 +938,7 @@ static void eap_pwd_process(struct eap_sm *sm, void *priv,
  32. * last fragment won't have the M bit set (but we're obviously
  33. * buffering fragments so that's how we know it's the last)
  34. */
  35. - if (data->in_frag_pos) {
  36. + if (data->in_frag_pos && data->inbuf) {
  37. pos = wpabuf_head_u8(data->inbuf);
  38. len = data->in_frag_pos;
  39. wpa_printf(MSG_DEBUG, "EAP-pwd: Last fragment, %d bytes",
  40. --
  41. 2.7.4