ctf: Fix buffer overflow traces from crashing batch import
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 26 Jun 2013 19:10:18 +0000 (15:10 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 31 Jul 2013 14:44:11 +0000 (10:44 -0400)
Buffer overflows are caused here by synthetic traces that aim to
behave maliciously. The parser already handles these attacks, but
the BufferOverflowException will cause the batch import trace wizard
to stop scanning. This fix catches buffer overflows in the validation
and warns that the error is serious.

Change-Id: Ie9156cfaac0944763e3d1dc798c42f1d64753560
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/14088
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Messages.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/messages.properties
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties

index cc72b09c109100b4a8cf7cab872da0045ee76f69..c9d658179197d627e68fc6ee9991ba10d9eaf258 100644 (file)
@@ -14,6 +14,7 @@
 package org.eclipse.linuxtools.lttng2.kernel.core.trace;
 
 import java.io.File;
+import java.nio.BufferOverflowException;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IStatus;
@@ -75,6 +76,9 @@ public class LttngKernelTrace extends CtfTmfTrace {
         } catch (NullPointerException e){
             validStatus = new Status(IStatus.ERROR,  Activator.PLUGIN_ID, e.toString(), e);
             return validStatus;
+        } catch (final BufferOverflowException e) {
+            validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_TraceReadError + ": " + Messages.LttngKernelTrace_MalformedTrace); //$NON-NLS-1$
+            return validStatus;
         }
 
         /* Make sure the domain is "kernel" in the trace's env vars */
index 6b958f2b3e1baebde192cdca816d78333ee45852..e3372101c08ec7785e18535eebc51dad7a8c7a41 100644 (file)
@@ -27,6 +27,16 @@ public class Messages extends NLS {
      * The domain is not "kernel"
      */
     public static String LttngKernelTrace_DomainError;
+    /**
+     * Malformed trace (buffer overflow maybe?)
+     * @since 2.1
+     */
+    public static String LttngKernelTrace_MalformedTrace;
+    /**
+     * Trace read error
+     * @since 2.1
+     */
+    public static String LttngKernelTrace_TraceReadError;
 
     static {
         // initialize resource bundle
index 7ef639cf62a3fd5b0dcdf98d1749d427a4dc58df..460105a03e799e0a35d5a4042b677705f28f8954 100644 (file)
@@ -11,3 +11,5 @@
 ###############################################################################
 
 LttngKernelTrace_DomainError=Domain mismatch, the environment should be 'kernel'.
+LttngKernelTrace_MalformedTrace=Buffer overflow exception, trace is malformed
+LttngKernelTrace_TraceReadError=Lttng trace read error
index 700b0a9d7d228c807e0bbe948349375249192527..16ff7f5c7f47587fd68eb3ee8922e170f8ed5f12 100644 (file)
@@ -13,6 +13,7 @@
 
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
+import java.nio.BufferOverflowException;
 import java.util.Collections;
 import java.util.Map;
 
@@ -154,7 +155,10 @@ public class CtfTmfTrace extends TmfTrace
             temp.dispose();
         } catch (final CTFReaderException e) {
             validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + e.toString()); //$NON-NLS-1$
+        } catch (final BufferOverflowException e){
+            validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + Messages.CtfTmfTrace_BufferOverflowErrorMessage); //$NON-NLS-1$
         }
+
         return validTrace;
     }
 
index 654a6ce72424b8b3e93a79636a82200aec0cab35..6d51e613eece8373423f1e113b8c77bee099f4ff 100644 (file)
@@ -23,6 +23,10 @@ public class Messages extends NLS {
 
     private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.ctfadaptor.messages"; //$NON-NLS-1$
 
+    /** Buffer overflow detected
+     * @since 2.1*/
+    public static String CtfTmfTrace_BufferOverflowErrorMessage;
+
     /** Major version number not set */
     public static String CtfTmfTrace_MajorNotSet;
 
index 5fe42dca0ca173cdc9ef8dea5702c4ae85f7591c..ba5eee55acb7f66d3c6ffac440f413b0c33452fd 100644 (file)
@@ -10,6 +10,7 @@
 #     Ericsson - Initial API and implementation
 ###############################################################################
 
+CtfTmfTrace_BufferOverflowErrorMessage=Buffer overflow exception, trace is malformed
 CtfTmfTrace_MajorNotSet=Major version number not set
 CtfTmfTrace_ReadingError=Reading error
 CtfTmfTrace_NoEvent=Trace has no events
\ No newline at end of file
This page took 0.179095 seconds and 5 git commands to generate.