Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2050633imm; Thu, 24 May 2018 05:06:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoI+VU1Ym7s5qdNGz8g/pAfIsQrnPVSpwCjpscMep7qc3yO2Cl9pNmK0IgtnW+Ivxj+vLQz X-Received: by 2002:a17:902:6549:: with SMTP id d9-v6mr7160253pln.196.1527163591414; Thu, 24 May 2018 05:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163591; cv=none; d=google.com; s=arc-20160816; b=gGXbNIC0VPImN5DjhmS6GuyOJkLgVXb/QyMTkJwR2KS+Otl0rpqn9Zo//n42MXPfi3 UFMMQUdINsBmtYCrjfkBY+n+4TVoJW043RhMP6otUiEA8pw+lwYNLgLi7O8Xh4IMxoAk JJQXSpp8eZxfgz+dgBhDp3nL+X9ljp17hUlrOaNlHuV2KngO7kq/NKab+/eQZ+Xz+2+n D/kbTbS3WhWZBz3gwxuG8ZRvSSC4i2gA73UqRoJgvy/6JieljBIrG0CXdpqXUlQ5oEKZ dESUWM1lDjO1/y+wuYRzw9tR1z101GXkMd0OtkosNL2W6NeDC4VMBBN1ikMNKv6P0rTI LwOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2c4n0uy9eYPE3eQTAbzsuGo3jCL8hG2MJJYu6dtSNGY=; b=i5RwSL8TytVWa/PRj1nuj1yMdOnpTX/9TSrujUXa6TWoc9V3HA65b69NmEGPFjJdkz MXu8VTGvIFFyxyygKq90pqiWMt5diGstSB5zHOgd7giS1rYdXRvpzAEVBMU8Ho6W9eLx TyFOXxt2j6vL0VLZ74qf4jsmS4iWqnhQuPRwWctEbspfOH/yCMN1vlRA9ekBobE+WaK3 gzqPLlruzya6J4UNDBxEu6Eft0bUneJML6EI2/xg2q/Ev84cxoE9K+zQkgoS+wvvsdK2 GmCDNk9T8uAhAG7Kv5N84uN5HKKfOch+A4XgKcSYesiJkdQotyhabdqsZYTF9VEESIqH V0kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o/sQC6/Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k82-v6si21791721pfj.302.2018.05.24.05.06.15; Thu, 24 May 2018 05:06:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o/sQC6/Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969628AbeEXMDD (ORCPT + 99 others); Thu, 24 May 2018 08:03:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:55932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966394AbeEXJok (ORCPT ); Thu, 24 May 2018 05:44:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE0EC208B6; Thu, 24 May 2018 09:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155080; bh=HQnb9+MiBwW329oafVbKmCJ+ZHiZI/K9QE6LpczmV44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/sQC6/YPwi/G/j1BiApCrxIvLhY5nvcsyobufBNJ4qh4AZr8D+UVDU5yILl8NkQM RLDDbHr8RPpK83hwAcNYkU/2mbvfDZoTW9Vh64+X57SXm7Fy7EbI7FsgP+KOMOCi5p 6ks8m6YUPtualCuUiOd0CYFnAAXCwE3zA//D2ub4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+cd494c1dd681d4d93ebb@syzkaller.appspotmail.com, Xin Long , Neil Horman , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.4 13/92] sctp: handle two v4 addrs comparison in sctp_inet6_cmp_addr Date: Thu, 24 May 2018 11:37:50 +0200 Message-Id: <20180524093200.452022191@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit d625329b06e46bd20baf9ee40847d11982569204 ] Since sctp ipv6 socket also supports v4 addrs, it's possible to compare two v4 addrs in pf v6 .cmp_addr, sctp_inet6_cmp_addr. However after Commit 1071ec9d453a ("sctp: do not check port in sctp_inet6_cmp_addr"), it no longer calls af1->cmp_addr, which in this case is sctp_v4_cmp_addr, but calls __sctp_v6_cmp_addr where it handles them as two v6 addrs. It would cause a out of bounds crash. syzbot found this crash when trying to bind two v4 addrs to a v6 socket. This patch fixes it by adding the process for two v4 addrs in sctp_inet6_cmp_addr. Fixes: 1071ec9d453a ("sctp: do not check port in sctp_inet6_cmp_addr") Reported-by: syzbot+cd494c1dd681d4d93ebb@syzkaller.appspotmail.com Signed-off-by: Xin Long Acked-by: Neil Horman Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/ipv6.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -863,6 +863,9 @@ static int sctp_inet6_cmp_addr(const uni if (sctp_is_any(sk, addr1) || sctp_is_any(sk, addr2)) return 1; + if (addr1->sa.sa_family == AF_INET && addr2->sa.sa_family == AF_INET) + return addr1->v4.sin_addr.s_addr == addr2->v4.sin_addr.s_addr; + return __sctp_v6_cmp_addr(addr1, addr2); }