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.
Shared libs
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Shared libs
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.
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.