Skip to content

Commit 1fa6daa

Browse files
committed
ipfilter: Avoid stopping with a lock held
Avoid calling _callout_stop_safe with a non-sleepable lock held when detaching by initializing callout_init_rw() with CALLOUT_SHAREDLOCK. It avoids the following WITNESS warning when stopping the service: # service ipfilter stop calling _callout_stop_safe with the following non-sleepable locks held: shared rw ipf filter load/unload mutex (ipf filter load/unload mutex) r = 0 (0xffff0000417c7530) locked @ /usr/src/sys/netpfil/ipfilter/netinet/fil.c:7926 stack backtrace: #0 0xffff00000052d394 at witness_debugger+0x60 pfsense#1 0xffff00000052e620 at witness_warn+0x404 pfsense#2 0xffff0000004d4ffc at _callout_stop_safe+0x8c pfsense#3 0xffff0000f7236674 at ipfdetach+0x3c pfsense#4 0xffff0000f723fa4c at ipf_ipf_ioctl+0x788 pfsense#5 0xffff0000f72367e0 at ipfioctl+0x144 pfsense#6 0xffff00000034abd8 at devfs_ioctl+0x100 pfsense#7 0xffff0000005c66a0 at vn_ioctl+0xbc pfsense#8 0xffff00000034b2cc at devfs_ioctl_f+0x24 pfsense#9 0xffff0000005331ec at kern_ioctl+0x2e0 pfsense#10 0xffff000000532eb4 at sys_ioctl+0x140 pfsense#11 0xffff000000880480 at do_el0_sync+0x604 pfsense#12 0xffff0000008579ac at handle_el0_sync+0x4c PR: 282478 Suggested by: markj Reviewed by: cy Approved by: emaste (mentor) MFC after: 1 week
1 parent 9da30a2 commit 1fa6daa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ipf_timer_func(void *arg)
181181
#if 0
182182
softc->ipf_slow_ch = timeout(ipf_timer_func, softc, hz/2);
183183
#endif
184-
callout_init(&softc->ipf_slow_ch, 1);
184+
callout_init_rw(&softc->ipf_slow_ch, &softc->ipf_global.ipf_lk, CALLOUT_SHAREDLOCK);
185185
callout_reset(&softc->ipf_slow_ch,
186186
(hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT,
187187
ipf_timer_func, softc);
@@ -221,7 +221,7 @@ ipfattach(ipf_main_softc_t *softc)
221221
softc->ipf_slow_ch = timeout(ipf_timer_func, softc,
222222
(hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT);
223223
#endif
224-
callout_init(&softc->ipf_slow_ch, 1);
224+
callout_init_rw(&softc->ipf_slow_ch, &softc->ipf_global.ipf_lk, CALLOUT_SHAREDLOCK);
225225
callout_reset(&softc->ipf_slow_ch, (hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT,
226226
ipf_timer_func, softc);
227227
return (0);

0 commit comments

Comments
 (0)