Skip to content

If load config size is larger than reported, overwrite#1050

Open
yardenshafir wants to merge 1 commit intomasterfrom
yarden/use-correct-load-config-size
Open

If load config size is larger than reported, overwrite#1050
yardenshafir wants to merge 1 commit intomasterfrom
yarden/use-correct-load-config-size

Conversation

@yardenshafir
Copy link
Copy Markdown
Contributor

No description provided.

@yardenshafir yardenshafir requested a review from woodruffw January 6, 2023 15:43
@yardenshafir yardenshafir force-pushed the yarden/use-correct-load-config-size branch from bc1649f to fa57793 Compare January 6, 2023 16:03
checksec.cpp Outdated
std::cerr << "Warn: load config larger than reported by data directory entry,"
<< " overwriting"
<< "\n";
memcpy(&loadConfig, loadConfigData.data(), loadConfig.Size);
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.

We probably need a bounds check on loadConfigData.data() + loadConfig.Size, right?

LGTM otherwise!

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.

Don't think so, since the total data size is loadConfig.Size, we just overwrite the data we already copies earlier, not add to it.

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 meant for the PE container itself -- I could be wrong, but I think someone could modify a PE to set the load config's size to a size larger than the PE itself, meaning that loadConfigData.data() + loadConfig.Size would point past the end of the PE in memory.

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.

Ah, I see what you mean. Yeah, I'll add that check!

@yardenshafir yardenshafir force-pushed the yarden/use-correct-load-config-size branch 3 times, most recently from 85c33c0 to 1a5a52b Compare January 6, 2023 16:42
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.

2 participants