Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Issue 1549793002: port of sqlite3 fuzzer with some updates (Closed)

Created:
5 years ago by mmoroz
Modified:
4 years, 11 months ago
Reviewers:
krasin1, kcc2, aizatsky, inferno
CC:
chromium-reviews, mbarbella (wrong one)
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

port of sqlite3 fuzzer with some updates R=aizatsky@chromium.org, inferno@chromium.org, kcc@chromium.org, krasin@chromium.org BUG=569578 Committed: https://crrev.com/b5a889360ccf53d7da52b37e3dbc1f9d4e335292 Cr-Commit-Position: refs/heads/master@{#366983}

Patch Set 1 #

Total comments: 7

Patch Set 2 : fix the nits #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+58 lines, -0 lines) Patch
M testing/libfuzzer/fuzzers/BUILD.gn View 1 chunk +9 lines, -0 lines 0 comments Download
A testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc View 1 1 chunk +49 lines, -0 lines 2 comments Download

Messages

Total messages: 12 (3 generated)
mmoroz
5 years ago (2015-12-23 16:28:09 UTC) #1
aizatsky
lgtm https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc File testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc (right): https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc#newcode22 testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:22: if (data[0] & 1) I suggest you add ...
5 years ago (2015-12-23 21:04:33 UTC) #2
inferno
lgtm with nits, can land/cq after fixing these. https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc File testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc (right): https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc#newcode22 testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:22: if ...
4 years, 12 months ago (2015-12-26 22:33:07 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1549793002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1549793002/20001
4 years, 12 months ago (2015-12-28 16:14:00 UTC) #6
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 12 months ago (2015-12-28 16:49:31 UTC) #7
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/b5a889360ccf53d7da52b37e3dbc1f9d4e335292 Cr-Commit-Position: refs/heads/master@{#366983}
4 years, 12 months ago (2015-12-28 16:50:50 UTC) #9
kcc2
fuzzing sql is *much* more efficient with a dictionary, which you can grab from AFL ...
4 years, 11 months ago (2016-01-04 17:26:26 UTC) #10
kcc2
https://codereview.chromium.org/1549793002/diff/20001/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc File testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc (right): https://codereview.chromium.org/1549793002/diff/20001/testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc#newcode23 testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:23: int selector = data[0]; Two problems with this approach: ...
4 years, 11 months ago (2016-01-04 19:05:13 UTC) #11
mmoroz
4 years, 11 months ago (2016-01-15 19:08:16 UTC) #12
Message was sent while issue was closed.
https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/s...
File testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc (right):

https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/s...
testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:22: if (data[0] & 1)
On 2015/12/23 21:04:33, aizatsky wrote:
> I suggest you add a comment at the top about how you use data.

Done.

https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/s...
testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:28: int r =
sqlite3_prepare_v2(db, (const char*)(data + 1), size - 1,
On 2015/12/26 22:33:07, inferno wrote:
> s/r/result

Done.

https://codereview.chromium.org/1549793002/diff/1/testing/libfuzzer/fuzzers/s...
testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:31: for (int i = 0; i <
(data[0] >> 1); i++) {
On 2015/12/26 22:33:07, inferno wrote:
> What is reason for >> 1, also use the local defined above ?

We used least significant bit above for sqlite3_progress_handler selection. Then
we should remove this bit, I think. Otherwise, we always will use loop for odd
number of iterations in cases when progress_handler is used, and always use loop
for even number of iterations in cases without progress_handler.

https://codereview.chromium.org/1549793002/diff/20001/testing/libfuzzer/fuzze...
File testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc (right):

https://codereview.chromium.org/1549793002/diff/20001/testing/libfuzzer/fuzze...
testing/libfuzzer/fuzzers/sqlite3_prepare_v2_fuzzer.cc:23: int selector =
data[0];
On 2016/01/04 19:05:13, kcc2 wrote:
> Two problems with this approach: 
> 1. Now you can not feed the units to standard sqlite utilities, 
> you will first need to remove the first byte. 
> 
> 2. In cases there is a buffer overflow by one byte to the left 
> when reading the original buffer, asan will not find it. 
> I'd say this is highly unlikely in this particular case though. 
> 
> I don't say you should do something about this,
> just want to leave this comment FTR. 

Thanks,

1. Yes, I do remove first byte at line #35.

2. That's a good point.

We can copy the data without first byte to a new buffer, but as READ
stack-overflow to the left is not likely to happen, it would be redundant
overhead. One more suggestion is to use some XOR'ed value of 3 or 4 different
bytes from data and don't remove anything from the input. It's not perfect
solution in terms of mathematics, but probably will not cause any dependencies
and non-covered cases.

Powered by Google App Engine
This is Rietveld 408576698