* [PATCH] MIPS: KASLR: Fix handling of NULL FDT
@ 2016-10-17 10:04 Matt Redfearn
2016-10-17 10:08 ` James Hogan
2016-10-17 13:47 ` Sergei Shtylyov
0 siblings, 2 replies; 3+ messages in thread
From: Matt Redfearn @ 2016-10-17 10:04 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Matt Redfearn, # 4 . 7+, linux-kernel
If platform code returns a NULL pointer to the FDT, initial_boot_params
will not get set to a valid pointer and attempting to find the /chosen
node in it will cause a NULL pointer dereference and the kernel to crash
immediately on startup - with no output to the console.
Fix this by checking that initial_boot_params is valid before using it.
Fixes: 405bc8fd12f5 ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE")
Cc: <stable@vger.kernel.org> # 4.7+
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---
arch/mips/kernel/relocate.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index ca1cc30c0891..8810183840ca 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -200,6 +200,7 @@ static inline __init unsigned long get_random_boot(void)
#if defined(CONFIG_USE_OF)
/* Get any additional entropy passed in device tree */
+ if (initial_boot_params)
{
int node, len;
u64 *prop;
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: KASLR: Fix handling of NULL FDT
2016-10-17 10:04 [PATCH] MIPS: KASLR: Fix handling of NULL FDT Matt Redfearn
@ 2016-10-17 10:08 ` James Hogan
2016-10-17 13:47 ` Sergei Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: James Hogan @ 2016-10-17 10:08 UTC (permalink / raw)
To: Matt Redfearn; +Cc: Ralf Baechle, linux-mips, # 4 . 7+, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
Hi Matt,
On Mon, Oct 17, 2016 at 11:04:54AM +0100, Matt Redfearn wrote:
> If platform code returns a NULL pointer to the FDT, initial_boot_params
> will not get set to a valid pointer and attempting to find the /chosen
> node in it will cause a NULL pointer dereference and the kernel to crash
> immediately on startup - with no output to the console.
>
> Fix this by checking that initial_boot_params is valid before using it.
>
> Fixes: 405bc8fd12f5 ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE")
> Cc: <stable@vger.kernel.org> # 4.7+
> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
> ---
>
> arch/mips/kernel/relocate.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
> index ca1cc30c0891..8810183840ca 100644
> --- a/arch/mips/kernel/relocate.c
> +++ b/arch/mips/kernel/relocate.c
> @@ -200,6 +200,7 @@ static inline __init unsigned long get_random_boot(void)
>
> #if defined(CONFIG_USE_OF)
> /* Get any additional entropy passed in device tree */
> + if (initial_boot_params)
> {
The open brace should be on the same line as the if really.
Cheers
James
> int node, len;
> u64 *prop;
> --
> 2.7.4
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: KASLR: Fix handling of NULL FDT
2016-10-17 10:04 [PATCH] MIPS: KASLR: Fix handling of NULL FDT Matt Redfearn
2016-10-17 10:08 ` James Hogan
@ 2016-10-17 13:47 ` Sergei Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2016-10-17 13:47 UTC (permalink / raw)
To: Matt Redfearn, Ralf Baechle; +Cc: linux-mips, # 4 . 7+, linux-kernel
Hello.
On 10/17/2016 01:04 PM, Matt Redfearn wrote:
> If platform code returns a NULL pointer to the FDT, initial_boot_params
> will not get set to a valid pointer and attempting to find the /chosen
> node in it will cause a NULL pointer dereference and the kernel to crash
> immediately on startup - with no output to the console.
>
> Fix this by checking that initial_boot_params is valid before using it.
>
> Fixes: 405bc8fd12f5 ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE")
> Cc: <stable@vger.kernel.org> # 4.7+
> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
> ---
>
> arch/mips/kernel/relocate.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
> index ca1cc30c0891..8810183840ca 100644
> --- a/arch/mips/kernel/relocate.c
> +++ b/arch/mips/kernel/relocate.c
> @@ -200,6 +200,7 @@ static inline __init unsigned long get_random_boot(void)
>
> #if defined(CONFIG_USE_OF)
> /* Get any additional entropy passed in device tree */
> + if (initial_boot_params)
> {
CodingStyle: *if* and { should be on the same line.
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-17 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 10:04 [PATCH] MIPS: KASLR: Fix handling of NULL FDT Matt Redfearn
2016-10-17 10:08 ` James Hogan
2016-10-17 13:47 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®