]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r349369:
authorHans Petter Selasky <hselasky@FreeBSD.org>
Fri, 5 Jul 2019 10:31:37 +0000 (10:31 +0000)
committerHans Petter Selasky <hselasky@FreeBSD.org>
Fri, 5 Jul 2019 10:31:37 +0000 (10:31 +0000)
commit4c92d36a51d4ae100cccf6763c0c52abbbb88a0c
treef3bf3c86a67203c8bf845cfdcb7e27106b9ab686
parent4c608f24a0136fb17f6a833c8ddf59cf1c3a6cb6
MFC r349369:
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 @
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