Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-30 Thread Andrew Morton
On Wed, 27 Jun 2007 15:11:49 -0700 Nicholas Miell <[EMAIL PROTECTED]> wrote: > I don't think the security issues with this will ever make it > worthwhile. eh, security issues are a corner case. The vast majority of Linux machines are used by a single user who has admin access anyway. This

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-30 Thread Andrew Morton
On Wed, 27 Jun 2007 15:11:49 -0700 Nicholas Miell [EMAIL PROTECTED] wrote: I don't think the security issues with this will ever make it worthwhile. eh, security issues are a corner case. The vast majority of Linux machines are used by a single user who has admin access anyway. This includes

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Davide Libenzi wrote: > On Wed, 27 Jun 2007, Nicholas Miell wrote: > > > 1) euid is not sufficient, you need to store away arbitrary LSM > > information and call LSM hooks to decide security equivalence. The same > > applies to VServer or whatever other container system you

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Nicholas Miell wrote: > 1) euid is not sufficient, you need to store away arbitrary LSM > information and call LSM hooks to decide security equivalence. The same > applies to VServer or whatever other container system you use. The EUID that is used now, can easily be any

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Nicholas Miell
On Wed, 2007-06-27 at 11:45 -0700, Davide Libenzi wrote: > On Wed, 27 Jun 2007, Hugh Dickins wrote: > > > On Wed, 27 Jun 2007, Davide Libenzi wrote: > > > On Wed, 27 Jun 2007, Hugh Dickins wrote: > > > > > > > In honesty, I should add that I dislike and distrust Davide's > > > > MAP_NOZERO very

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Ulrich Drepper wrote: > On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: > > The absolute virtual addresses are randomized, yes; but do a sequence > > of mmaps and they come back adjacent to each other, and so mergable. > > Or does your distro include a kernel patch to

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Rik van Riel wrote: > Ulrich Drepper wrote: > > On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: > > > Not so: if an mmap can be done by extending either adjacent vma (prot > > > and flags and file and offset all match up), that's what's done and no > > > separate vma is

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Rik van Riel
Ulrich Drepper wrote: On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And adjacent vmas get merged when mprotect removes

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Ulrich Drepper
On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: The absolute virtual addresses are randomized, yes; but do a sequence of mmaps and they come back adjacent to each other, and so mergable. Or does your distro include a kernel patch to randomize them relative to each other? Each individual

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: > On Wed, 27 Jun 2007, Davide Libenzi wrote: > > On Wed, 27 Jun 2007, Hugh Dickins wrote: > > > > > In honesty, I should add that I dislike and distrust Davide's > > > MAP_NOZERO very much indeed! Would much rather leave my cpus > > > spending a little

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Davide Libenzi wrote: > On Wed, 27 Jun 2007, Hugh Dickins wrote: > > > In honesty, I should add that I dislike and distrust Davide's > > MAP_NOZERO very much indeed! Would much rather leave my cpus > > spending a little time in clear_page(). A uid in struct page > > (though

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: > In honesty, I should add that I dislike and distrust Davide's > MAP_NOZERO very much indeed! Would much rather leave my cpus > spending a little time in clear_page(). A uid in struct page > (though I'm sure we could find somewhere to tuck it away) - >

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Ulrich Drepper wrote: > On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: > > Not so: if an mmap can be done by extending either adjacent vma (prot > > and flags and file and offset all match up), that's what's done and no > > separate vma is created. (And adjacent vmas get

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Ulrich Drepper
On 6/27/07, Hugh Dickins <[EMAIL PROTECTED]> wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And adjacent vmas get merged when mprotect removes the difference in

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Tue, 26 Jun 2007, Ulrich Drepper wrote: > On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: > > I acutally have the code for it, but I never posted it since it did not > > receive a too warm review (and the only user was the fdmap thingy). > > Only user of sys_indirect? There will be

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: > On Tue, 26 Jun 2007, Ulrich Drepper wrote: > > On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: > > > > > OTOH glibc could implement __morecore using mmap(MAP_NOZERO), and hence > > > brk2() would not be needed, no? > > > > No. mmap calls create

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Tue, 26 Jun 2007, Ulrich Drepper wrote: > On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: > > > OTOH glibc could implement __morecore using mmap(MAP_NOZERO), and hence > > brk2() would not be needed, no? > > No. mmap calls create individual VMAs which gets expensive. There > are also

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Tue, 26 Jun 2007, Ulrich Drepper wrote: On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: OTOH glibc could implement __morecore using mmap(MAP_NOZERO), and hence brk2() would not be needed, no? No. mmap calls create individual VMAs which gets expensive. There are also some

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: On Tue, 26 Jun 2007, Ulrich Drepper wrote: On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: OTOH glibc could implement __morecore using mmap(MAP_NOZERO), and hence brk2() would not be needed, no? No. mmap calls create individual VMAs

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Tue, 26 Jun 2007, Ulrich Drepper wrote: On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: I acutally have the code for it, but I never posted it since it did not receive a too warm review (and the only user was the fdmap thingy). Only user of sys_indirect? There will be quite a few

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Ulrich Drepper
On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And adjacent vmas get merged when mprotect removes the difference in

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Ulrich Drepper wrote: On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And adjacent vmas get merged

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: In honesty, I should add that I dislike and distrust Davide's MAP_NOZERO very much indeed! Would much rather leave my cpus spending a little time in clear_page(). A uid in struct page (though I'm sure we could find somewhere to tuck it away) - the

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Davide Libenzi wrote: On Wed, 27 Jun 2007, Hugh Dickins wrote: In honesty, I should add that I dislike and distrust Davide's MAP_NOZERO very much indeed! Would much rather leave my cpus spending a little time in clear_page(). A uid in struct page (though I'm sure

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Hugh Dickins wrote: On Wed, 27 Jun 2007, Davide Libenzi wrote: On Wed, 27 Jun 2007, Hugh Dickins wrote: In honesty, I should add that I dislike and distrust Davide's MAP_NOZERO very much indeed! Would much rather leave my cpus spending a little time in

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Ulrich Drepper
On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: The absolute virtual addresses are randomized, yes; but do a sequence of mmaps and they come back adjacent to each other, and so mergable. Or does your distro include a kernel patch to randomize them relative to each other? Each individual mmap

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Rik van Riel
Ulrich Drepper wrote: On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And adjacent vmas get merged when mprotect removes the

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Rik van Riel wrote: Ulrich Drepper wrote: On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: Not so: if an mmap can be done by extending either adjacent vma (prot and flags and file and offset all match up), that's what's done and no separate vma is created. (And

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Hugh Dickins
On Wed, 27 Jun 2007, Ulrich Drepper wrote: On 6/27/07, Hugh Dickins [EMAIL PROTECTED] wrote: The absolute virtual addresses are randomized, yes; but do a sequence of mmaps and they come back adjacent to each other, and so mergable. Or does your distro include a kernel patch to randomize

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Nicholas Miell
On Wed, 2007-06-27 at 11:45 -0700, Davide Libenzi wrote: On Wed, 27 Jun 2007, Hugh Dickins wrote: On Wed, 27 Jun 2007, Davide Libenzi wrote: On Wed, 27 Jun 2007, Hugh Dickins wrote: In honesty, I should add that I dislike and distrust Davide's MAP_NOZERO very much indeed!

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Nicholas Miell wrote: 1) euid is not sufficient, you need to store away arbitrary LSM information and call LSM hooks to decide security equivalence. The same applies to VServer or whatever other container system you use. The EUID that is used now, can easily be any

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-27 Thread Davide Libenzi
On Wed, 27 Jun 2007, Davide Libenzi wrote: On Wed, 27 Jun 2007, Nicholas Miell wrote: 1) euid is not sufficient, you need to store away arbitrary LSM information and call LSM hooks to decide security equivalence. The same applies to VServer or whatever other container system you use.

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Rik van Riel <[EMAIL PROTECTED]> wrote: After going through the first malloc()/free() cycle, surely the memory will no longer be zeroed on the second malloc() ? If returned to the system, sure. What makes the first brk malloc so special? If the memory is zeroed it needs not be

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: I acutally have the code for it, but I never posted it since it did not receive a too warm review (and the only user was the fdmap thingy). Only user of sys_indirect? There will be quite a few right away. Every syscall that returns a file

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Rik van Riel
Ulrich Drepper wrote: On 6/26/07, Rik van Riel <[EMAIL PROTECTED]> wrote: Since programs can get back free()d memory after a malloc(), with the old contents of the memory intact, surely your MAP_NONZERO behavior could be the default for programs that can get away with it? Maybe we could use

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
On Tue, 26 Jun 2007, Ulrich Drepper wrote: > On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: > > The following patch implements the sys_brk2() syscall, that nothing is > > other than a sys_brk() with an extra "flags" parameter. > > Shouldn't we wait for Linus' sys_indirect to arrive and

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Davide Libenzi <[EMAIL PROTECTED]> wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra "flags" parameter. Shouldn't we wait for Linus' sys_indirect to arrive and make this another syscall which takes advantage of it? -

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Rik van Riel <[EMAIL PROTECTED]> wrote: Since programs can get back free()d memory after a malloc(), with the old contents of the memory intact, surely your MAP_NONZERO behavior could be the default for programs that can get away with it? Maybe we could use some magic ELF header,

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
On Tue, 26 Jun 2007, Rik van Riel wrote: > Davide Libenzi wrote: > > The following patch implements the sys_brk2() syscall, that nothing is > > other than a sys_brk() with an extra "flags" parameter. This can be used > > to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero > >

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Rik van Riel
Davide Libenzi wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra "flags" parameter. This can be used to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero pages if possible. Since programs can get back free()d

[patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra "flags" parameter. This can be used to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero pages if possible. Signed-off-by: Davide Libenzi <[EMAIL PROTECTED]> - Davide

[patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra flags parameter. This can be used to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero pages if possible. Signed-off-by: Davide Libenzi [EMAIL PROTECTED] - Davide

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Rik van Riel
Davide Libenzi wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra flags parameter. This can be used to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero pages if possible. Since programs can get back free()d

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
On Tue, 26 Jun 2007, Rik van Riel wrote: Davide Libenzi wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra flags parameter. This can be used to pass the new MAP_NOZERO bit, to ask the kernel to hand over non-zero pages if

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Rik van Riel [EMAIL PROTECTED] wrote: Since programs can get back free()d memory after a malloc(), with the old contents of the memory intact, surely your MAP_NONZERO behavior could be the default for programs that can get away with it? Maybe we could use some magic ELF header,

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra flags parameter. Shouldn't we wait for Linus' sys_indirect to arrive and make this another syscall which takes advantage of it? - To

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Davide Libenzi
On Tue, 26 Jun 2007, Ulrich Drepper wrote: On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: The following patch implements the sys_brk2() syscall, that nothing is other than a sys_brk() with an extra flags parameter. Shouldn't we wait for Linus' sys_indirect to arrive and make this

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Rik van Riel
Ulrich Drepper wrote: On 6/26/07, Rik van Riel [EMAIL PROTECTED] wrote: Since programs can get back free()d memory after a malloc(), with the old contents of the memory intact, surely your MAP_NONZERO behavior could be the default for programs that can get away with it? Maybe we could use some

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Davide Libenzi [EMAIL PROTECTED] wrote: I acutally have the code for it, but I never posted it since it did not receive a too warm review (and the only user was the fdmap thingy). Only user of sys_indirect? There will be quite a few right away. Every syscall that returns a file

Re: [patch 2/3] MAP_NOZERO - implement sys_brk2()

2007-06-26 Thread Ulrich Drepper
On 6/26/07, Rik van Riel [EMAIL PROTECTED] wrote: After going through the first malloc()/free() cycle, surely the memory will no longer be zeroed on the second malloc() ? If returned to the system, sure. What makes the first brk malloc so special? If the memory is zeroed it needs not be