Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy #8779

Merged
merged 50 commits into from
Dec 20, 2019

Conversation

jmarantz
Copy link
Contributor

@jmarantz jmarantz commented Oct 27, 2019

Description: Stats have a reasonably generous hard limit of 64k bytes per "."-separated segment. However fuzzing is evidently happy to make longer strings, based on the fuzz crash report

This change also has the benefit of further reducing memory use; see gold-file updates in the PR.

Risk Level: low
Testing: just this one fuzz test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, curious what enforces the stat name limits.

test/common/stats/symbol_table_fuzz_test.cc Outdated Show resolved Hide resolved

if (str.size() >= StatNameMaxSize) {
size_t halfway = str.size() / 2;
addSymbol(pool, symbol_table, str.substr(0, halfway));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to have this kind of smart logic; if you just cap the string at StatNameMaxSize, the fuzzer will be able to do what is implied in this logic if it is helpful to the exploration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm changing the symbol-table impl to simply not have this limit, which should simplify fuzzing. It works I think but still not quite ready for review. Will ping again when ready.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for review now.

Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out how to max_len to at least libfuzzer in oss-fuzz, but would it benefit if we only consume up to StatNameMaxSize per symbol?

I will test run the max_len for one @htuch's fuzzers for now, cc you on it and lmk

test/common/stats/symbol_table_fuzz_test.cc Outdated Show resolved Hide resolved
…, or on the length of a fake-symbol table stat-name.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title stats: Avoid asserts in fuzz-tests due to input strings being too long. WiP stats: Avoid asserts in fuzz-tests due to input strings being too long. Oct 28, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…es or symbols. it's bytes.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title WiP stats: Avoid asserts in fuzz-tests due to input strings being too long. stats: Avoid asserts in fuzz-tests due to input strings being too long. Oct 29, 2019
@jmarantz jmarantz changed the title stats: Avoid asserts in fuzz-tests due to input strings being too long. stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits Oct 29, 2019
@jmarantz
Copy link
Contributor Author

ready for review now

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/azp run envoy-macos

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ass.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits WiP stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits Nov 2, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, adding a new MemBlock wrapper for memcpy WiP stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, adding a new MemBlock wrapper for memcpy Dec 11, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title WiP stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, adding a new MemBlock wrapper for memcpy stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy Dec 15, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit to jmarantz/envoy that referenced this pull request Dec 16, 2019
…xy#8779).

Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit that referenced this pull request Dec 16, 2019
…(discovered in #8779). (#9360)

* Add test for release(), which was not working (discovered in #8779).

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: api (failed build)

🐱

Caused by: a #8779 (comment) was created by @jmarantz.

see: more, trace.

Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM from the fuzzing / test utility side now

@jmarantz
Copy link
Contributor Author

Over to @mattklein123 for senior maintainer review. Thank you!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a skim.

@@ -135,6 +135,37 @@ MemoryTest::Mode MemoryTest::mode() {
#endif
}

// TODO(jmarantz): this utility is intended to be costs both for unit tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"costs both"? Feel free to fix in a follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matt, rolling that into #9355

@jmarantz jmarantz merged commit 6eeced6 into envoyproxy:master Dec 20, 2019
@jmarantz jmarantz deleted the stats-fuzzer-not-too-long branch December 20, 2019 18:18
spenceral added a commit to spenceral/envoy that referenced this pull request Dec 20, 2019
* master: (167 commits)
  stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy (envoyproxy#8779)
  Make %UPSTREAM_LOCAL_ADDRESS% access-log format work for HTTP requests. (envoyproxy#9362)
  tools: API boosting support for using decls and enum constants. (envoyproxy#9418)
  Fix incorrect cluster InitializePhase type (envoyproxy#9379)
  build: fix merge race between envoyproxy#9241 and envoyproxy#9413. (envoyproxy#9427)
  fuzz: fix incorrect evaluator test (envoyproxy#9402)
  server: fix bogus startup log message (envoyproxy#9404)
  tools: Add protoxform tests (envoyproxy#9241)
  api: options after import (envoyproxy#9413)
  misc: use std::move instead of constructing a copy (envoyproxy#9415)
  tools: API boosting support for rewriting elaborated types. (envoyproxy#9375)
  docs: fix invalid transport_socket value (envoyproxy#9403)
  fix typo in docs (envoyproxy#9394)
  srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. (envoyproxy#9366)
  api: generate whole directory and sync (envoyproxy#9382)
  bazel: Add load statements for proto_library (envoyproxy#9367)
  Fix typo (envoyproxy#9388)
  Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) (envoyproxy#9290)
  http1 encode trailers in chunk encoding (envoyproxy#8667)
  Add mode to PipeInstance (envoyproxy#8423)
  ...
prakhag1 pushed a commit to prakhag1/envoy that referenced this pull request Jan 3, 2020
…(discovered in envoyproxy#8779). (envoyproxy#9360)

* Add test for release(), which was not working (discovered in envoyproxy#8779).

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Prakhar <prakhar_au@yahoo.com>
prakhag1 pushed a commit to prakhag1/envoy that referenced this pull request Jan 3, 2020
…mits, using the new MemBlock wrapper for memcpy (envoyproxy#8779)

* Avoid crashes in fuzz-tests due to input strings being too long.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Prakhar <prakhar_au@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants