Skip to contentSkip to conversation

Understanding Linux addr space, malloc, and heap

DISCUSSION Bodo Eggert 3 participants 3 messages Oct 23, 2005 8 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 8 lines · Kyle Moffett
Quoted 2 lines · Vincent W. Freeh

I guess I live in a different world. I do lots of things I'm not "supposed" to do.

So why are you complaining that it doesn't work? "Doctor, it hurts when I use my toes to hold a nail as I hammer it in!" "Well don't do that then!"

I'm not supposed to run linux on i386, ask Bill. Why do I do it then?

Quoted 4 lines
Quoted 1 line

Moreover, it is very sensible and usable to mprotect malloc pages.

DANGER! DANGER WILL ROBINSON! DANGER! malloc() is *NOT* guaranteed or even theoretically implemented to return pages.

If you allocate a block of 2*PAGESIZE-1 bytes, *any* allocation method is *guaranteed* return at least one complete page. (BTW: The example from the manpage is wrong since it does only make sure the starting address is on the page, but not that the end of the protected memory is within the allocated area. Whom should I contact?)

But even if Vincend makes the next malloc/free/whatever to be fubar, or if he made the world explode, mprotect is still required to report an error if the requested action failed. If it doesn't do that for mprotecting _any_ range, no matter how strange it may be, it is broken.

Signature · 2 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
#9 lore raw
Quoted 4 lines

But even if Vincend makes the next malloc/free/whatever to be fubar, or if he made the world explode, mprotect is still required to report an error if the requested action failed.

but.. there's no proof yet that it failed...

#10 lore raw
Quoted 3 lines · Arjan van de Ven
Quoted 1 line

But even if Vincend makes the next malloc/free/whatever to be fubar, or if he made the world explode, mprotect is still required to report an error if the requested action failed.

but.. there's no proof yet that it failed...

Precisely. The only code sample he's sent that exhibits this "problem" is buggy because it checks the wrong addresses for protected status. In any case, if you _were_ going to try to change protection bits on malloc()ed memory, you would need to make _damn_sure_ that you didn't change the protection bits on internal data structures that malloc uses to keep track of allocations. If you remove read or write privs on malloc-internal linked-list pointers, an attempt to malloc() or free() memory might (and probably will) crash.

Cheers,
Kyle Moffett

--
I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated.
-- Poul Anderson