[openssl-commits] [openssl] master update

Kurt Roeckx kurt at openssl.org
Sun Apr 16 17:31:07 UTC 2017


The branch master has been updated
       via  ff54cd9beb07e47c48dac02d3006b0fbe5fc6cc2 (commit)
       via  14a6570f318562faf850f842ef3ce56f54ddc890 (commit)
       via  930aa9eeedd57478418ee267bb91d15ac95b1a78 (commit)
       via  b534df96c99b7f6103188005a688944645e2ec7b (commit)
       via  644fb113a0fe069c43911a86ff1b78bb6b7892c3 (commit)
      from  cad3f9dacbd03ea686a26690c8f4e58866d08104 (commit)


- Log -----------------------------------------------------------------
commit ff54cd9beb07e47c48dac02d3006b0fbe5fc6cc2
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Mon Mar 13 22:43:36 2017 +0100

    Optionally check for early data
    
    This adds a way to use the last byte of the buffer to change the
    behavior of the server. The last byte is used so that the existing
    corpus can be reused either without changing it, or just adding a single
    byte, and that it can still be used by other projects.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    GH: #2683

commit 14a6570f318562faf850f842ef3ce56f54ddc890
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Sun Feb 19 16:59:25 2017 +0100

    Use a fixed time when fuzzing.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    GH: #2683

commit 930aa9eeedd57478418ee267bb91d15ac95b1a78
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Sun Feb 19 17:09:45 2017 +0100

    Document how to update the corpus.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    GH: #2683

commit b534df96c99b7f6103188005a688944645e2ec7b
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Sun Feb 19 17:04:11 2017 +0100

    Make x509 and asn1 fuzzer reproducible
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    GH: #2683

commit 644fb113a0fe069c43911a86ff1b78bb6b7892c3
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Sun Feb 19 17:05:00 2017 +0100

    Switch libfuzzer to use trace-pc-guard
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    GH: #2683

-----------------------------------------------------------------------

Summary of changes:
 fuzz/README.md | 14 +++++++++++++-
 fuzz/asn1.c    | 12 ++++++++++++
 fuzz/client.c  | 18 ++++++++++++++++++
 fuzz/server.c  | 39 +++++++++++++++++++++++++++++++++++++--
 fuzz/x509.c    | 12 ++++++++++++
 5 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/fuzz/README.md b/fuzz/README.md
index 31e21ac..3800ef1 100644
--- a/fuzz/README.md
+++ b/fuzz/README.md
@@ -40,7 +40,7 @@ Configure for fuzzing:
             --with-fuzzer-lib=../../svn-work/Fuzzer/libFuzzer \
             -DPEDANTIC enable-asan enable-ubsan no-shared \
             -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION \
-            -fsanitize-coverage=edge,indirect-calls,8bit-counters \
+            -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp \
             enable-ec_nistp_64_gcc_128 -fno-sanitize=alignment enable-tls1_3 \
             enable-weak-ssl-ciphers enable-rc5 enable-md2 \
             enable-ssl3 enable-ssl3-method enable-nextprotoneg \
@@ -117,3 +117,15 @@ Since the corpus depends on the default behaviour of the client and the server,
 changes in what they send by default will have an impact on the coverage. The
 corpus will need to be updated in that case.
 
+Updating the corpus
+===================
+
+The client and server corpus is generated with multiple config options:
+- The options as documented above
+- Without enable-ec_nistp_64_gcc_128 and without --debug
+- With no-asm
+- Using 32 bit
+- A default config, plus options needed to generate the fuzzer.
+
+The libfuzzer merge option is used to add the additional coverage
+from each config to the minimal set.
diff --git a/fuzz/asn1.c b/fuzz/asn1.c
index 0c61315..c45fd79 100644
--- a/fuzz/asn1.c
+++ b/fuzz/asn1.c
@@ -28,8 +28,14 @@
 #include <openssl/x509v3.h>
 #include <openssl/cms.h>
 #include <openssl/err.h>
+#include <openssl/rand.h>
 #include "fuzzer.h"
 
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+extern int rand_predictable;
+#endif
+#define ENTROPY_NEEDED 32
+
 static ASN1_ITEM_EXP *item_type[] = {
     ASN1_ITEM_ref(ACCESS_DESCRIPTION),
 #ifndef OPENSSL_NO_RFC3779
@@ -210,6 +216,12 @@ int FuzzerInitialize(int *argc, char ***argv)
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
     ERR_get_state();
     CRYPTO_free_ex_index(0, -1);
+    RAND_add("", 1, ENTROPY_NEEDED);
+    RAND_status();
+
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    rand_predictable = 1;
+#endif
 
     return 1;
 }
