0004-batman-adv-Fix-double-free-during-fragment-merge-error.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Tue, 28 Mar 2017 14:39:48 +0200
  3. Subject: batman-adv: Fix double free during fragment merge error
  4. diff --git a/batman-adv/patches/1003-batman-adv-Fix-double-free-during-fragment-merge-err.patch b/batman-adv/patches/1003-batman-adv-Fix-double-free-during-fragment-merge-err.patch
  5. new file mode 100644
  6. index 0000000000000000000000000000000000000000..42748aac79d082e67a8552690b3aa6e7f5ec7d12
  7. --- /dev/null
  8. +++ b/batman-adv/patches/1003-batman-adv-Fix-double-free-during-fragment-merge-err.patch
  9. @@ -0,0 +1,41 @@
  10. +From ee1415285ddb56a3c15b5b70d7b403637486382c Mon Sep 17 00:00:00 2001
  11. +Message-Id: <ee1415285ddb56a3c15b5b70d7b403637486382c.1490704674.git.mschiffer@universe-factory.net>
  12. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  13. +Date: Tue, 28 Mar 2017 14:35:12 +0200
  14. +Subject: [PATCH] batman-adv: Fix double free during fragment merge error
  15. +
  16. +The function batadv_frag_skb_buffer was supposed not to consume the skbuff
  17. +on errors. This was followed in the helper function
  18. +batadv_frag_insert_packet when the skb would potentially be inserted in the
  19. +fragment queue. But it could happen that the next helper function
  20. +batadv_frag_merge_packets would try to merge the fragments and fail. This
  21. +results in a kfree_skb of all the enqueued fragments (including the just
  22. +inserted one). batadv_recv_frag_packet would detect the error in
  23. +batadv_frag_skb_buffer and try to free the skb again.
  24. +
  25. +The behavior of batadv_frag_skb_buffer must therefore be changed to return
  26. +true when batadv_frag_merge_packets fails.
  27. +
  28. +Fixes: 9b3eab61754d ("batman-adv: Receive fragmented packets and merge")
  29. +Signed-off-by: Sven Eckelmann <sven@narfation.org>
  30. +[Matthias Schiffer: backport to batman-adv 2016.2]
  31. +---
  32. + net/batman-adv/fragmentation.c | 2 --
  33. + 1 file changed, 2 deletions(-)
  34. +
  35. +diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
  36. +index 65536db1..21e5b79f 100644
  37. +--- a/net/batman-adv/fragmentation.c
  38. ++++ b/net/batman-adv/fragmentation.c
  39. +@@ -326,8 +326,6 @@ bool batadv_frag_skb_buffer(struct sk_buff **skb,
  40. + goto out;
  41. +
  42. + skb_out = batadv_frag_merge_packets(&head);
  43. +- if (!skb_out)
  44. +- goto out_err;
  45. +
  46. + out:
  47. + *skb = skb_out;
  48. +--
  49. +2.12.1
  50. +