public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: fw: Gracefully handle unknown firmware protocols
@ 2024-08-24 14:41 Bjørn Mork
  2024-08-25 12:50 ` Jiaxun Yang
  2024-08-28 22:15 ` kernel test robot
  0 siblings, 2 replies; 10+ messages in thread
From: Bjørn Mork @ 2024-08-24 14:41 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Steven J . Hill, linux-mips, linux-kernel, Bjørn Mork,
	stable

Boards based on the same SoC family can use different boot loaders.
These may pass numeric arguments which we erroneously interpret as
command line or environment pointers. Such errors will cause boot
to halt at an early stage since commit 056a68cea01e ("mips: allow
firmware to pass RNG seed to kernel").

One known example of this issue is a HPE switch using a BootWare
boot loader.  It was found to pass these arguments to the kernel:

  0x00020000 0x00060000 0xfffdffff 0x0000416c

We can avoid hanging by validating that both passed pointers are in
KSEG1 as expected.

Cc: stable@vger.kernel.org
Fixes: 14aecdd41921 ("MIPS: FW: Add environment variable processing.")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 arch/mips/fw/lib/cmdline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/fw/lib/cmdline.c b/arch/mips/fw/lib/cmdline.c
index 892765b742bb..51238c4f9455 100644
--- a/arch/mips/fw/lib/cmdline.c
+++ b/arch/mips/fw/lib/cmdline.c
@@ -22,7 +22,7 @@ void __init fw_init_cmdline(void)
 	int i;
 
 	/* Validate command line parameters. */
-	if ((fw_arg0 >= CKSEG0) || (fw_arg1 < CKSEG0)) {
+	if (fw_arg0 >= CKSEG0 || fw_arg1 < CKSEG0 || fw_arg1 >= CKSEG2) {
 		fw_argc = 0;
 		_fw_argv = NULL;
 	} else {
@@ -31,7 +31,7 @@ void __init fw_init_cmdline(void)
 	}
 
 	/* Validate environment pointer. */
-	if (fw_arg2 < CKSEG0)
+	if (fw_arg2 < CKSEG0 || fw_arg2 >= CKSEG2)
 		_fw_envp = NULL;
 	else
 		_fw_envp = (int *)fw_arg2;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-08-28 22:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-24 14:41 [PATCH] MIPS: fw: Gracefully handle unknown firmware protocols Bjørn Mork
2024-08-25 12:50 ` Jiaxun Yang
2024-08-25 13:56   ` Maciej W. Rozycki
2024-08-25 14:44   ` Bjørn Mork
2024-08-25 15:18     ` Maciej W. Rozycki
2024-08-25 15:47       ` Bjørn Mork
2024-08-25 19:59         ` Maciej W. Rozycki
2024-08-26  8:52           ` Bjørn Mork
2024-08-26 13:17     ` Jiaxun Yang
2024-08-28 22:15 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox