Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <la_putin> is musl's malloc() compatible with mprotect
  2. <la_putin> as mprotect is giving me invalid argument when i try to use it with a implimentation of malloc() http://rextester.com/JTJGO67005
  3. <feepbot> mprotect, C (gcc) - rextester
  4. <la_putin> so if i used musl's malloc instead would i still get invalid argument?
  5. <la_putin> or would mprotect need to be implimented aswell like realloc and free does as it is not compatible with the malloc implimentation
  6. <ammar2> is there a reason you're using mprotect with malloc instead of mmap
  7. <Maxpm> la_putin: mprotect needs a page-aligned address. Could that be it?
  8. <la_putin> to figure out the start of the heap
  9. <la_putin> and im not sure as as far as ik, it is just this [ unsigned long * heap_end = sbrk(0); mprotect (heap_end, 0, PROT_READ|PROT_WRITE); ]
  10. <la_putin> im not sure why it requires a malloc(0x1000) for it to work tho
  11. <la_putin> although the malloc should not apply as the length is 0 so it is mprotect'ing 0 bytes
  12. <Maxpm> Unless I'm missing something, heap_end is not page-aligned?
  13. <la_putin> it works if i use the libc malloc()
  14. <Maxpm> By chance, maybe.
  15. <la_putin> actually it works even without malloc
  16. <la_putin> although then it cannot determine the heap start
  17. <la_putin> this is the full function http://coliru.stacked-crooked.com/a/bc6fb347ce183a3f and this is what it is supposed to do http://coliru.stacked-crooked.com/a/841cec3ccd3948b0
  18. <feepbot> Coliru Viewer
  19. <la_putin> the 1st is with the malloc implimentation and the 2nd is without it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement