reset_work is a file-scope delayed work shared by all SVC watchdogs, but do_work() calls INIT_DELAYED_WORK() on it every time a ping fails, right before scheduling it to run half a second later. With two host devices, the watchdog of the second SVC can see its ping fail while the work scheduled by the first one is still pending. INIT_DELAYED_WORK() then reinitializes a timer that is still enqueued, and debugobjects reports:
greybus 1-svc: Resetting the greybus network, watch out!!! greybus 2-svc: Resetting the greybus network, watch out!!! ODEBUG: init active (active state 0) object: ffffffff9bda1f68 object type: timer_list hint: greybus_reset+0x0/0x50 WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0 Workqueue: events do_work Call Trace: __debug_object_init timer_init_key do_work drivers/greybus/svc_watchdog.c:92 process_one_work
Without CONFIG_DEBUG_OBJECTS_TIMERS nothing catches this and the timer is added to the timer wheel a second time while it is still linked there.
Initialize reset_work once with DECLARE_DELAYED_WORK() and only schedule it from do_work(). schedule_delayed_work() does nothing when the work is already pending, which is what is wanted here: greybus_reset() resets the whole greybus network, so one run serves both watchdogs.
Fixes: ed7279ae31b0 ("greybus: svc: add a "watchdog" to check the network health") Reported-by: syzbot+e6bea924b5ee24f7cb98@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=e6bea924b5ee24f7cb98 Link: https://lore.kernel.org/r/CA+0ovCiyBFo_gx4UaRN095=MdWaBgKm=TqA1uYdOu-hb_BPt6... Signed-off-by: Jiayi Zhang zhangjiayi1014@gmail.com --- Compile tested only (allmodconfig, W=1); syzbot has no reproducer for this report.
AI tools assisted with the analysis, the code and the changelog.
drivers/greybus/svc_watchdog.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/greybus/svc_watchdog.c b/drivers/greybus/svc_watchdog.c index b318eb34bcca..11eb7c961b06 100644 --- a/drivers/greybus/svc_watchdog.c +++ b/drivers/greybus/svc_watchdog.c @@ -20,8 +20,6 @@ struct gb_svc_watchdog { struct notifier_block pm_notifier; };
-static struct delayed_work reset_work; - static int svc_watchdog_pm_notifier(struct notifier_block *notifier, unsigned long pm_event, void *unused) { @@ -61,6 +59,8 @@ static void greybus_reset(struct work_struct *work) call_usermodehelper(start_path, argv, envp, UMH_WAIT_EXEC); }
+static DECLARE_DELAYED_WORK(reset_work, greybus_reset); + static void do_work(struct work_struct *work) { struct gb_svc_watchdog *watchdog; @@ -89,7 +89,6 @@ static void do_work(struct work_struct *work) } else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO) { dev_err(&svc->dev, "Resetting the greybus network, watch out!!!\n");
- INIT_DELAYED_WORK(&reset_work, greybus_reset); schedule_delayed_work(&reset_work, HZ / 2);
/*
base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48