Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4812729yba; Tue, 30 Apr 2019 04:56:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzE/yOLGXcowc11pHEPc/Eai3cJqE6zljGPl8Zfi8m2QRBixepY7nNCI6DY55KB78CgcLp X-Received: by 2002:a17:902:a7:: with SMTP id a36mr68669348pla.111.1556625393690; Tue, 30 Apr 2019 04:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625393; cv=none; d=google.com; s=arc-20160816; b=AyNOtsyJhQ0Cm4ivsZG9KD9qrUcossIdmjvcxFqz6H8fWq7+zHAu69kTzkEJny1Uq0 KkWxICnhltu7dU9Mnxqwpy7N/pIriw4GM6J4CZaVGRfsFsDmKFgN8jrI90tEyvygapKK gJCcGNLl1E/tp5DCuYKqU6tVxdypKmOMLipaUliXEkOraqQg02gshDge++SV78WlcqzH ilLOaxLaZDev+wUqO+ezSNFsgdcEelwnb3FGs6Z4ktM2AL+0xj0aKij1x9fhpOtAxM3A pW6yMGiJ1K+3pxxKWIRuprD0eISPvrwjdaZXnVqgoTr0L1q32F9AuhgoVlHezkXhMEkC wAcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CXJ/DR1dKoxtLXxN7w/Uh4w/xIRNO6+3wsuIKIhrfAs=; b=AHwxhdp2ad2FPTtIryBd92t+gYOG59TFAYFFsUSXBBJ+BPki1IUrM08MjzyCLaJBOz qsl4lfzGO49cmxgKvf/C75PJH2KtLCVvJ5nvnECyxDC5zTmDWhKq5kW7BvlJFkKpaM2o KxUQ8sn0l8LeWnlUtl9Y1lzmxq+7eDVfUAe45h93gXrnWf7BGH/VPk/FoaJ/MzXYYpT0 O1KT5JoE7jzO6Yrf+43WtiAMIhNBqdAaYBfEd1Q2AUkInM0to3ur5VSvXc0zU/EaAKNN 8WedGi6BagqJHzctwG/rF1AsmLwdaxOFzLaAtV5Gb6L+ZIC1UyDWultRu1s8BVCvM27j 17+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xDA1KWAV; 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 a67si36242672pgc.80.2019.04.30.04.56.18; Tue, 30 Apr 2019 04:56:33 -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=xDA1KWAV; 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 S1731194AbfD3Lu1 (ORCPT + 99 others); Tue, 30 Apr 2019 07:50:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731182AbfD3LuX (ORCPT ); Tue, 30 Apr 2019 07:50:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1400821670; Tue, 30 Apr 2019 11:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625022; bh=+ebOXy1Dc42e2ylzFgurqpriBg0nrITmuqCC5h/OTV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDA1KWAVK8V86Z2Yi1mUr/3+TuNIsPPvA4XhMAt/ukDW0sODPyfEtUrT7bUJxvGBK Vvjo8h5+RkkBEG6Gn3q1C8x1+Yrp4fLfIcWFBTDW9vj/F4ggasJo01ViSDiMB9LoVL MPajDpGA3WtzcL6rJ7WHvDeC1kb/3ILNnTkPLG5Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , syzbot , Tetsuo Handa , Santosh Shilimkar , "David S. Miller" Subject: [PATCH 5.0 62/89] net/rds: Check address length before reading address family Date: Tue, 30 Apr 2019 13:38:53 +0200 Message-Id: <20190430113612.606541047@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa commit dd3ac9a684358b8c1d5c432ca8322aaf5e4f28ee upstream. syzbot is reporting uninitialized value at rds_connect() [1] and rds_bind() [2]. This is because syzbot is passing ulen == 0 whereas these functions expect that it is safe to access sockaddr->family field in order to determine minimal address length for validation. [1] https://syzkaller.appspot.com/bug?id=f4e61c010416c1e6f0fa3ffe247561b60a50ad71 [2] https://syzkaller.appspot.com/bug?id=a4bf9e41b7e055c3823fdcd83e8c58ca7270e38f Reported-by: syzbot Reported-by: syzbot Signed-off-by: Tetsuo Handa Acked-by: Santosh Shilimkar Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/rds/af_rds.c | 3 +++ net/rds/bind.c | 2 ++ 2 files changed, 5 insertions(+) --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c @@ -506,6 +506,9 @@ static int rds_connect(struct socket *so struct rds_sock *rs = rds_sk_to_rs(sk); int ret = 0; + if (addr_len < offsetofend(struct sockaddr, sa_family)) + return -EINVAL; + lock_sock(sk); switch (uaddr->sa_family) { --- a/net/rds/bind.c +++ b/net/rds/bind.c @@ -173,6 +173,8 @@ int rds_bind(struct socket *sock, struct /* We allow an RDS socket to be bound to either IPv4 or IPv6 * address. */ + if (addr_len < offsetofend(struct sockaddr, sa_family)) + return -EINVAL; if (uaddr->sa_family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;