From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226x7Ir0cOzqQpxKPqJjdb9Hn9L4dapZcyz63c7ENkyAEtGQwJ7xlwJmiJzy/vX3hF4DRJ09 ARC-Seal: i=1; a=rsa-sha256; t=1517256597; cv=none; d=google.com; s=arc-20160816; b=csrgbYwPcYOeGjKzNARCtuuaklzd24zA4uW3AtAetEYKd/qlY/tGOpmVl8kS/vc2z9 PpF6TCk2AFkJlNRj6zGVb7LhC8vEak0HE529AAICsoQ93LPpodicOlGxTOF+nC/JjUB5 kfYszmsrrYeMj45BONtIG8DTp+w1sibBJS0xez1jKn2Ul1ARnoiuBlPLQ5A9nyvcQKQg iiZKTbCZDLU64UrT5hoOTg+EE99bOCgK8tBXAmQWTdA0k24aluobL7MDfsRwYbxAXEVK lfSxrUL3dwZ8N4+9764E6xpAAWqUtKSkKloE//eiqzz2alHDlapDyx5Q7TNr3n9IrkSX 1Pfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XacyLtITrm2iqDSdylHFUdRiIJchifIzcoLmZ2LUpMw=; b=i/Z9NxfoFCOFfsmaexwr0d6I9G37N3RKViNBIbh6eotchPNAY1bkv5iNoq0vYOZPz7 NmJzRimjh1dlmHImmAB6+SkOvMIOaRGhX69tT2Zqp/V/f3Tz7yW8lI2W/mSA+ot8OC3b Cs/k3tflc1t99AMjKtygi9pTll3uQ5boQEHF4hUfkNoTxOvMEe2//ER9sLcq8pS1jIbO ZIAD4Bd6Olx+IJqeX+5aAz6WwswTysSezo7gwLBZUO2JhiXBCRxd0LwLLoJf9OFKx+/K nglTFr8qfzJGKvYAAmC9hHFvJAXgnzxHOo+CflPdN1lURO1HnqGOkBuKBcxWvXcq/sqA JjAw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+7b7b518b1228d2743963@syzkaller.appspotmail.com, Neil Horman , Xin Long , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.4 68/74] sctp: do not allow the v4 socket to bind a v4mapped v6 address Date: Mon, 29 Jan 2018 13:57:13 +0100 Message-Id: <20180129123850.608774579@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958773280293896?= X-GMAIL-MSGID: =?utf-8?q?1590958853853396209?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit c5006b8aa74599ce19104b31d322d2ea9ff887cc ] The check in sctp_sockaddr_af is not robust enough to forbid binding a v4mapped v6 addr on a v4 socket. The worse thing is that v4 socket's bind_verify would not convert this v4mapped v6 addr to a v4 addr. syzbot even reported a crash as the v4 socket bound a v6 addr. This patch is to fix it by doing the common sa.sa_family check first, then AF_INET check for v4mapped v6 addrs. Fixes: 7dab83de50c7 ("sctp: Support ipv6only AF_INET6 sockets.") Reported-by: syzbot+7b7b518b1228d2743963@syzkaller.appspotmail.com Acked-by: Neil Horman Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -332,16 +332,14 @@ static struct sctp_af *sctp_sockaddr_af( if (len < sizeof (struct sockaddr)) return NULL; + if (!opt->pf->af_supported(addr->sa.sa_family, opt)) + return NULL; + /* V4 mapped address are really of AF_INET family */ if (addr->sa.sa_family == AF_INET6 && - ipv6_addr_v4mapped(&addr->v6.sin6_addr)) { - if (!opt->pf->af_supported(AF_INET, opt)) - return NULL; - } else { - /* Does this PF support this AF? */ - if (!opt->pf->af_supported(addr->sa.sa_family, opt)) - return NULL; - } + ipv6_addr_v4mapped(&addr->v6.sin6_addr) && + !opt->pf->af_supported(AF_INET, opt)) + return NULL; /* If we get this far, af is valid. */ af = sctp_get_af_specific(addr->sa.sa_family);