diff --git a/fuzz/client.c b/fuzz/client.c
index 9404a95..622d782 100644
--- a/fuzz/client.c
+++ b/fuzz/client.c
@@ -8,6 +8,7 @@
  * or in the file LICENSE in the source distribution.
  */
 
+#include <time.h>
 #include <openssl/rand.h>
 #include <openssl/ssl.h>
 #include <openssl/rsa.h>
@@ -25,6 +26,23 @@ extern int rand_predictable;
 /* unused, to avoid warning. */
 static int idx;
 
+#define FUZZTIME 1485898104
+
+#define TIME_IMPL(t) { if (t != NULL) *t = FUZZTIME; return FUZZTIME; }
+
+/*
+ * This might not in all cases and still get the current time
+ * instead of the fixed time. This will just result in things
+ * not being fully reproducible and have a slightly different
+ * coverage.
+ */
+#if defined(_WIN32) && defined(_TIME64_T_DEFINED)
+time64_t _time64(time64_t *t) TIME_IMPL(t)
+#endif
+#if !defined(_WIN32) || !defined(_MSC_VER)
+time_t time(time_t *t) TIME_IMPL(t)
+#endif
+
 int FuzzerInitialize(int *argc, char ***argv)
 {
     STACK_OF(SSL_COMP) *comp_methods;
diff --git a/fuzz/server.c b/fuzz/server.c
index 5bbba1c..1a6dd2c 100644
--- a/fuzz/server.c
+++ b/fuzz/server.c
@@ -12,7 +12,7 @@
 
 /* Test first part of SSL server handshake. */
 
-
+#include <time.h>
 #include <openssl/rand.h>
 #include <openssl/ssl.h>
 #include <openssl/rsa.h>
@@ -473,6 +473,23 @@ extern int rand_predictable;
 /* unused, to avoid warning. */
 static int idx;
 
+#define FUZZTIME 1485898104
+
+#define TIME_IMPL(t) { if (t != NULL) *t = FUZZTIME; return FUZZTIME; }
+
+/*
+ * This might not in all cases and still get the current time
+ * instead of the fixed time. This will just result in things
+ * not being fully reproducible and have a slightly different
+ * coverage.
+ */
+#if defined(_WIN32) && defined(_TIME64_T_DEFINED)
+time64_t _time64(time64_t *t) TIME_IMPL(t)
+#endif
+#if !defined(_WIN32) || !defined(_MSC_VER)
+time_t time(time_t *t) TIME_IMPL(t)
+#endif
+
 int FuzzerInitialize(int *argc, char ***argv)
 {
     STACK_OF(SSL_COMP) *comp_methods;
@@ -513,8 +530,9 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 #ifndef OPENSSL_NO_DSA
     DSA *dsakey = NULL;
 #endif
+    uint8_t opt;
 
-    if (len == 0)
+    if (len < 2)
         return 0;
 
     /*
@@ -598,7 +616,24 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     out = BIO_new(BIO_s_mem());
     SSL_set_bio(server, in, out);
     SSL_set_accept_state(server);
+
+    opt = (uint8_t)buf[len-1];
+    len--;
+
     OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+
+    if ((opt & 0x01) != 0)
+    {
+        do {
+            char early_buf[16384];
+            size_t early_len;
+            ret = SSL_read_early_data(server, early_buf, sizeof(early_buf), &early_len);
+
+            if (ret != SSL_READ_EARLY_DATA_SUCCESS)
+                break;
+        } while (1);
+    }
+
     if (SSL_do_handshake(server) == 1) {
         /* Keep reading application data until error or EOF. */
         uint8_t tmp[1024];
diff --git a/fuzz/x509.c b/fuzz/x509.c
index 8d383e4..83b00f6 100644
--- a/fuzz/x509.c
+++ b/fuzz/x509.c
@@ -11,13 +11,25 @@
 #include <openssl/x509.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>
+#include <openssl/rand.h>
 #include "fuzzer.h"
 
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+extern int rand_predictable;
+#endif
+#define ENTROPY_NEEDED 32
+
 int FuzzerInitialize(int *argc, char ***argv)
 {
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
     ERR_get_state();
     CRYPTO_free_ex_index(0, -1);
+    RAND_add("", 1, ENTROPY_NEEDED);
+    RAND_status();
+
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    rand_predictable = 1;
+#endif
     return 1;
 }
 


More information about the openssl-commits mailing list