Re: [PATCH v2 2/2] firmware_loader: fix soundness issue in `request_internal`
From: Danilo Krummrich
Date: Mon Jul 08 2024 - 17:07:26 EST
On Mon, Jul 08, 2024 at 01:37:51PM -0700, Luis Chamberlain wrote:
> On Mon, Jul 08, 2024 at 10:07:21PM +0200, Danilo Krummrich wrote:
> > `request_internal` must be called with one of the following function
> > pointers: request_firmware(), firmware_request_nowarn(),
> > firmware_request_platform() or request_firmware_direct().
> >
> > The previous `FwFunc` alias did not guarantee this, which is unsound.
> >
> > In order to fix this up, implement `FwFunc` as new type with a
> > corresponding type invariant.
> >
> > Reported-by: Gary Guo <gary@xxxxxxxxxxx>
> > Closes: https://lore.kernel.org/lkml/20240620143611.7995e0bb@eugeo/
> > Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
>
> While you're at it, can you go ahead and extend out selftest coverage
I think that'd be good and I thought about it. However, I think it makes more
sense once we got a few more abstractions in place, such that we can come up
with a Rust test module analogue to lib/test_firmware.c. What do you think?
> for the firmware_loader so we can test Rust too? Could these issues
> have been caught with a selftest? If not why not?
This patch isn't actually fixing a real bug. Which is also why I didn't put a
"Fixes" tag.
It's more that without the `FwFunc` type indirection and the corresponding
invariant the safety of `request_internal` isn't guranteed formally.
- Danilo
>
> Luis
>