Page MenuHomeFreeBSD

mroute: avoid calling if_allmulti with the lock held
ClosedPublic

Authored by kp on Jul 27 2023, 12:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 8:59 PM
Unknown Object (File)
Tue, Apr 30, 12:50 AM
Unknown Object (File)
Sun, Apr 28, 8:04 AM
Unknown Object (File)
Fri, Apr 26, 11:18 PM
Unknown Object (File)
Apr 11 2024, 12:08 AM
Unknown Object (File)
Apr 11 2024, 12:08 AM
Unknown Object (File)
Apr 11 2024, 12:08 AM
Unknown Object (File)
Apr 10 2024, 8:41 PM

Details

Summary

Avoid locking issues when if_allmulti() calls the driver's if_ioctl,
because that may acquire sleepable locks (while we hold a non-sleepable
rwlock).

Fortunately there's no pressing need to hold the mroute lock while we
do this, so we can postpone the call slightly, until after we've
released the lock.

This avoids the following WITNESS warning (with iflib drivers):

lock order reversal: (sleepable after non-sleepable)

	 1st 0xffffffff82f64960 IPv4 multicast forwarding (IPv4 multicast forwarding, rw) @ /usr/src/sys/netinet/ip_mroute.c:1050
	 2nd 0xfffff8000480f180 iflib ctx lock (iflib ctx lock, sx) @ /usr/src/sys/net/iflib.c:4525

lock order IPv4 multicast forwarding -> iflib ctx lock attempted at:
#0 0xffffffff80bbd6ce at witness_checkorder+0xbbe
#1 0xffffffff80b56d10 at _sx_xlock+0x60
#2 0xffffffff80c9ce5c at iflib_if_ioctl+0x2dc
#3 0xffffffff80c7c395 at if_setflag+0xe5
#4 0xffffffff82f60a0e at del_vif_locked+0x9e
#5 0xffffffff82f5f0d5 at X_ip_mrouter_set+0x265
#6 0xffffffff80bfd402 at sosetopt+0xc2
#7 0xffffffff80c02105 at kern_setsockopt+0xa5
#8 0xffffffff80c02054 at sys_setsockopt+0x24
#9 0xffffffff81046be8 at amd64_syscall+0x138
#10 0xffffffff8101930b at fast_syscall_common+0xf8

See also: https://redmine.pfsense.org/issues/12079
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Jul 27 2023, 12:18 PM
mjg added a subscriber: mjg.

i had a similar patch as a hack for this issue, what really needs to be done here though is a revamp

This revision is now accepted and ready to land.Jul 27 2023, 12:22 PM