clockintr_dispatch: copy cl_func to cq_shadow.cl_func before calling it
authorcheloha <cheloha@openbsd.org>
Sat, 9 Sep 2023 03:03:45 +0000 (03:03 +0000)
committercheloha <cheloha@openbsd.org>
Sat, 9 Sep 2023 03:03:45 +0000 (03:03 +0000)
commite1d9391c7276abe132b77530f6d0b3199517ca9a
tree8fe7e6bb21c3d7bf8762c25d7d2a623010ab6d23
parentd72af28441d7b9f1932de72e0a3e91af6470af69
clockintr_dispatch: copy cl_func to cq_shadow.cl_func before calling it

When we add support for disestablishing clockintrs in the near future,
the current call to cl->cl_func will be in a race with free(9) on
another CPU.  Copying cl_func to cq_shadow.cl_func before leaving the
mutex and then calling the copy eliminates the race.

Correcting the race has a negligible performance impact and simplifies
the forthcoming clockintr_disestablish() patch.

Requested by dlg@ back in March.
sys/kern/kern_clockintr.c