diff options
author | William Breathitt Gray <vilhelm.gray@gmail.com> | 2021-10-21 13:35:40 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-21 14:02:47 +0300 |
commit | 8ac33b8b6841e99a624ace543d92cbf598a91381 (patch) | |
tree | bfbb42f1f6f41bc9fb8cae0098746d382196ad67 /drivers/hwmon/occ/common.c | |
parent | 310e75c72fefa3b0b4535f669c8b37c963a2dba5 (diff) | |
download | linux-8ac33b8b6841e99a624ace543d92cbf598a91381.tar.xz |
counter: Fix use-after-free race condition for events_queue_size write
A race condition is possible when writing to events_queue_size where the
events kfifo is freed during the execution of a kfifo_in(), resulting in
a use-after-free. This patch prevents such a scenario by protecting the
events queue in operation with a spinlock and locking before performing
the events queue size adjustment.
The existing events_lock mutex is renamed to events_out_lock to reflect
that it only protects events queue out operations. Because the events
queue in operations can occur in an interrupt context, a new
events_in_lock spinlock is introduced and utilized.
Fixes: feff17a550c7 ("counter: Implement events_queue_size sysfs attribute")
Cc: David Lechner <david@lechnology.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/20211021103540.955639-1-vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwmon/occ/common.c')
0 files changed, 0 insertions, 0 deletions