Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions docs/reference/trace-processor-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,19 @@ configuration, so pass `--debuginfod` when starting the server.

Setting URLs alone does not enable downloads; a configured `DEBUGINFOD_URLS`
without `--debuginfod` produces a warning when symbolization leaves frames
unresolved. Local symbol paths and Breakpad
files are searched first and only build IDs that are still unresolved are
fetched, from the cache and then from each server in order. Downloaded files
are checked against the requested build ID and published to the cache
atomically. There is no automatic eviction. `DEBUGINFOD_URLS` and
`LLVM_SYMBOLIZER_OPTS` are removed from the `llvm-symbolizer` environment so
it cannot download on its own. The summary counts downloads, cache hits,
build IDs no server had, and failed lookups, and names servers that could not
be reached; `--verbose` lists every server tried for each mapping with the
reason it did not help.
unresolved. Perfetto accepts `ima:enforcing` and `ima:ignore` tokens in the
URL list but does not perform IMA signature verification. A regular warning
is emitted when debuginfod is used with a server under `ima:enforcing`.

Local symbol paths and Breakpad files are searched first and only build IDs
that are still unresolved are fetched, from the cache and then from each
server in order. Downloaded files are checked against the requested build ID
and published to the cache atomically. There is no automatic eviction.
`DEBUGINFOD_URLS` and `LLVM_SYMBOLIZER_OPTS` are removed from the
`llvm-symbolizer` environment so it cannot download on its own. The summary
counts downloads, cache hits, build IDs no server had, and failed lookups, and
names servers that could not be reached; `--verbose` lists every server tried
for each mapping with the reason it did not help.

## {#subcommands} Commands

Expand Down
14 changes: 14 additions & 0 deletions src/trace_processor/util/symbolizer/debuginfod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,28 @@ base::Status ResolveDebuginfodOptions(const DebuginfodOptions& options,
std::replace_if(
list.begin(), list.end(),
[](char c) { return isspace(static_cast<unsigned char>(c)); }, ' ');
bool ima_enforcing = false;
for (base::StringSplitter urls(std::move(list), ' '); urls.Next();) {
std::string url = urls.cur_token();
if (url == "ima:enforcing") {
ima_enforcing = true;
continue;
}
if (url == "ima:ignore") {
ima_enforcing = false;
continue;
}
while (!url.empty() && url.back() == '/')
url.pop_back();
if ((!base::StartsWith(url, "https://") &&
!base::StartsWith(url, "http://")) ||
url.find_first_of("?#") != std::string::npos)
return base::ErrStatus("debuginfod URLs must be HTTP(S) server roots");
if (ima_enforcing && config->ima_policy_warning.empty()) {
config->ima_policy_warning =
"debuginfod IMA verification is not supported; downloads from "
"ima:enforcing servers are not signature-verified.\n";
}
config->urls.push_back(std::move(url));
}
if (config->urls.empty())
Expand Down
1 change: 1 addition & 0 deletions src/trace_processor/util/symbolizer/debuginfod.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct DebuginfodConfig {
// they would have changed: one that looked up frames, and for
// |disabled_warning| left some of them unresolved.
std::string llvm_opts_warning;
std::string ima_policy_warning;
std::string disabled_warning;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ SymbolizerResult SymbolizeDatabase(trace_processor::TraceProcessor* tp,
SymbolizePendingAddresses(groups, env, symbolizer.get(), &mappings,
&result.symbols);
}
result.debuginfod.warnings += config.debuginfod.ima_policy_warning;
}
result.debuginfod.warnings += config.debuginfod.llvm_opts_warning;
if (unresolved)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,30 @@ TEST(DebuginfodOptionsTest, ExplicitValuesAndWhitespace) {
EXPECT_EQ(config.stall_timeout_seconds, 3u);
}

TEST(DebuginfodOptionsTest, ImaPolicyTags) {
DebuginfodOptions options;
options.enabled = true;
options.urls =
"ima:enforcing https://one.example/ https://two.example/debug/ "
"ima:ignore http://three.example/";
options.cache_path = "/chosen/cache";
DebuginfodConfig config;

ASSERT_TRUE(ResolveDebuginfodOptions(options, &config).ok());
EXPECT_THAT(config.urls, testing::ElementsAre("https://one.example",
"https://two.example/debug",
"http://three.example"));
EXPECT_THAT(config.ima_policy_warning, testing::HasSubstr("ima:enforcing"));
EXPECT_EQ(config.cache_path, "/chosen/cache");

config = {};
options.urls = "ima:enforcing ima:ignore https://one.example/";
ASSERT_TRUE(ResolveDebuginfodOptions(options, &config).ok());
EXPECT_THAT(config.urls, testing::ElementsAre("https://one.example"));
EXPECT_TRUE(config.ima_policy_warning.empty());
EXPECT_EQ(config.cache_path, "/chosen/cache");
}

#endif

TEST(DebuginfodOptionsTest, ConfigurationDoesNotEnableDownloads) {
Expand All @@ -136,7 +160,8 @@ TEST(DebuginfodOptionsTest, RejectsEmptyOverridesAndInvalidValues) {
DebuginfodConfig config;
EXPECT_FALSE(ResolveDebuginfodOptions(options, &config).ok());
for (const char* url :
{"file:///tmp/debug", "https://host?q=x", "https://host#fragment"}) {
{"file:///tmp/debug", "https://host?q=x", "https://host#fragment",
"ima:unknown https://host"}) {
config = {};
options.urls = url;
EXPECT_FALSE(ResolveDebuginfodOptions(options, &config).ok());
Expand Down
19 changes: 19 additions & 0 deletions test/debuginfod_integrationtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ TEST_F(DebuginfodIntegrationTest, RemoteOnlyAndCacheReuse) {
EXPECT_THAT(server_->requests(), IsEmpty());
}

TEST_F(DebuginfodIntegrationTest, ImaTagsFromEnvironment) {
auto result = Bundle(
{"--debuginfod"},
{"DEBUGINFOD_URLS=ima:enforcing " + server_->url() + "/ok ima:ignore"});
EXPECT_THAT(result.err, HasSubstr("IMA verification is not supported"));
ExpectSymbolized(bundle_);
EXPECT_THAT(server_->requests(), ElementsAre(OkRequest()));
}

TEST_F(DebuginfodIntegrationTest, DisabledWarnsEvenWhenQuiet) {
auto result =
Bundle({"--quiet"}, {"DEBUGINFOD_URLS=" + server_->url() + "/ok"});
Expand Down Expand Up @@ -480,6 +489,16 @@ TEST_F(DebuginfodIntegrationTest, SymbolizeUtility) {
EXPECT_THAT(result.err, IsEmpty());
}

TEST_F(DebuginfodIntegrationTest, SymbolizeWithImaTags) {
auto result = RunShell(
{"util", "symbolize", "--quiet", "--debuginfod", "--debuginfod-urls",
"ima:enforcing " + server_->url() + "/ok ima:ignore",
"--debuginfod-cache-path", cache_, trace_});
EXPECT_EQ(result.exit_code, 0) << result.err;
EXPECT_THAT(result.out, HasSubstr(kSymbol));
EXPECT_THAT(result.err, IsEmpty());
}

TEST_F(DebuginfodIntegrationTest, QueryWithoutLocalBinaries) {
auto result = RunShell(
{"query", "--quiet", trace_, "SELECT name FROM stack_profile_symbol",
Expand Down
Loading