* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE @ 2016-07-26 17:16 Jeff Vander Stoep 2016-07-26 17:45 ` Catalin Marinas 0 siblings, 1 reply; 6+ messages in thread From: Jeff Vander Stoep @ 2016-07-26 17:16 UTC (permalink / raw) To: linux-arm-kernel Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a build error due to dependencies on modules. This patch makes KASLR module config options dependent on CONFIG_MODULES=y. Signed-off-by: Jeff Vander Stoep <jeffv@google.com> --- arch/arm64/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7e23f95..c9eff79 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -891,7 +891,6 @@ config RELOCATABLE config RANDOMIZE_BASE bool "Randomize the address of the kernel image" - select ARM64_MODULE_PLTS select RELOCATABLE help Randomizes the virtual address at which the kernel image is @@ -911,6 +910,8 @@ config RANDOMIZE_BASE config RANDOMIZE_MODULE_REGION_FULL bool "Randomize the module region independently from the core kernel" depends on RANDOMIZE_BASE + depends on MODULES + select ARM64_MODULE_PLTS default y help Randomizes the location of the module region without considering the -- 2.8.0.rc3.226.g39d4020 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE 2016-07-26 17:16 [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE Jeff Vander Stoep @ 2016-07-26 17:45 ` Catalin Marinas 2016-07-26 17:52 ` Ard Biesheuvel 2016-07-26 17:53 ` Catalin Marinas 0 siblings, 2 replies; 6+ messages in thread From: Catalin Marinas @ 2016-07-26 17:45 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jul 26, 2016 at 10:16:55AM -0700, Jeff Vander Stoep wrote: > Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a > build error due to dependencies on modules. This patch makes KASLR > module config options dependent on CONFIG_MODULES=y. > > Signed-off-by: Jeff Vander Stoep <jeffv@google.com> > --- > arch/arm64/Kconfig | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 7e23f95..c9eff79 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -891,7 +891,6 @@ config RELOCATABLE > > config RANDOMIZE_BASE > bool "Randomize the address of the kernel image" > - select ARM64_MODULE_PLTS > select RELOCATABLE > help > Randomizes the virtual address at which the kernel image is I thought we need the module PLTs once we randomize the kernel base, independent of whether we randomize the modules base or not. Could we do something like: select ARM64_MODULE_PLTS if MODULES Whichever way we fix this, we probably need: Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") Cc: <stable@vger.kernel.org> # 4.6+ -- Catalin ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE 2016-07-26 17:45 ` Catalin Marinas @ 2016-07-26 17:52 ` Ard Biesheuvel 2016-07-26 18:45 ` Mark Rutland 2016-07-27 6:55 ` Catalin Marinas 2016-07-26 17:53 ` Catalin Marinas 1 sibling, 2 replies; 6+ messages in thread From: Ard Biesheuvel @ 2016-07-26 17:52 UTC (permalink / raw) To: linux-arm-kernel On 26 July 2016 at 19:45, Catalin Marinas <catalin.marinas@arm.com> wrote: > On Tue, Jul 26, 2016 at 10:16:55AM -0700, Jeff Vander Stoep wrote: >> Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a >> build error due to dependencies on modules. This patch makes KASLR >> module config options dependent on CONFIG_MODULES=y. >> >> Signed-off-by: Jeff Vander Stoep <jeffv@google.com> >> --- >> arch/arm64/Kconfig | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig >> index 7e23f95..c9eff79 100644 >> --- a/arch/arm64/Kconfig >> +++ b/arch/arm64/Kconfig >> @@ -891,7 +891,6 @@ config RELOCATABLE >> >> config RANDOMIZE_BASE >> bool "Randomize the address of the kernel image" >> - select ARM64_MODULE_PLTS >> select RELOCATABLE >> help >> Randomizes the virtual address at which the kernel image is > > I thought we need the module PLTs once we randomize the kernel base, > independent of whether we randomize the modules base or not. Indeed. The module region is always randomized with KASLR, but either fully (i.e., anywhere in the vmalloc region) or partially, in which case a random 128 MB range is selected that also covers vmlinux's .text segment, allowing jumps without veneers. However, since this range is part of the ordinary vmalloc space, there is a >0 probability that other allocations may exhaust it before you have loaded all your modules, in which case the module loader will fall back to ordinary vmalloc region allocations, which are most likely too far away to be resolved without PLTs > Could we do > something like: > > select ARM64_MODULE_PLTS if MODULES > > Whichever way we fix this, we probably need: > > Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") > Cc: <stable@vger.kernel.org> # 4.6+ > With these changes Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE 2016-07-26 17:52 ` Ard Biesheuvel @ 2016-07-26 18:45 ` Mark Rutland 2016-07-27 6:55 ` Catalin Marinas 1 sibling, 0 replies; 6+ messages in thread From: Mark Rutland @ 2016-07-26 18:45 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jul 26, 2016 at 07:52:33PM +0200, Ard Biesheuvel wrote: > On 26 July 2016 at 19:45, Catalin Marinas <catalin.marinas@arm.com> wrote: > > On Tue, Jul 26, 2016 at 10:16:55AM -0700, Jeff Vander Stoep wrote: > >> Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a > >> build error due to dependencies on modules. This patch makes KASLR > >> module config options dependent on CONFIG_MODULES=y. > >> > >> Signed-off-by: Jeff Vander Stoep <jeffv@google.com> > >> --- > >> arch/arm64/Kconfig | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > >> index 7e23f95..c9eff79 100644 > >> --- a/arch/arm64/Kconfig > >> +++ b/arch/arm64/Kconfig > >> @@ -891,7 +891,6 @@ config RELOCATABLE > >> > >> config RANDOMIZE_BASE > >> bool "Randomize the address of the kernel image" > >> - select ARM64_MODULE_PLTS > >> select RELOCATABLE > >> help > >> Randomizes the virtual address at which the kernel image is > > > > I thought we need the module PLTs once we randomize the kernel base, > > independent of whether we randomize the modules base or not. > > Indeed. The module region is always randomized with KASLR, but either > fully (i.e., anywhere in the vmalloc region) or partially, in which > case a random 128 MB range is selected that also covers vmlinux's > .text segment, allowing jumps without veneers. However, since this > range is part of the ordinary vmalloc space, there is a >0 probability > that other allocations may exhaust it before you have loaded all your > modules, in which case the module loader will fall back to ordinary > vmalloc region allocations, which are most likely too far away to be > resolved without PLTs Looking at module_alloc, we only fall back when CONFIG_ARM64_MODULE_PLTS is selected, no? So the allocation would fail completely in the case of the range being exhausted. I agree that it's sensible to select CONFIG_ARM64_MODULE_PLTS so as to be able to load modules regardless of other vmalloc allocations exhausting a VA range. > > Could we do > > something like: > > > > select ARM64_MODULE_PLTS if MODULES > > > > Whichever way we fix this, we probably need: > > > > Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") > > Cc: <stable@vger.kernel.org> # 4.6+ > > > > With these changes > > Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> FWIW, likewise: Acked-by: Mark Rutland <mark.rutland@arm.com> Thanks, Mark. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE 2016-07-26 17:52 ` Ard Biesheuvel 2016-07-26 18:45 ` Mark Rutland @ 2016-07-27 6:55 ` Catalin Marinas 1 sibling, 0 replies; 6+ messages in thread From: Catalin Marinas @ 2016-07-27 6:55 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jul 26, 2016 at 07:52:33PM +0200, Ard Biesheuvel wrote: > On 26 July 2016 at 19:45, Catalin Marinas <catalin.marinas@arm.com> wrote: > > On Tue, Jul 26, 2016 at 10:16:55AM -0700, Jeff Vander Stoep wrote: > >> Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a > >> build error due to dependencies on modules. This patch makes KASLR > >> module config options dependent on CONFIG_MODULES=y. > >> > >> Signed-off-by: Jeff Vander Stoep <jeffv@google.com> > >> --- > >> arch/arm64/Kconfig | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > >> index 7e23f95..c9eff79 100644 > >> --- a/arch/arm64/Kconfig > >> +++ b/arch/arm64/Kconfig > >> @@ -891,7 +891,6 @@ config RELOCATABLE > >> > >> config RANDOMIZE_BASE > >> bool "Randomize the address of the kernel image" > >> - select ARM64_MODULE_PLTS > >> select RELOCATABLE > >> help > >> Randomizes the virtual address at which the kernel image is > > > > I thought we need the module PLTs once we randomize the kernel base, > > independent of whether we randomize the modules base or not. > > Indeed. The module region is always randomized with KASLR, but either > fully (i.e., anywhere in the vmalloc region) or partially, in which > case a random 128 MB range is selected that also covers vmlinux's > .text segment, allowing jumps without veneers. However, since this > range is part of the ordinary vmalloc space, there is a >0 probability > that other allocations may exhaust it before you have loaded all your > modules, in which case the module loader will fall back to ordinary > vmalloc region allocations, which are most likely too far away to be > resolved without PLTs > > > Could we do > > something like: > > > > select ARM64_MODULE_PLTS if MODULES > > > > Whichever way we fix this, we probably need: > > > > Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") > > Cc: <stable@vger.kernel.org> # 4.6+ > > > > With these changes > > Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Thanks. I pushed my variant above to arm64 for-next/core. -- Catalin ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE 2016-07-26 17:45 ` Catalin Marinas 2016-07-26 17:52 ` Ard Biesheuvel @ 2016-07-26 17:53 ` Catalin Marinas 1 sibling, 0 replies; 6+ messages in thread From: Catalin Marinas @ 2016-07-26 17:53 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jul 26, 2016 at 06:45:56PM +0100, Catalin Marinas wrote: > On Tue, Jul 26, 2016 at 10:16:55AM -0700, Jeff Vander Stoep wrote: > > Selecting CONFIG_RANDOMIZE_BASE=y and CONFIG_MODULES=n causes a > > build error due to dependencies on modules. This patch makes KASLR > > module config options dependent on CONFIG_MODULES=y. > > > > Signed-off-by: Jeff Vander Stoep <jeffv@google.com> > > --- > > arch/arm64/Kconfig | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 7e23f95..c9eff79 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -891,7 +891,6 @@ config RELOCATABLE > > > > config RANDOMIZE_BASE > > bool "Randomize the address of the kernel image" > > - select ARM64_MODULE_PLTS > > select RELOCATABLE > > help > > Randomizes the virtual address at which the kernel image is > > I thought we need the module PLTs once we randomize the kernel base, > independent of whether we randomize the modules base or not. Looking at the code, I think we don't really need the PLTs when the modules are randomised together with the kernel image. So I think your original patch is fine. > Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") > Cc: <stable@vger.kernel.org> # 4.6+ I'll add these myself. Unless Ard has any objections, I'll queue this for 4.8. Thanks. -- Catalin ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-27 6:55 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-07-26 17:16 [PATCH] arm64: Fix Kconfig dependencies for RANDOMIZE_BASE Jeff Vander Stoep 2016-07-26 17:45 ` Catalin Marinas 2016-07-26 17:52 ` Ard Biesheuvel 2016-07-26 18:45 ` Mark Rutland 2016-07-27 6:55 ` Catalin Marinas 2016-07-26 17:53 ` Catalin Marinas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox