android_kernel_motorola_sm6375/drivers/base
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jann Horn 9b1ca33ebd firmware_loader: Block path traversal
commit f0e5311aa8022107d63c54e2f03684ec097d1394 upstream.

Most firmware names are hardcoded strings, or are constructed from fairly
constrained format strings where the dynamic parts are just some hex
numbers or such.

However, there are a couple codepaths in the kernel where firmware file
names contain string components that are passed through from a device or
semi-privileged userspace; the ones I could find (not counting interfaces
that require root privileges) are:

 - lpfc_sli4_request_firmware_update() seems to construct the firmware
   filename from "ModelName", a string that was previously parsed out of
   some descriptor ("Vital Product Data") in lpfc_fill_vpd()
 - nfp_net_fw_find() seems to construct a firmware filename from a model
   name coming from nfp_hwinfo_lookup(pf->hwinfo, "nffw.partno"), which I
   think parses some descriptor that was read from the device.
   (But this case likely isn't exploitable because the format string looks
   like "netronome/nic_%s", and there shouldn't be any *folders* starting
   with "netronome/nic_". The previous case was different because there,
   the "%s" is *at the start* of the format string.)
 - module_flash_fw_schedule() is reachable from the
   ETHTOOL_MSG_MODULE_FW_FLASH_ACT netlink command, which is marked as
   GENL_UNS_ADMIN_PERM (meaning CAP_NET_ADMIN inside a user namespace is
   enough to pass the privilege check), and takes a userspace-provided
   firmware name.
   (But I think to reach this case, you need to have CAP_NET_ADMIN over a
   network namespace that a special kind of ethernet device is mapped into,
   so I think this is not a viable attack path in practice.)

Fix it by rejecting any firmware names containing ".." path components.

For what it's worth, I went looking and haven't found any USB device
drivers that use the firmware loader dangerously.

Cc: [email protected]
Reviewed-by: Danilo Krummrich <[email protected]>
Fixes: abb139e75c ("firmware: teach the kernel to load firmware files directly from the filesystem")
Signed-off-by: Jann Horn <[email protected]>
Acked-by: Luis Chamberlain <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
2024-11-08 16:20:33 +01:00
..
firmware_loader firmware_loader: Block path traversal 2024-11-08 16:20:33 +01:00
power PM: sleep: wakeirq: fix wake irq warning in system suspend 2024-04-13 12:51:25 +02:00
regmap regmap: Add missing map->bus check 2024-03-26 18:22:25 -04:00
test driver core: test_async: fix an error code 2023-09-23 10:59:50 +02:00
arch_topology.c arm64: topology: move store_cpu_topology() to shared code 2022-10-29 10:20:36 +02:00
attribute_container.c
base.h
bus.c driver: base: fix UAF when driver_attach failed 2022-06-14 18:11:54 +02:00
cacheinfo.c
class.c class: fix possible memory leak in __class_register() 2023-01-18 11:41:21 +01:00
component.c
container.c
core.c driver core: Fix uevent_show() vs driver detach race 2024-08-19 05:33:52 +02:00
cpu.c x86/speculation: Add Gather Data Sampling mitigation 2023-08-08 19:56:35 +02:00
dd.c driver core: Release all resources during unbind before updating device links 2023-12-08 08:44:22 +01:00
devcon.c
devcoredump.c devcoredump: Send uevent once devcd is ready 2023-12-13 18:18:18 +01:00
devres.c devres: Initialize an uninitialized struct member 2024-09-12 11:03:54 +02:00
devtmpfs.c
driver.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 11:23:39 +01:00
firmware.c
hypervisor.c
init.c
isa.c
Kconfig
Makefile
map.c
memory.c
module.c driver core: Fix uevent_show() vs driver detach race 2024-08-19 05:33:52 +02:00
node.c drivers/base/node.c: fix compaction sysfs file leak 2022-06-14 18:11:41 +02:00
pinctrl.c
platform-msi.c
platform.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 11:23:39 +01:00
property.c
soc.c
swnode.c software node: Let args be NULL in software_node_get_reference_args 2024-01-25 14:34:31 -08:00
syscore.c
topology.c
transport_class.c