[llvm] r281106 - [libFuzzer] one more puzzle for value profile

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 15:21:38 PDT 2016


On Fri, Sep 9, 2016 at 2:58 PM, Kostya Serebryany via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: kcc
> Date: Fri Sep  9 16:58:42 2016
> New Revision: 281106
>
> URL: http://llvm.org/viewvc/llvm-project?rev=281106&view=rev
> Log:
> [libFuzzer] one more puzzle for value profile
>
> Added:
>     llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
> Modified:
>     llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
>     llvm/trunk/lib/Fuzzer/test/value-profile-cmp.test
>
> Added: llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/
> test/AbsNegAndConstant64Test.cpp?rev=281106&view=auto
> ============================================================
> ==================
> --- llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp (added)
> +++ llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp Fri Sep  9
> 16:58:42 2016
> @@ -0,0 +1,23 @@
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +
> +// abs(x) < 0 and y == Const puzzle, 64-bit variant.
> +#include <cstring>
> +#include <cstdint>
> +#include <cstdlib>
> +#include <cstddef>
> +#include <cstdio>
> +
> +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
> +  if (Size < 16) return 0;
> +  long x;
> +  unsigned long y;
> +  memcpy(&x, Data, 8);
> +  memcpy(&y, Data + 8, 8);
>

Can you use sizeof instead of hardcoded values?

-- Sean Silva


> +  if (labs(x) < 0 && y == 0xbaddcafedeadbeefUL) {
> +    printf("BINGO; Found the target, exiting; x = 0x%lx y 0x%lx\n", x, y);
> +    exit(1);
> +  }
> +  return 0;
> +}
> +
>
> Modified: llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/
> test/CMakeLists.txt?rev=281106&r1=281105&r2=281106&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Fuzzer/test/CMakeLists.txt (original)
> +++ llvm/trunk/lib/Fuzzer/test/CMakeLists.txt Fri Sep  9 16:58:42 2016
> @@ -63,6 +63,7 @@ set(TestBinaries)
>
>  set(Tests
>    AbsNegAndConstantTest
> +  AbsNegAndConstant64Test
>    AccumulateAllocationsTest
>    BufferOverflowOnInput
>    CallerCalleeTest
>
> Modified: llvm/trunk/lib/Fuzzer/test/value-profile-cmp.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/
> test/value-profile-cmp.test?rev=281106&r1=281105&r2=281106&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Fuzzer/test/value-profile-cmp.test (original)
> +++ llvm/trunk/lib/Fuzzer/test/value-profile-cmp.test Fri Sep  9 16:58:42
> 2016
> @@ -2,5 +2,6 @@ CHECK: BINGO
>  RUN: not LLVMFuzzer-SimpleCmpTest -use_value_profile=1 -runs=100000000
> 2>&1 | FileCheck %s
>  RUN: not LLVMFuzzer-SimpleHashTest -use_value_profile=1 -runs=100000000
> 2>&1 | FileCheck %s
>  RUN: not LLVMFuzzer-AbsNegAndConstantTest -use_value_profile=1
> -runs=100000000 2>&1 | FileCheck %s
> +RUN: not LLVMFuzzer-AbsNegAndConstant64Test -use_value_profile=1
> -runs=100000000 2>&1 | FileCheck %s
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160909/14b027f3/attachment.html>


More information about the llvm-commits mailing list