Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame^] | 1 | From 4fc0d23e8f6d795c679623d2ed2cbe6a7a17b9c7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Li Zhou <li.zhou@windriver.com> |
| 3 | Date: Tue, 10 Sep 2019 20:02:15 -0700 |
| 4 | Subject: [PATCH] ip_reass: Fix use after free |
| 5 | |
| 6 | Using ip_deq after m_free might read pointers from an allocation reuse. |
| 7 | |
| 8 | This would be difficult to exploit, but that is still related with |
| 9 | CVE-2019-14378 which generates fragmented IP packets that would trigger this |
| 10 | issue and at least produce a DoS. |
| 11 | |
| 12 | Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> |
| 13 | |
| 14 | Upstream-Status: Backport |
| 15 | CVE: CVE-2019-15890 |
| 16 | Signed-off-by: Li Zhou <li.zhou@windriver.com> |
| 17 | --- |
| 18 | slirp/src/ip_input.c | 6 ++++-- |
| 19 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 20 | |
| 21 | diff --git a/slirp/src/ip_input.c b/slirp/src/ip_input.c |
| 22 | index 8c75d914..c07d7d40 100644 |
| 23 | --- a/slirp/src/ip_input.c |
| 24 | +++ b/slirp/src/ip_input.c |
| 25 | @@ -292,6 +292,7 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp) |
| 26 | */ |
| 27 | while (q != (struct ipasfrag *)&fp->frag_link && |
| 28 | ip->ip_off + ip->ip_len > q->ipf_off) { |
| 29 | + struct ipasfrag *prev; |
| 30 | i = (ip->ip_off + ip->ip_len) - q->ipf_off; |
| 31 | if (i < q->ipf_len) { |
| 32 | q->ipf_len -= i; |
| 33 | @@ -299,9 +300,10 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp) |
| 34 | m_adj(dtom(slirp, q), i); |
| 35 | break; |
| 36 | } |
| 37 | + prev = q; |
| 38 | q = q->ipf_next; |
| 39 | - m_free(dtom(slirp, q->ipf_prev)); |
| 40 | - ip_deq(q->ipf_prev); |
| 41 | + ip_deq(prev); |
| 42 | + m_free(dtom(slirp, prev)); |
| 43 | } |
| 44 | |
| 45 | insert: |
| 46 | -- |
| 47 | 2.23.0 |
| 48 | |