forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libFuzzer] extend -rss_limit_mb to crash instantly on a single mallo…
…c that exceeds the limit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288281 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
6 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
|
||
// Tests OOM handling. | ||
#include <assert.h> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <cstddef> | ||
#include <cstring> | ||
#include <iostream> | ||
#include <unistd.h> | ||
|
||
static volatile char *SinkPtr; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | ||
if (Size > 0 && Data[0] == 'H') { | ||
if (Size > 1 && Data[1] == 'i') { | ||
if (Size > 2 && Data[2] == '!') { | ||
size_t kSize = 0xff000000U; | ||
char *p = new char[kSize]; | ||
SinkPtr = p; | ||
delete [] p; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
REQUIRES: linux | ||
RUN: not LLVMFuzzer-OutOfMemoryTest -rss_limit_mb=10 2>&1 | FileCheck %s | ||
CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 10Mb) | ||
RUN: not LLVMFuzzer-OutOfMemoryTest -rss_limit_mb=300 2>&1 | FileCheck %s | ||
CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300Mb) | ||
CHECK: Live Heap Allocations | ||
CHECK: Test unit written to ./oom- | ||
SUMMARY: libFuzzer: out-of-memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
RUN: not LLVMFuzzer-OutOfMemoryTest -rss_limit_mb=10 2>&1 | FileCheck %s | ||
CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 10Mb) | ||
RUN: not LLVMFuzzer-OutOfMemoryTest -rss_limit_mb=300 2>&1 | FileCheck %s | ||
CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300Mb) | ||
CHECK: Test unit written to ./oom- | ||
SUMMARY: libFuzzer: out-of-memory | ||
|
||
RUN: not LLVMFuzzer-OutOfMemorySingleLargeMallocTest 2>&1 | FileCheck %s --check-prefix=SINGLE_LARGE_MALLOC | ||
SINGLE_LARGE_MALLOC: libFuzzer: out-of-memory (malloc(42{{.*}})) | ||
SINGLE_LARGE_MALLOC: in LLVMFuzzerTestOneInput |