From: "Bjørn Mork" <bjorn@mork.no>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
linux-kernel@vger.kernel.org,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] MIPS: fw: Gracefully handle unknown firmware protocols
Date: Mon, 26 Aug 2024 10:52:36 +0200 [thread overview]
Message-ID: <87cylvy8bv.fsf@miraculix.mork.no> (raw)
In-Reply-To: <alpine.DEB.2.21.2408252029130.30766@angie.orcam.me.uk> (Maciej W. Rozycki's message of "Sun, 25 Aug 2024 20:59:26 +0100 (BST)")
"Maciej W. Rozycki" <macro@orcam.me.uk> writes:
> Even those that do use the function have a choice to override the default
> handler by setting CONFIG_HAVE_PLAT_FW_INIT_CMDLINE. Perhaps it's what
> you need to do for your platform too.
Considered that, but this problem isn't directly platform-related, is
it? Many of the firmware implementations are multi-platform. And they
support many of the same platforms.
My concrete eample showed up on the "realtek" (rtl838x and rtl93xx SoCs)
platform in OpenWrt, where a large number of boards from assorted
vendors are currently supported. The current implementation works fine
for most of them because they using U-Boot. But it failed in what I
consider the ugliest way possible (no ooops, no error message, just
hanging) on the boards from HPE because they use Bootware.
FWIW, there is also a vendor using BootBase for pretty much the same
hardware. But that's still unsupported in OpenWrt for various reasons.
So yes, this could be worked around by having a platform specific
fw_init_cmdline(). Or even another out-of-tree OpenWrt specific patch.
But whatever the solution is, it can't drop the U-Boot support since
most of the boards actually use U-Boot. Which is why I believe it's
much better to solve this problem at the root, for the benefit of
everyone else.
But of course, if necessary it would be possible to build X kernels with
dfferent fw_init_cmdline() implementations to support the same hardware
booted from X different boot firmwares.
> It's clear to me that this mess has to be cleaned up. Not all kinds of
> firmware permit the setting of arbitrary environment variables (or ones
> that survive a reboot) though.
Yes. And I believe it can be solved by improving the pointer validation
that's already there. All we need is to reject argument values passed
by other firmwares.
But it's probably better to create an inline valid_fw_arg(() or similar
function as proposed by Jiaxun, allowing the XKPHYS range too on 64 bit
systems.
If necessary we can improve further by adding an alignment requirement,
which was a proposal that came up in the OpenWrt discussions.
Another option is to connect the validation of all 4 arguments. There
is for example no reason to interpret the Bootware fw_arg2 value as an
enviroment pointer after we've already rejected fw_arg1 as cmdline.
It's also possible to validate command line argument pointers and
environment variable pointers (except for alignment, I guess?), refusing
anything which ends ut pointing outsde KSEG1 or XKPHYS.
How complicated you want this is all a matter of taste IMHO. I tried to
make this a simple solution matching the current "forgiving"
implementation.
Another improvement would be a pr_info() dumping the fw_argX values. It
would make it possible to understand why the code is hanging when the
firmware does something unexpected. I don't think pr_debug() helps much
in this particular case.
Bjørn
next prev parent reply other threads:[~2024-08-26 8:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-08-26 13:17 ` Jiaxun Yang
2024-08-28 22:15 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cylvy8bv.fsf@miraculix.mork.no \
--to=bjorn@mork.no \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=stable@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox