Shared libs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Curufir

Shared libs

Post by Curufir »

Simple question. What stops a malevolent application rewriting the code of a shared lib? Is it simply the r/w mechanism for pages/segments or what?

I know it's a dumb thing to ask, but my brain just ain't working today.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Shared libs

Post by Pype.Clicker »

basically yes: all the .text you load (this is, the code that you can execute) usually has read-only attributes, so you cannot alter the pages that hold a shared lib's code.

For shared lib datas (and there will eventually be some), it's common trick to use copy-on-write: initially, all the programs share the initial page, but once they attemp to modify it, they get a clean copy of the page in a new fresh page, so that the 'sharing' becomes broken for that program that now has its private copy of the page.
Post Reply