linux-uconsole/drivers
Yves-Alexis Perez 656c9abd57 firmware: fix usermode helper fallback loading
commit 2e700f8d85 upstream.

When you use the firmware usermode helper fallback with a timeout value set to a
value greater than INT_MAX (2147483647) a cast overflow issue causes the
timeout value to go negative and breaks all usermode helper loading. This
regression was introduced through commit 68ff2a00db ("firmware_loader:
handle timeout via wait_for_completion_interruptible_timeout()") on kernel
v4.0.

The firmware_class drivers relies on the firmware usermode helper
fallback as a mechanism to look for firmware if the direct filesystem
search failed only if:

  a) You've enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK (not many distros):

  Then all of these callers will rely on the fallback mechanism in case
  the firmware is not found through an initial direct filesystem lookup:

  o request_firmware()
  o request_firmware_into_buf()
  o request_firmware_nowait()

  b) If you've only enabled CONFIG_FW_LOADER_USER_HELPER (most distros):

  Then only callers using request_firmware_nowait() with the second
  argument set to false, this explicitly is requesting the UMH firmware
  fallback to be relied on in case the first filesystem lookup fails.

  Using Coccinelle SmPL grammar we have identified only two drivers
  explicitly requesting the UMH firmware fallback mechanism:

  - drivers/firmware/dell_rbu.c
  - drivers/leds/leds-lp55xx-common.c

Since most distributions only enable CONFIG_FW_LOADER_USER_HELPER the
biggest impact of this regression are users of the dell_rbu and
leds-lp55xx-common device driver which required the UMH to find their
respective needed firmwares.

