FAILED: patch "[PATCH] driver core: Fix locking bug in" failed to apply to 4.19-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From eed6e41813deb9ee622cd9242341f21430d7789f Mon Sep 17 00:00:00 2001
From: Saravana Kannan <[email protected]>
Date: Thu, 1 Apr 2021 21:03:40 -0700
Subject: [PATCH] driver core: Fix locking bug in
deferred_probe_timeout_work_func()
list_for_each_entry_safe() is only useful if we are deleting nodes in a linked list within the loop. It doesn't protect against other threads adding/deleting nodes to the list in parallel. We need to grab deferred_probe_mutex when traversing the deferred_probe_pending_list.
drivers/base/dd.c +5 -3
@@ -292,14 +292,16 @@ int driver_deferred_probe_check_state(struct device *dev)static void deferred_probe_timeout_work_func (struct work_struct *work) { -struct device_private *private, *p; +struct device_private *p; driver_deferred_probe_timeout =0 ;driver_deferred_probe_trigger ();flush_work (&deferred_probe_work); -list_for_each_entry_safe (private, p, &deferred_probe_pending_list, deferred_probe) -dev_info (private->device,"deferred probe pending\n" ); +mutex_lock (&deferred_probe_mutex); +list_for_each_entry (p, &deferred_probe_pending_list, deferred_probe) +dev_info (p->device,"deferred probe pending\n" ); +mutex_unlock (&deferred_probe_mutex);wake_up_all (&probe_timeout_waitqueue); } static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
Quoted 6 lines · On Sun, Apr 11, 2021 at 12:23 AM <[email protected]> wrote:
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
I sent a patch that should resolve the conflict for 4.19 and 5.4.
https://lore.kernel.org/lkml/[email protected]/T/#u
-Saravana
Quoted 49 lines
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
eed6e41813deb9ee622cd9242341f21430d7789fMon Sep 17 00:00:00 2001
From: Saravana Kannan <[email protected]>
Date: Thu, 1 Apr 2021 21:03:40 -0700
Subject: [PATCH] driver core: Fix locking bug in
deferred_probe_timeout_work_func()
list_for_each_entry_safe()is only useful if we are deleting nodes in a linked list within the loop. It doesn't protect against other threads adding/deleting nodes to the list in parallel. We need to grabdeferred_probe_mutexwhen traversing thedeferred_probe_pending_list.Fixes 25b4e70dcce9 ("driver core: allow stopping deferred probe after init")Signed-off-by Saravana Kannan <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>drivers/base/dd.c +5
-3@@ -292,14 +292,16 @@ int driver_deferred_probe_check_state(struct device *dev)static void deferred_probe_timeout_work_func (struct work_struct *work) { -struct device_private *private, *p; +struct device_private *p; driver_deferred_probe_timeout =0 ;driver_deferred_probe_trigger ();flush_work (&deferred_probe_work); -list_for_each_entry_safe (private, p, &deferred_probe_pending_list, deferred_probe) -dev_info (private->device,"deferred probe pending\n" ); +mutex_lock (&deferred_probe_mutex); +list_for_each_entry (p, &deferred_probe_pending_list, deferred_probe) +dev_info (p->device,"deferred probe pending\n" ); +mutex_unlock (&deferred_probe_mutex);wake_up_all (&probe_timeout_waitqueue); } static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);