From owner-svn-src-releng@freebsd.org Wed Jul 8 20:11:41 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDF4036DE6D; Wed, 8 Jul 2020 20:11:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B29SF62b9z3c90; Wed, 8 Jul 2020 20:11:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A581C25BA4; Wed, 8 Jul 2020 20:11:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 068KBfmd029382; Wed, 8 Jul 2020 20:11:41 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 068KBejP029378; Wed, 8 Jul 2020 20:11:40 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <202007082011.068KBejP029378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Wed, 8 Jul 2020 20:11:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r363026 - in releng: 11.3/sys/netinet6 11.4/sys/netinet6 12.1/sys/netinet6 X-SVN-Group: releng X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: in releng: 11.3/sys/netinet6 11.4/sys/netinet6 12.1/sys/netinet6 X-SVN-Commit-Revision: 363026 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2020 20:11:42 -0000 Author: gordon Date: Wed Jul 8 20:11:40 2020 New Revision: 363026 URL: https://svnweb.freebsd.org/changeset/base/363026 Log: Fix IPv6 socket option race condition and use after free. Approved by: so Security: FreeBSD-SA-20:20.ipv6 Security: CVE-2020-7457 Modified: releng/11.3/sys/netinet6/ip6_output.c releng/11.4/sys/netinet6/ip6_output.c releng/12.1/sys/netinet6/ip6_output.c Modified: releng/11.3/sys/netinet6/ip6_output.c ============================================================================== --- releng/11.3/sys/netinet6/ip6_output.c Wed Jul 8 20:08:05 2020 (r363025) +++ releng/11.3/sys/netinet6/ip6_output.c Wed Jul 8 20:11:40 2020 (r363026) @@ -1498,8 +1498,10 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) error = soopt_mcopyin(sopt, m); /* XXX */ if (error != 0) break; + INP_WLOCK(in6p); error = ip6_pcbopts(&in6p->in6p_outputopts, m, so, sopt); + INP_WUNLOCK(in6p); m_freem(m); /* XXX */ break; } @@ -2244,8 +2246,11 @@ ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf * printf("ip6_pcbopts: all specified options are cleared.\n"); #endif ip6_clearpktopts(opt, -1); - } else - opt = malloc(sizeof(*opt), M_IP6OPT, M_WAITOK); + } else { + opt = malloc(sizeof(*opt), M_IP6OPT, M_NOWAIT); + if (opt == NULL) + return (ENOMEM); + } *pktopt = NULL; if (!m || m->m_len == 0) { Modified: releng/11.4/sys/netinet6/ip6_output.c ============================================================================== --- releng/11.4/sys/netinet6/ip6_output.c Wed Jul 8 20:08:05 2020 (r363025) +++ releng/11.4/sys/netinet6/ip6_output.c Wed Jul 8 20:11:40 2020 (r363026) @@ -1514,8 +1514,10 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) error = soopt_mcopyin(sopt, m); /* XXX */ if (error != 0) break; + INP_WLOCK(in6p); error = ip6_pcbopts(&in6p->in6p_outputopts, m, so, sopt); + INP_WUNLOCK(in6p); m_freem(m); /* XXX */ break; } @@ -2260,8 +2262,11 @@ ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf * printf("ip6_pcbopts: all specified options are cleared.\n"); #endif ip6_clearpktopts(opt, -1); - } else - opt = malloc(sizeof(*opt), M_IP6OPT, M_WAITOK); + } else { + opt = malloc(sizeof(*opt), M_IP6OPT, M_NOWAIT); + if (opt == NULL) + return (ENOMEM); + } *pktopt = NULL; if (!m || m->m_len == 0) { Modified: releng/12.1/sys/netinet6/ip6_output.c ============================================================================== --- releng/12.1/sys/netinet6/ip6_output.c Wed Jul 8 20:08:05 2020 (r363025) +++ releng/12.1/sys/netinet6/ip6_output.c Wed Jul 8 20:11:40 2020 (r363026) @@ -1544,8 +1544,10 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) error = soopt_mcopyin(sopt, m); /* XXX */ if (error != 0) break; + INP_WLOCK(in6p); error = ip6_pcbopts(&in6p->in6p_outputopts, m, so, sopt); + INP_WUNLOCK(in6p); m_freem(m); /* XXX */ break; } @@ -2305,8 +2307,11 @@ ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf * printf("ip6_pcbopts: all specified options are cleared.\n"); #endif ip6_clearpktopts(opt, -1); - } else - opt = malloc(sizeof(*opt), M_IP6OPT, M_WAITOK); + } else { + opt = malloc(sizeof(*opt), M_IP6OPT, M_NOWAIT); + if (opt == NULL) + return (ENOMEM); + } *pktopt = NULL; if (!m || m->m_len == 0) {