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

Excess memory allocation #2

Open
Smattr opened this issue May 4, 2016 · 1 comment
Open

Excess memory allocation #2

Smattr opened this issue May 4, 2016 · 1 comment

Comments

@Smattr
Copy link

Smattr commented May 4, 2016

IIUC 17d4a60 modified ptrace_writemem to expect the size of its input to be word-aligned. It did this by pushing the alignment adjustment outwards into ptrace_writemem's callers. However, the new alignment adjustment is not equivalent. In particular, prior to this commit the size would not be adjusted if it was already word-aligned. Following this commit a word-aligned size is incremented by another word. I'm unsure if this was intentional or not, but it looks to me as if this extra word is unnecessary and goes unused. If you agree with this assessment and are happy to take a pull request, I can have a go at changing this to only increase the size when it's not already word-aligned. Thanks!

@dismantl
Copy link
Owner

You're right, it would add an extra word if the payload length was already word-aligned. Since the newly allocated payload buffer is filled with NOPs before the shellcode is copied into it, it shouldn't affect the functionality. But for the sake of code cleanliness, I'm happy to accept a pull request that fixes this. Thanks for pointing it out.

Smattr added a commit to Smattr/linux-injector that referenced this issue Jul 29, 2016
Prior to this commit, a word-aligned payload would result in an allocation that
was one word larger than required. This commit modifies the rounding logic so we
only round up if the payload is not already word-aligned.

Closes dismantl#2
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

No branches or pull requests

2 participants