linux-stable/drivers/counter
William Breathitt Gray 50531cd807 counter: 104-quad-8: Fix race getting function mode and direction
commit d501d37841 upstream.

The quad8_action_read() function checks the Count function mode and
Count direction without first acquiring a lock. This is a race condition
because the function mode could change by the time the direction is
checked.

Because the quad8_function_read() already acquires a lock internally,
the quad8_function_read() is refactored to spin out the no-lock code to
a new quad8_function_get() function.

To resolve the race condition in quad8_action_read(), a lock is acquired
before calling quad8_function_get() and quad8_direction_read() in order
to get both function mode and direction atomically.

Fixes: f1d8a071d4 ("counter: 104-quad-8: Add Generic Counter interface support")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221020141121.15434-1-william.gray@linaro.org/
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-04 00:00:23 +09:00
..
104-quad-8.c counter: 104-quad-8: Fix race getting function mode and direction 2022-11-04 00:00:23 +09:00
Kconfig counter: 104-quad-8: Add COMPILE_TEST depends 2022-03-18 14:04:30 +01:00
Makefile counter: Add character device interface 2021-10-17 10:53:52 +01:00
counter-chrdev.c counter: add defaults to switch-statements 2022-03-18 14:04:30 +01:00
counter-chrdev.h counter: Add character device interface 2021-10-17 10:53:52 +01:00
counter-core.c counter: Set counter device name 2022-03-18 14:04:30 +01:00
counter-sysfs.c counter: Stop using dev_get_drvdata() to get the counter device 2022-03-15 19:24:13 +01:00
counter-sysfs.h counter: Internalize sysfs interface code 2021-10-17 10:52:58 +01:00
ftm-quaddec.c counter: ftm-quaddec: Convert to new counter registration 2021-12-30 17:44:07 +01:00
intel-qep.c counter: intel-qep: Convert to new counter registration 2021-12-30 17:44:07 +01:00
interrupt-cnt.c counter: interrupt-cnt: add counter_push_event() 2022-03-18 14:04:30 +01:00
microchip-tcb-capture.c counter: microchip-tcb-capture: Handle Signal1 read and Synapse 2022-11-04 00:00:23 +09:00
stm32-lptimer-cnt.c counter: stm32-lptimer-cnt: Convert to new counter registration 2021-12-30 17:44:07 +01:00
stm32-timer-cnt.c counter: stm32-timer-cnt: Convert to new counter registration 2021-12-30 17:44:07 +01:00
ti-eqep.c counter: ti-eqep: Convert to new counter registration 2021-12-30 17:44:07 +01:00