opnsense-src/sys/compat/linuxkpi/common/src
Ryan Stone b58cf1cb35 Fix race condition in linuxkpi workqueue
Consider the following scenario:

1. A delayed_work struct in the WORK_ST_TIMER state.
2. Thread A calls mod_delayed_work()
3. Thread B (a callout thread) simultaneously calls
linux_delayed_work_timer_fn()

The following sequence of events is possible:

A: Call linux_cancel_delayed_work()
A: Change state from TIMER TO CANCEL
B: Change state from CANCEL to TASK
B: taskqueue_enqueue() the task
A: taskqueue_cancel() the task
A: Call linux_queue_delayed_work_on().  This is a no-op because the
state is WORK_ST_TASK.

As a result, the delayed_work struct will never be invoked.  This is
causing address resolution in ib_addr.c to stop permanently, as it
never tries to reschedule a task that it thinks is already scheduled.

Fix this by introducing locking into the cancel path (which
corresponds with the lock held while the callout runs).  This will
prevent the callout from changing the state of the task until the
cancel is complete, preventing the race.

Differential Revision:	https://reviews.freebsd.org/D28420
Reviewed by: hselasky
MFC after: 2 months
2021-02-04 13:54:53 -05:00
..
linux_acpi.c LinuxKPI: Implement ACPI bits required by drm-kmod in base system 2020-11-09 13:20:14 +00:00
linux_compat.c LinuxKPI: implement devres() framework parts and two examples 2021-01-28 16:32:43 +00:00
linux_current.c linuxkpi: improvements for linux_pid_task() and linux_get_pid_task(). 2020-07-02 10:42:58 +00:00
linux_devres.c LinuxKPI: implement devres() framework parts and two examples 2021-01-28 16:32:43 +00:00
linux_dmi.c linuxkpi: Add dmi_* function 2020-10-02 18:28:00 +00:00
linux_firmware.c LinuxKPI: add firmware loading support 2021-01-28 16:05:32 +00:00
linux_fpu.c linuxkpi: add kernel_fpu_begin/kernel_fpu_end 2021-01-12 12:31:00 +01:00
linux_hrtimer.c compat: clean up empty lines in .c and .h files 2020-09-01 21:24:33 +00:00
linux_idr.c compat: clean up empty lines in .c and .h files 2020-09-01 21:24:33 +00:00
linux_kmod.c LinuxKPI: add module dependency on firmware(9) 2021-01-30 17:50:26 +00:00
linux_kthread.c schedlock 1/4 2019-12-15 21:11:15 +00:00
linux_lock.c Populate the acquire context field of a ww_mutex in the LinuxKPI. 2020-10-04 17:23:39 +00:00
linux_page.c Remove some redundant assignments and computations. 2020-06-28 21:34:38 +00:00
linux_pci.c LinuxKPI: enhance PCI bits for DRM 2021-01-28 16:23:19 +00:00
linux_radix.c compat: clean up empty lines in .c and .h files 2020-09-01 21:24:33 +00:00
linux_rcu.c compat: clean up empty lines in .c and .h files 2020-09-01 21:24:33 +00:00
linux_schedule.c Implement the init_wait_entry() function macro in the LinuxKPI. 2018-06-06 14:59:23 +00:00
linux_seq_file.c compat: clean up empty lines in .c and .h files 2020-09-01 21:24:33 +00:00
linux_shmemfs.c linuxkpi: Move shmem related functions in it's own file 2020-02-21 09:28:45 +00:00
linux_shrinker.c linuxkpi: Fix the shrinker scan target 2021-01-18 17:07:55 -05:00
linux_slab.c LinuxKPI: Reimplement irq_work queue on top of fast taskqueue 2021-01-17 12:47:28 +01:00
linux_tasklet.c LinuxKPI: Fix build on powerpc/sparc. 2019-05-16 19:32:11 +00:00
linux_usb.c Improve handling of alternate settings in the USB stack. 2020-12-15 12:05:07 +00:00
linux_work.c Fix race condition in linuxkpi workqueue 2021-02-04 13:54:53 -05:00
linux_xarray.c Implement extensible arrays API using the existing radix tree implementation 2020-08-27 10:28:12 +00:00