Date: Mon, 7 Oct 2019 23:35:23 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353295 - head/sys/netinet6 Message-ID: <201910072335.x97NZNOV001164@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Mon Oct 7 23:35:23 2019 New Revision: 353295 URL: https://svnweb.freebsd.org/changeset/base/353295 Log: Improve locking in the IPV6_V6ONLY socket option handler. Acquire the inp lock before checking whether the socket is already bound, and around updates to the inp_vflag field. MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21867 Modified: head/sys/netinet6/ip6_output.c Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Mon Oct 7 23:31:17 2019 (r353294) +++ head/sys/netinet6/ip6_output.c Mon Oct 7 23:35:23 2019 (r353295) @@ -1806,21 +1806,24 @@ do { \ #endif case IPV6_V6ONLY: - /* - * make setsockopt(IPV6_V6ONLY) - * available only prior to bind(2). - * see ipng mailing list, Jun 22 2001. - */ + INP_WLOCK(inp); if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { + /* + * The socket is already bound. + */ + INP_WUNLOCK(inp); error = EINVAL; break; } - OPTSET(IN6P_IPV6_V6ONLY); - if (optval) + if (optval) { + inp->inp_flags |= IN6P_IPV6_V6ONLY; inp->inp_vflag &= ~INP_IPV4; - else + } else { + inp->inp_flags &= ~IN6P_IPV6_V6ONLY; inp->inp_vflag |= INP_IPV4; + } + INP_WUNLOCK(inp); break; case IPV6_RECVTCLASS: /* cannot mix with RFC2292 XXX */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910072335.x97NZNOV001164>