Skip to content

i#7823: Look for MEMPROT_EXEC when looking for the executable#7824

Open
palmer-dabbelt wants to merge 1 commit intoDynamoRIO:masterfrom
palmer-dabbelt:i7823
Open

i#7823: Look for MEMPROT_EXEC when looking for the executable#7824
palmer-dabbelt wants to merge 1 commit intoDynamoRIO:masterfrom
palmer-dabbelt:i7823

Conversation

@palmer-dabbelt
Copy link
Copy Markdown
Contributor

I don't know the larger context of what's going on here, but just from looking at the place of the assent it seems somewhat sane to be checking for MEMPROT_EXEC here (or possibly even above where we're looking for MEMPROT_READ) -- we're looking for the executable, so the mapping must be executable.

This makes the assert stop triggering for us, but I'm not sure if it has some other issues.

Fixes #7823

Comment thread core/unix/os.c Outdated
}
# endif
if (found_exec) {
if (found_exec && TEST(MEMPROT_EXEC, iter->prot)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR description mentions there were some ASSERT crashes that are fixed by this change (I assume you were referring to the L10307 check). Can you check why found_exec was set to true in that case? E.g., was it that the L10273 comparison found a region named exactly like get_application_name() that's somehow not executable? Or is it the anonymous region for the header (L10274; but executable_start == iter->vm_start should be true already for that case)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Folly's symbolizer maps the executable a second time as read-only. I don't know the specifics of why it feels it needs to do that, but here's the code: https://github.com/facebook/folly/blob/93187f748cc5d9aebdffa58e462c146a27cfb713/folly/debugging/symbolizer/Elf.cpp#L108 .

FWIW: it's also using MAP_SHARED, which seems odd, but MAP_PRIVATE has the same behavior in DynamoRIO so at least that's not the issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. Can we augment the L10273 comparison to also check for MEMPROT_EXEC? That seems better to me as it avoids changing the handling for the anon header case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ya, if you think that's safe then it's probably the better bet.

@abhinav92003 abhinav92003 self-requested a review March 2, 2026 18:04
I don't know the larger context of what's going on here, but just from
looking at the place of the assent it seems somewhat sane to be checking
for MEMPROT_EXEC here (or possibly even above where we're looking for
MEMPROT_READ) -- we're looking for the executable, so the mapping must
be executable.

This makes the assert stop triggering for us, but I'm not sure if it has
some other issues.

Fixes DynamoRIO#7823

Signed-off-by: Palmer Dabbelt <palmerdabbelt@meta.com>
@abhinav92003
Copy link
Copy Markdown
Contributor

@palmer-dabbelt
Copy link
Copy Markdown
Contributor Author

Please don't force push shared branches; see https://dynamorio.org/page_code_reviews.html#sec_code_review_non_member and https://dynamorio.org/page_code_reviews.html#autotoc_md118.

oh sorry, I'll read the docs. Do you want me to reset the branch to where it was?

Comment thread core/unix/os.c
image = true;
DODEBUG({ map_type = "ELF SO"; });
} else if (TEST(MEMPROT_READ, iter->prot) &&
} else if (TEST(MEMPROT_READ | MEMPROT_EXEC, iter->prot) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought the consensus in the other comment thread was to add this MEMPROT_EXEC check to L10288 (the line #s have changed now it seems; maybe because the force-push also updated the branch baseline?). Like I said, by doing that, we can avoid making any assumption about the anon region case (see L10289).

Does this solve your crash?

@abhinav92003
Copy link
Copy Markdown
Contributor

Please don't force push shared branches; see https://dynamorio.org/page_code_reviews.html#sec_code_review_non_member and https://dynamorio.org/page_code_reviews.html#autotoc_md118.

oh sorry, I'll read the docs. Do you want me to reset the branch to where it was?

Not necessary. The changes in this PR are simple enough that losing that history didn't make reviewing much harder.

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.

ASSERT(iter->vm_start == executable_start) when a statically linked app has duplicate executable mappings

2 participants