aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2020-04-04 22:42:13 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2020-04-06 12:43:30 +0200
commit9bd6c5913271eabcb7768a58197ed3301fe19f2d (patch)
treeb045efa2e1fe9705c6ff793cec7f43ba49f25c24 /src
parentb2dd09156a1ff5adb20c8ad73055284c6be786ff (diff)
downloadslirp-9bd6c5913271eabcb7768a58197ed3301fe19f2d.zip
slirp-9bd6c5913271eabcb7768a58197ed3301fe19f2d.tar.gz
slirp-9bd6c5913271eabcb7768a58197ed3301fe19f2d.tar.bz2
Fix use-afte-free in ip_reass() (CVE-2020-1983)
The q pointer is updated when the mbuf data is moved from m_dat to m_ext. m_ext buffer may also be realloc()'ed and moved during m_cat(): q should also be updated in this case. Reported-by: Aviv Sasson <asasson@paloaltonetworks.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'src')
-rw-r--r--src/ip_input.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/ip_input.c b/src/ip_input.c
index aa514ae..89a01d4 100644
--- a/src/ip_input.c
+++ b/src/ip_input.c
@@ -327,8 +327,7 @@ insert:
*/
q = fp->frag_link.next;
m = dtom(slirp, q);
-
- int was_ext = m->m_flags & M_EXT;
+ int delta = (char *)q - (m->m_flags & M_EXT ? m->m_ext : m->m_dat);
q = (struct ipasfrag *)q->ipf_next;
while (q != (struct ipasfrag *)&fp->frag_link) {
@@ -351,8 +350,7 @@ insert:
* then an m_ext buffer was alloced. But fp->ipq_next points to the old
* buffer (in the mbuf), so we must point ip into the new buffer.
*/
- if (!was_ext && m->m_flags & M_EXT) {
- int delta = (char *)q - m->m_dat;
+ if (m->m_flags & M_EXT) {
q = (struct ipasfrag *)(m->m_ext + delta);
}