Skip to content

Commit abac3ac

Browse files
Vlad4896simonwunderlich
authored andcommitted
batman-adv: Broken sync while rescheduling delayed work
Syzkaller got a lot of crashes like: KASAN: use-after-free Write in *_timers* All of these crashes point to the same memory area: The buggy address belongs to the object at ffff88801f870000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 5320 bytes inside of 8192-byte region [ffff88801f870000, ffff88801f872000) This area belongs to : batadv_priv->batadv_priv_dat->delayed_work->timer_list The reason for these issues is the lack of synchronization. Delayed work (batadv_dat_purge) schedules new timer/work while the device is being deleted. As the result new timer/delayed work is set after cancel_delayed_work_sync() was called. So after the device is freed the timer list contains pointer to already freed memory. Found by Linux Verification Center (linuxtesting.org) with syzkaller. Cc: [email protected] Fixes: 2f1dfbe ("batman-adv: Distributed ARP Table - implement local storage") Signed-off-by: Vladislav Efanov <[email protected]> Acked-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 44c026a commit abac3ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/batman-adv/distributed-arp-table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static void batadv_dat_purge(struct work_struct *work);
101101
*/
102102
static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
103103
{
104-
INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
105104
queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
106105
msecs_to_jiffies(10000));
107106
}
@@ -819,6 +818,7 @@ int batadv_dat_init(struct batadv_priv *bat_priv)
819818
if (!bat_priv->dat.hash)
820819
return -ENOMEM;
821820

821+
INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
822822
batadv_dat_start_timer(bat_priv);
823823

824824
batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,

0 commit comments

Comments
 (0)