Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-10-01 Thread Svatopluk Kraus
On Fri, Sep 7, 2012 at 9:40 PM, John Baldwin j...@freebsd.org wrote: On Friday, September 07, 2012 2:41:20 pm Konstantin Belousov wrote: I think these would be rare? There's no good reason for anything to write to a shared library that I can think of. install(1) does an atomic rename to

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Svatopluk Kraus
On Tue, Sep 4, 2012 at 3:00 PM, Konstantin Belousov kostik...@gmail.com wrote: On Tue, Sep 04, 2012 at 02:49:07PM +0200, Svatopluk Kraus wrote: On Mon, Sep 3, 2012 at 2:46 PM, Konstantin Belousov kostik...@gmail.com wrote: On Mon, Sep 03, 2012 at 12:35:08PM +0200, Svatopluk Kraus wrote:

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Svatopluk Kraus
On Tue, Sep 4, 2012 at 6:00 PM, John Baldwin j...@freebsd.org wrote: On Tuesday, September 04, 2012 9:00:39 am Konstantin Belousov wrote: On Tue, Sep 04, 2012 at 02:49:07PM +0200, Svatopluk Kraus wrote: On Mon, Sep 3, 2012 at 2:46 PM, Konstantin Belousov kostik...@gmail.com wrote: On Mon,

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Konstantin Belousov
On Fri, Sep 07, 2012 at 05:12:37PM +0200, Svatopluk Kraus wrote: On Tue, Sep 4, 2012 at 6:00 PM, John Baldwin j...@freebsd.org wrote: On Tuesday, September 04, 2012 9:00:39 am Konstantin Belousov wrote: On Tue, Sep 04, 2012 at 02:49:07PM +0200, Svatopluk Kraus wrote: On Mon, Sep 3, 2012 at

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread John Baldwin
On Friday, September 07, 2012 12:02:08 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 05:12:37PM +0200, Svatopluk Kraus wrote: On Tue, Sep 4, 2012 at 6:00 PM, John Baldwin j...@freebsd.org wrote: On Tuesday, September 04, 2012 9:00:39 am Konstantin Belousov wrote: 2. I do not see

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Konstantin Belousov
On Fri, Sep 07, 2012 at 12:21:37PM -0400, John Baldwin wrote: On Friday, September 07, 2012 12:02:08 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 05:12:37PM +0200, Svatopluk Kraus wrote: On Tue, Sep 4, 2012 at 6:00 PM, John Baldwin j...@freebsd.org wrote: On Tuesday, September

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread John Baldwin
On Friday, September 07, 2012 12:42:18 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 12:21:37PM -0400, John Baldwin wrote: On Friday, September 07, 2012 12:02:08 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 05:12:37PM +0200, Svatopluk Kraus wrote: On Tue, Sep 4, 2012 at

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Konstantin Belousov
On Fri, Sep 07, 2012 at 02:05:28PM -0400, John Baldwin wrote: On Friday, September 07, 2012 12:42:18 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 12:21:37PM -0400, John Baldwin wrote: On Friday, September 07, 2012 12:02:08 pm Konstantin Belousov wrote: On Fri, Sep 07, 2012 at

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Ian Lepore
On Fri, 2012-09-07 at 21:41 +0300, Konstantin Belousov wrote: After a second thought, I do not like your proposal as well. +x is set for shebang scripts, and allowing PROT_EXEC to set VV_TEXT for them means that such scripts are subject for write denial. You say that like it's a bad thing. I

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Konstantin Belousov
On Fri, Sep 07, 2012 at 12:48:19PM -0600, Ian Lepore wrote: On Fri, 2012-09-07 at 21:41 +0300, Konstantin Belousov wrote: After a second thought, I do not like your proposal as well. +x is set for shebang scripts, and allowing PROT_EXEC to set VV_TEXT for them means that such scripts are

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread Ian Lepore
On Fri, 2012-09-07 at 21:53 +0300, Konstantin Belousov wrote: On Fri, Sep 07, 2012 at 12:48:19PM -0600, Ian Lepore wrote: On Fri, 2012-09-07 at 21:41 +0300, Konstantin Belousov wrote: After a second thought, I do not like your proposal as well. +x is set for shebang scripts, and allowing

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-07 Thread John Baldwin
On Friday, September 07, 2012 2:41:20 pm Konstantin Belousov wrote: I think these would be rare? There's no good reason for anything to write to a shared library that I can think of. install(1) does an atomic rename to swap in the new libraries already. After a second thought, I

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-04 Thread Svatopluk Kraus
On Mon, Sep 3, 2012 at 2:46 PM, Konstantin Belousov kostik...@gmail.com wrote: On Mon, Sep 03, 2012 at 12:35:08PM +0200, Svatopluk Kraus wrote: Hi, I found out that while the running excecutables and a dynamic linker are protected against writing (ETXTBSY), the loaded shared libraries are

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-04 Thread Konstantin Belousov
On Tue, Sep 04, 2012 at 02:49:07PM +0200, Svatopluk Kraus wrote: On Mon, Sep 3, 2012 at 2:46 PM, Konstantin Belousov kostik...@gmail.com wrote: On Mon, Sep 03, 2012 at 12:35:08PM +0200, Svatopluk Kraus wrote: Hi, I found out that while the running excecutables and a dynamic linker

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-04 Thread John Baldwin
On Tuesday, September 04, 2012 9:00:39 am Konstantin Belousov wrote: On Tue, Sep 04, 2012 at 02:49:07PM +0200, Svatopluk Kraus wrote: On Mon, Sep 3, 2012 at 2:46 PM, Konstantin Belousov kostik...@gmail.com wrote: On Mon, Sep 03, 2012 at 12:35:08PM +0200, Svatopluk Kraus wrote: Hi,

[patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-03 Thread Svatopluk Kraus
Hi, I found out that while the running excecutables and a dynamic linker are protected against writing (ETXTBSY), the loaded shared libraries are not protected. The libraries are mapped by mmap() in dynamic linker (rtld) and there is no way how to set VV_TEXT flag on the libraries vnodes in

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-03 Thread Andriy Gapon
on 03/09/2012 13:35 Svatopluk Kraus said the following: After some investigation, it looks that VV_TEXT once set on a vnode remains set until last reference on the vnode is left. There was an idea to turn VV_TEXT flag into a v_text counter. Maybe something like that would be useful indeed? --

Re: [patch] mmap() MAP_TEXT implementation (to use for shared libraries)

2012-09-03 Thread Konstantin Belousov
On Mon, Sep 03, 2012 at 12:35:08PM +0200, Svatopluk Kraus wrote: Hi, I found out that while the running excecutables and a dynamic linker are protected against writing (ETXTBSY), the loaded shared libraries are not protected. The libraries are mapped by mmap() in dynamic linker (rtld) and