The default timeout for the UMH is set to 60 seconds always, as of
commit 68ff2a00db ("firmware_loader: handle timeout via
wait_for_completion_interruptible_timeout()") the timeout was bumped
to MAX_JIFFY_OFFSET ((LONG_MAX >> 1)-1). Additionally the MAX_JIFFY_OFFSET
value was also used if the timeout was configured by a user to 0.

The following works:

echo 2147483647 > /sys/class/firmware/timeout

But both of the following set the timeout to MAX_JIFFY_OFFSET even if
we display 0 back to userspace:

echo 2147483648 > /sys/class/firmware/timeout
cat /sys/class/firmware/timeout
0

echo 0> /sys/class/firmware/timeout
cat /sys/class/firmware/timeout
0

A max value of INT_MAX (2147483647) seconds is therefore implicit due to the
another cast with simple_strtol().

This fixes the secondary cast (the first one is simple_strtol() but its an
issue only by forcing an implicit limit) by re-using the timeout variable and
only setting retval in appropriate cases.

Lastly worth noting systemd had ripped out the UMH firmware fallback
mechanism from udev since udev 2014 via commit be2ea723b1d023b3d
("udev: remove userspace firmware loading support"), so as of systemd v217.

Signed-off-by: Yves-Alexis Perez <corsac@corsac.net>
Fixes: 68ff2a00db "firmware_loader: handle timeout via wait_for_completion_interruptible_timeout()"
Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
[mcgrof@kernel.org: gave commit log a whole lot of love]
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-09 08:07:49 +01:00
..
accessibility
acpi ACPI / video: Add force_native quirk for HP Pavilion dv6 2017-01-09 08:07:44 +01:00
amba
android ANDROID: binder: Clear binder and cookie when setting handle in flat binder struct 2016-11-10 16:36:33 +01:00
ata libata: LITE-ON CX1-JB256-HP needs lower max_sectors 2016-08-10 11:49:29 +02:00
atm
auxdisplay
base firmware: fix usermode helper fallback loading 2017-01-09 08:07:49 +01:00
bcma x86/quirks: Add early quirk to reset Apple AirPort card 2016-08-10 11:49:24 +02:00
block loop: return proper error from loop_queue_rq() 2017-01-06 11:16:14 +01:00
bluetooth Bluetooth: Add support for Intel Bluetooth device 8265 [8087:0a2b] 2016-09-15 08:27:49 +02:00
bus bus: arm-ccn: Fix XP watchpoint settings bitmask 2016-09-24 10:07:40 +02:00
cdrom
char tpm xen: Remove bogus tpm_chip_unregister 2017-01-06 11:16:16 +01:00
clk clk: bcm2835: Avoid overwriting the div info when disabling a pll_div clk 2017-01-09 08:07:43 +01:00
clocksource clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function 2016-09-24 10:07:35 +02:00
connector connector: bump skb->users before callback invocation 2016-01-04 21:46:45 -05:00
cpufreq cpufreq: intel_pstate: Fix unsafe HWP MSR access 2016-10-28 03:01:26 -04:00
cpuidle ARM: cpuidle: Fix error return code 2016-10-16 17:36:15 +02:00
crypto crypto: caam - fix AEAD givenc descriptors 2017-01-06 11:16:12 +01:00
dca
devfreq
dio
dma dmaengine: at_xdmac: fix spurious flag status for mem2mem transfers 2016-11-18 10:48:36 +01:00
dma-buf
edac EDAC: Increment correct counter in edac_inc_ue_error() 2016-09-07 08:32:41 +02:00
eisa
extcon extcon: max77843: Use correct size for reading the interrupt register 2016-05-04 14:48:54 -07:00
firewire firewire: net: fix fragmented datagram_size off-by-one 2016-11-10 16:36:35 +01:00
firmware efi: Expose non-blocking set_variable() wrapper to efivars 2016-05-04 14:48:49 -07:00
fmc
fpga
gpio gpio: mpc8xxx: Correct irq handler function 2016-10-28 03:01:25 -04:00
gpu drivers/gpu/drm/ast: Fix infinite loop if read fails 2017-01-09 08:07:46 +01:00
hid HID: usbhid: add ATEN CS962 to list of quirky devices 2016-11-10 16:36:37 +01:00
hsi
hv hv: do not lose pending heartbeat vmbus packets 2016-11-10 16:36:34 +01:00
hwmon hwmon: (adt7411) set bit 3 in CFG1 register 2016-10-07 15:23:42 +02:00
hwspinlock drivers/hwspinlock: fix race between radix tree insertion and lookup 2016-02-25 12:01:23 -08:00
hwtracing intel_th: Fix a deadlock in modprobing 2016-08-10 11:49:30 +02:00
i2c i2c: mux: fix up dependencies 2016-11-26 09:54:52 +01:00
ide
idle intel_idle: Support for Intel Xeon Phi Processor x200 Product Family 2016-09-15 08:27:46 +02:00
iio iio: orientation: hid-sensor-rotation: Add PM function (fix non working driver) 2016-11-18 10:48:35 +01:00
infiniband IB/cm: Mark stale CM id's whenever the mad agent was unregistered 2016-11-26 09:54:54 +01:00
input Input: i8042 - add XMG C504 to keyboard reset table 2016-11-10 16:36:35 +01:00
iommu iommu/vt-d: Fix IOMMU lookup for SR-IOV Virtual Functions 2016-12-02 09:09:00 +01:00
ipack
irqchip irqchip/gicv3: Handle loop timeout proper 2016-10-28 03:01:33 -04:00
isdn ser_gigaset: remove unnecessary kfree() calls from release method 2015-12-15 13:24:21 -05:00
leds
lguest
lightnvm lightnvm: put bio before return 2016-09-24 10:07:35 +02:00
macintosh
mailbox
mcb mcb: Fixed bar number assignment for the gdd 2016-06-01 12:15:53 -07:00
md dm space map metadata: fix 'struct sm_metadata' leak on failed create 2017-01-06 11:16:15 +01:00
media dib0700: fix nec repeat handling 2016-11-18 10:48:34 +01:00
memory memory: omap-gpmc: Fix omap gpmc EXTRADELAY timing 2016-07-27 09:47:35 -07:00
memstick memstick: rtsx_usb_ms: Manage runtime PM when accessing the device 2016-10-28 03:01:35 -04:00
message
mfd mfd: core: Fix device reference leak in mfd_clone_cell 2016-11-26 09:54:53 +01:00
misc mei: request async autosuspend at the end of enumeration 2017-01-09 08:07:47 +01:00
mmc mmc: sdhci: Fix recovery from tuning timeout 2017-01-09 08:07:43 +01:00
mtd ubi: fastmap: Fix add_vol() return value test in ubi_attach_fastmap() 2016-11-10 16:36:37 +01:00
net ath9k: Really fix LED polarity for some Mini PCI AR9220 MB92 cards. 2017-01-09 08:07:42 +01:00
nfc mei: bus: fix received data size check in NFC fixup 2016-11-18 10:48:36 +01:00
ntb
nubus
nvdimm libnvdimm, pfn: fix uuid validation 2016-04-20 15:41:54 +09:00
nvme nvme: Call pci_disable_device on the error path. 2016-09-15 08:27:51 +02:00
nvmem nvmem: mxs-ocotp: fix buffer overflow in read 2016-05-11 11:21:21 +02:00
of of: silence warnings due to max() usage 2016-11-15 07:46:39 +01:00
oprofile
parisc parisc iommu: fix panic due to trying to allocate too large region 2015-12-12 16:07:25 +01:00
parport
pci PCI: Set Read Completion Boundary to 128 iff Root Port supports it (_HPX) 2016-12-08 07:15:24 +01:00
pcmcia pcmcia: db1xxx_ss: fix last irq_to_gpio user 2016-04-20 15:42:09 +09:00
perf drivers/perf: arm_pmu: Fix leak in error path 2016-10-07 15:23:41 +02:00
phy phy: core: fix wrong err handle for phy_power_on 2016-03-03 15:07:28 -08:00
pinctrl pinctrl: cherryview: Prevent possible interrupt storm on resume 2016-11-18 10:48:34 +01:00
platform toshiba-wmi: Fix loading the driver on non Toshiba laptops 2016-11-18 10:48:35 +01:00
pnp PNP: Add Broadwell to Intel MCH size workaround 2016-08-16 09:30:48 +02:00
power power: bq24257: Fix use of uninitialized pointer bq->charger 2016-10-31 04:14:00 -06:00
powercap powercap / RAPL: fix BIOS lock check 2015-12-12 02:31:11 +01:00
pps pps: do not crash when failed to register 2016-08-10 11:49:25 +02:00
ps3
ptp
pwm pwm: Fix device reference leak 2016-12-08 07:15:24 +01:00
rapidio
ras
regulator regulator: stw481x-vmmc: fix ages old enable error 2017-01-09 08:07:43 +01:00
remoteproc remoteproc: Fix potential race condition in rproc_add 2016-08-20 18:09:20 +02:00
reset
rpmsg
rtc rtc: omap: Fix selecting external osc 2016-11-26 09:54:53 +01:00
s390 scsi: zfcp: fix rport unblock race with LUN recovery 2017-01-09 08:07:48 +01:00
sbus
scsi scsi: avoid a permanent stop of the scsi device's request queue 2017-01-09 08:07:48 +01:00
sfi
sh drivers: sh: Restore legacy clock domain on SuperH platforms 2016-03-09 15:34:49 -08:00
sn
soc soc: qcom/spm: shut up uninitialized variable warning 2016-09-24 10:07:42 +02:00
spi spi: spi-fsl-dspi: Drop extra spi_master_put in device remove function 2016-10-31 04:13:59 -06:00
spmi
ssb ssb: Fix error routine when fallback SPROM fails 2017-01-09 08:07:42 +01:00
staging staging: comedi: ni_mio_common: fix E series ni_ai_insn_read() data 2017-01-09 08:07:44 +01:00
target target: Don't override EXTENDED_COPY xcopy_pt_cmd SCSI status code 2016-10-28 03:01:36 -04:00
tc
thermal thermal: hwmon: Properly report critical temperature in sysfs 2017-01-09 08:07:44 +01:00
thunderbolt thunderbolt: Fix double free of drom buffer 2016-06-01 12:15:53 -07:00
tty vt: fix Scroll Lock LED trigger name 2017-01-09 08:07:47 +01:00
uio uio: fix dmem_region_start computation 2016-10-31 04:13:59 -06:00
usb usb: gadget: composite: always set ep->mult to a sensible value 2017-01-06 11:16:14 +01:00
uwb uwb: fix device reference leaks 2016-11-26 09:54:53 +01:00
vfio vfio/pci: Fix NULL pointer oops in error interrupt setup handling 2016-09-07 08:32:37 +02:00
vhost vhost/scsi: fix reuse of &vq->iov[out] in response 2016-09-15 08:27:53 +02:00
video fbdev/efifb: Fix 16 color palette entry calculation 2016-10-28 03:01:29 -04:00
virt
virtio virtio_ring: Make interrupt suppression spec compliant 2016-11-10 16:36:34 +01:00
vlynq
vme
w1 w1:omap_hdq: fix regression 2016-08-20 18:09:22 +02:00
watchdog watchdog: rc32434_wdt: fix ioctl error handling 2016-04-12 09:08:54 -07:00
xen xen/gntdev: Use VM_MIXEDMAP instead of VM_IO to avoid NUMA balancing 2017-01-06 11:16:17 +01:00
zorro
Kconfig
Makefile