Page 1 of 1
Shared libs
Posted: Mon Jul 14, 2003 10:53 am
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.
Re:Shared libs
Posted: Mon Jul 14, 2003 11:33 am
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.