]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Convert all IPv4 and IPv6 multicast memberships into using a STAILQ
authorhselasky <hselasky@FreeBSD.org>
Tue, 25 Jun 2019 11:54:41 +0000 (11:54 +0000)
committerhselasky <hselasky@FreeBSD.org>
Tue, 25 Jun 2019 11:54:41 +0000 (11:54 +0000)
commit1a5fd513af7e3801164aea50e6e53cd0b12075d8
treeb8dc02847e77eabbbea36e2a1519059383893961
parentea2c70c422748217e5406c3874c7acfb0cb63fc2
Convert all IPv4 and IPv6 multicast memberships into using a STAILQ
instead of a linear array.

The multicast memberships for the inpcb structure are protected by a
non-sleepable lock, INP_WLOCK(), which needs to be dropped when
calling the underlying possibly sleeping if_ioctl() method. When using
a linear array to keep track of multicast memberships, the computed
memory location of the multicast filter may suddenly change, due to
concurrent insertion or removal of elements in the linear array. This
in turn leads to various invalid memory access issues and kernel
panics.

To avoid this problem, put all multicast memberships on a STAILQ based
list. Then the memory location of the IPv4 and IPv6 multicast filters
become fixed during their lifetime and use after free and memory leak
issues are easier to track, for example by: vmstat -m | grep multi

All list manipulation has been factored into inline functions
including some macros, to easily allow for a future hash-list
implementation, if needed.

This patch has been tested by pho@ .

Differential Revision: https://reviews.freebsd.org/D20080
Reviewed by: markj @
MFC after: 1 week
Sponsored by: Mellanox Technologies
15 files changed:
sys/net/if_vxlan.c
sys/netinet/in.h
sys/netinet/in_mcast.c
sys/netinet/in_pcb.c
sys/netinet/in_var.h
sys/netinet/ip_carp.c
sys/netinet/ip_mroute.c
sys/netinet/ip_var.h
sys/netinet6/in6.h
sys/netinet6/in6_ifattach.c
sys/netinet6/in6_mcast.c
sys/netinet6/in6_pcb.c
sys/netinet6/in6_var.h
sys/netinet6/ip6_var.h
sys/netpfil/pf/if_pfsync.c