WSL2-Linux-Kernel/drivers/base/firmware_loader
Thiébaud Weksteen 12ff111421 firmware_loader: use kernel credentials when reading firmware
commit 581dd69830 upstream.

Device drivers may decide to not load firmware when probed to avoid
slowing down the boot process should the firmware filesystem not be
available yet. In this case, the firmware loading request may be done
when a device file associated with the driver is first accessed. The
credentials of the userspace process accessing the device file may be
used to validate access to the firmware files requested by the driver.
Ensure that the kernel assumes the responsibility of reading the
firmware.

This was observed on Android for a graphic driver loading their firmware
when the device file (e.g. /dev/mali0) was first opened by userspace
(i.e. surfaceflinger). The security context of surfaceflinger was used
to validate the access to the firmware file (e.g.
/vendor/firmware/mali.bin).

Previously, Android configurations were not setting up the
firmware_class.path command line argument and were relying on the
userspace fallback mechanism. In this case, the security context of the
userspace daemon (i.e. ueventd) was consistently used to read firmware
files. More Android devices are now found to set firmware_class.path
which gives the kernel the opportunity to read the firmware directly
(via kernel_read_file_from_path_initns). In this scenario, the current
process credentials were used, even if unrelated to the loading of the
firmware file.

Signed-off-by: Thiébaud Weksteen <tweek@google.com>
Cc: <stable@vger.kernel.org> # 5.10
Reviewed-by: Paul Moore <paul@paul-moore.com>
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20220502004952.3970800-1-tweek@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-18 10:26:53 +02:00
..
builtin firmware_loader: remove unneeded 'comma' macro 2021-06-04 15:06:03 +02:00
Kconfig drivers: base: Fix Kconfig indentation 2019-11-20 15:10:25 +01:00
Makefile firmware: Add new platform fallback mechanism and firmware_request_platform() 2020-03-20 14:54:04 +01:00
fallback.c firmware_loader: fix use-after-free in firmware_fallback_sysfs 2021-07-29 17:22:15 +02:00
fallback.h firmware: Store opt_flags in fw_priv 2020-10-05 13:37:04 +02:00
fallback_platform.c firmware: Store opt_flags in fw_priv 2020-10-05 13:37:04 +02:00
fallback_table.c firmware_loader: move fw_fallback_config to a private kernel symbol namespace 2020-04-28 21:05:42 +02:00
firmware.h firmware_loader: fix use-after-free in firmware_fallback_sysfs 2021-07-29 17:22:15 +02:00
main.c firmware_loader: use kernel credentials when reading firmware 2022-05-18 10:26:53 +02:00