qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 2/2] Delay crash when mbufs are corrupted


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [RFC PATCH 2/2] Delay crash when mbufs are corrupted
Date: Thu, 22 Aug 2019 16:41:34 +0200

If the mbufs linked list is corrupted, give the application
a chance to properly shutdown itself without causing dataloss.

For now, this means slowly leaking the heap.

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 src/ip_input.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/ip_input.c b/src/ip_input.c
index ee52085..36962b5 100644
--- a/src/ip_input.c
+++ b/src/ip_input.c
@@ -185,6 +185,15 @@ void ip_input(struct mbuf *m)
             if (ip == NULL)
                 return;
             m = dtom(slirp, ip);
+            if (m == NULL) {
+                /* The mbufs linked list is corrupted, we
+                 * should properly shutdown the application.
+                 * We prefer to leak a mbuf on the heap
+                 * rather than allowing null dereference
+                 * and eventual crash (data corruption).
+                 */
+                return; /* TODO warn the library consumer! */
+            }
         } else if (fp)
             ip_freef(slirp, fp);
 
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]