Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread H.J. Lu
On Wed, Dec 11, 2013 at 11:43 AM, H. Peter Anvin wrote: > On 12/11/2013 10:21 AM, H.J. Lu wrote: >> On Wed, Dec 11, 2013 at 9:49 AM, H. Peter Anvin wrote: >>> On 12/11/2013 05:41 AM, H.J. Lu wrote: When -Ttext-segment=XXX is used, the program is expected to load at XXX, regardless

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread H. Peter Anvin
On 12/11/2013 10:21 AM, H.J. Lu wrote: > On Wed, Dec 11, 2013 at 9:49 AM, H. Peter Anvin wrote: >> On 12/11/2013 05:41 AM, H.J. Lu wrote: >>> >>> When -Ttext-segment=XXX is used, the program is expected to >>> load at XXX, regardless -pie is used or not. >>> >> >> "Expected to" by whom? I think t

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread H.J. Lu
On Wed, Dec 11, 2013 at 9:49 AM, H. Peter Anvin wrote: > On 12/11/2013 05:41 AM, H.J. Lu wrote: >> >> When -Ttext-segment=XXX is used, the program is expected to >> load at XXX, regardless -pie is used or not. >> > > "Expected to" by whom? I think that is at the very best a matter of > interpreta

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread H. Peter Anvin
On 12/11/2013 05:41 AM, H.J. Lu wrote: > > When -Ttext-segment=XXX is used, the program is expected to > load at XXX, regardless -pie is used or not. > "Expected to" by whom? I think that is at the very best a matter of interpretation. -hpa -- To unsubscribe from this list: send the

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread H.J. Lu
On Wed, Dec 11, 2013 at 5:36 AM, Jiri Kosina wrote: > On Mon, 9 Dec 2013, H.J. Lu wrote: > >> >> so that he could load his program compiled as PIE above 4GB. >> >> If kernel is changed not to honor it, his program won't work any more. >> >> In normal case, PIE has zero vaddr and this doesn't apply

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-11 Thread Jiri Kosina
On Mon, 9 Dec 2013, H.J. Lu wrote: > >> so that he could load his program compiled as PIE above 4GB. > >> If kernel is changed not to honor it, his program won't work any more. > >> In normal case, PIE has zero vaddr and this doesn't apply. > >> > > > > That doesn't seem to be PIE at all, and if i

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 4:37 PM, H. Peter Anvin wrote: > On 12/09/2013 03:53 PM, H.J. Lu wrote: x86-64 small model is limited to 4GB in size. You can't build a dynamic executable in small model larger than 4GB. There are medium and large models. But they are slower than >

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
On 12/09/2013 03:53 PM, H.J. Lu wrote: >>> >>> x86-64 small model is limited to 4GB in size. You can't build >>> a dynamic executable in small model larger than 4GB. >>> >>> There are medium and large models. But they are slower than >>> small models as well as small models in PIE. Also there ar

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 3:35 PM, H. Peter Anvin wrote: > On 12/09/2013 01:44 PM, H.J. Lu wrote: >> On Mon, Dec 9, 2013 at 1:39 PM, H. Peter Anvin wrote: >>> On 12/09/2013 01:03 PM, H.J. Lu wrote: No, please don't do that. Normally, PIE has zero load address and kernel can load it a

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
On 12/09/2013 01:44 PM, H.J. Lu wrote: > On Mon, Dec 9, 2013 at 1:39 PM, H. Peter Anvin wrote: >> On 12/09/2013 01:03 PM, H.J. Lu wrote: >>> >>> No, please don't do that. Normally, PIE has zero load address and kernel >>> can load it anywhere. There are multiple reasons why PIE has non-zero >>>

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 2:01 PM, H. Peter Anvin wrote: > On 12/09/2013 01:59 PM, H.J. Lu wrote: >> >> A Linux/x86-64 user came to me at the end of 2008. He needed >> to load an executable above 4GB. I added -Ttext-segment option >> to linker: >> >> https://sourceware.org/ml/binutils/2009-01/msg00

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
On 12/09/2013 01:59 PM, H.J. Lu wrote: > > A Linux/x86-64 user came to me at the end of 2008. He needed > to load an executable above 4GB. I added -Ttext-segment option > to linker: > > https://sourceware.org/ml/binutils/2009-01/msg00173.html > > so that he could load his program compiled as P

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 1:53 PM, H. Peter Anvin wrote: > On 12/09/2013 01:52 PM, H.J. Lu wrote: >>> >>> Why is that? It would seem to be a big difference between a relocatable >>> binary (PIE) and one with a load address fixed at link time. >>> >> >> PIE with non-zero vaddr should be loaded at non

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 1:49 PM, H. Peter Anvin wrote: >> >>> PT_LOAD being non-zero causing randomization to be turned off seems like >>> quite unexpected behavior to me, with a great potential to cause a lot of >>> confusion. >> >> There should be no difference between dynamic executable and PIE

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
On 12/09/2013 01:52 PM, H.J. Lu wrote: >> >> Why is that? It would seem to be a big difference between a relocatable >> binary (PIE) and one with a load address fixed at link time. >> > > PIE with non-zero vaddr should be loaded at non-zero > vaddr. Otherwise, PIE may not work as expected. > P

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread Jiri Kosina
On Mon, 9 Dec 2013, H.J. Lu wrote: > >> No, please don't do that. Normally, PIE has zero load address and kernel > >> can load it anywhere. There are multiple reasons why PIE has non-zero > >> load address. Saying you need to load a program above 4GB under x86-64, > >> you can't do that with no

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
> >> PT_LOAD being non-zero causing randomization to be turned off seems like >> quite unexpected behavior to me, with a great potential to cause a lot of >> confusion. > > There should be no difference between dynamic executable and PIE > with non-zero vaddr when choosing where to load them. >

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 1:13 PM, Jiri Kosina wrote: > On Mon, 9 Dec 2013, H.J. Lu wrote: > >> >> Normally, a PIE executable has zero virtual address on the first PT_LOAD >> >> segment and kernel will load such executable at random address when >> >> randomization is enabled. If randomization is di

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 1:39 PM, H. Peter Anvin wrote: > On 12/09/2013 01:03 PM, H.J. Lu wrote: >> >> No, please don't do that. Normally, PIE has zero load address and kernel >> can load it anywhere. There are multiple reasons why PIE has non-zero >> load address. Saying you need to load a progr

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H. Peter Anvin
On 12/09/2013 01:03 PM, H.J. Lu wrote: > > No, please don't do that. Normally, PIE has zero load address and kernel > can load it anywhere. There are multiple reasons why PIE has non-zero > load address. Saying you need to load a program above 4GB under x86-64, > you can't do that with normal d

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread Jiri Kosina
On Mon, 9 Dec 2013, H.J. Lu wrote: > >> Normally, a PIE executable has zero virtual address on the first PT_LOAD > >> segment and kernel will load such executable at random address when > >> randomization is enabled. If randomization is disabled, kernel will load > >> it at a fixed address. But

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread H.J. Lu
On Mon, Dec 9, 2013 at 12:57 PM, Jiri Kosina wrote: > On Mon, 9 Dec 2013, H.J. Lu wrote: > >> Normally, a PIE executable has zero virtual address on the first PT_LOAD >> segment and kernel will load such executable at random address when >> randomization is enabled. If randomization is disabled,

Re: [PATCH] binfmt_elf: fix PIE load with randomization disabled

2013-12-09 Thread Jiri Kosina
On Mon, 9 Dec 2013, H.J. Lu wrote: > Normally, a PIE executable has zero virtual address on the first PT_LOAD > segment and kernel will load such executable at random address when > randomization is enabled. If randomization is disabled, kernel will load > it at a fixed address. But if a PIE exe