Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4811135yba; Tue, 30 Apr 2019 04:54:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoEbN1koJ3DsSFRao9fXZsmNnkcKTHjfIVFB4rTkpZQOgTwK7cZBmRHIcXQKp7wGLa7IHb X-Received: by 2002:a63:6804:: with SMTP id d4mr65940057pgc.240.1556625281417; Tue, 30 Apr 2019 04:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625281; cv=none; d=google.com; s=arc-20160816; b=laQlhagf8f8hCV6H/o0Cz6sPUL5VNocFm8XDlOi9NCOfyPcyiQuB4QvfHwp3cv6J4h R+yRaNW2q8dLN/C8ieMXMoYAYIWaVT0vg/k+3WlulSAo4IFsDYiLr8QxMF5j+E5eLjAG dANJfGZ+BRXgOHoT1NvhgLt7zILfguKsGT/5pH4j6kmbkjty1Wyly9P6pDubYp8EU65V n/37dkytUqZw9DaAsRQ1H4hXINke8MqDUpCBCOPY0Qpt17ejMnDuwmqlI2+io0EAv+Jb J9rXYQKGLHIjTGw2b9Csc9Lgv2DMgtvg7D4YBB6h+FSwKqXZnjv0iybnyWoKoT9H3FyE OXZQ== 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=+9yXpgoARa6+QnqbsMlqZcaqY1/JlYDPZqiy7u70SjQ=; b=VK5qeVWVffiVRLXuKxwTfnOaVcIjB0ZfjAqgpYtg45N8y5dihrsKkuxEDg/WIkA/36 in0ZlUkl1naZQsC/8xrYorCmuu+VaJgFZUOMos7d9uGJO3khCux0urZqnEhoZVQ8MIDM lxhie7cDAduR0YljaMdO4zxmrkT6VeHfJS2fwaxt4r99X8l71Dbz21B6JSQEuZZcJSfS I5EoGMHIxiH/4PNa/yT9+e6xBeLLPFd4HxQpGs8MMehreYCK8kyt5dA+BNq/QNhdByR3 Vn/CQhbDeshE14midC+kgNn6q8ltr6dyyfMQiEwfkzcGAgS2UnOmkKFTB63qWtJMqdFS 26Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LD8evLyX; 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 o64si37080791pfa.274.2019.04.30.04.54.26; Tue, 30 Apr 2019 04:54:41 -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=LD8evLyX; 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 S1728221AbfD3Lvq (ORCPT + 99 others); Tue, 30 Apr 2019 07:51:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731024AbfD3Lvn (ORCPT ); Tue, 30 Apr 2019 07:51:43 -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 C43EF2054F; Tue, 30 Apr 2019 11:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625103; bh=hbj4Hxas9SpGGmTaop8aSYshdRBvhpHxjJXEVUtkxbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LD8evLyXqwWcEpLNEepnR5D9x6aRy24JNrKVadGznlSpYdANmM98TaF8IERqxOLmS aDjYx/ZrjKJtt3QXACHtAq5kc9ufLSf6UyFcm8r1XlGvp6tvoMabENymqt5N5QqjZS eOfA9CTx903BZ/OW8+a4Q6EMtFBnbRDzJuF/tOaI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Tetsuo Handa , Trond Myklebust Subject: [PATCH 5.0 56/89] NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family. Date: Tue, 30 Apr 2019 13:38:47 +0200 Message-Id: <20190430113612.304331882@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 7c2bd9a39845bfb6d72ddb55ce737650271f6f96 upstream. syzbot is reporting uninitialized value at rpc_sockaddr2uaddr() [1]. This is because syzbot is setting AF_INET6 to "struct sockaddr_in"->sin_family (which is embedded into user-visible "struct nfs_mount_data" structure) despite nfs23_validate_mount_data() cannot pass sizeof(struct sockaddr_in6) bytes of AF_INET6 address to rpc_sockaddr2uaddr(). Since "struct nfs_mount_data" structure is user-visible, we can't change "struct nfs_mount_data" to use "struct sockaddr_storage". Therefore, assuming that everybody is using AF_INET family when passing address via "struct nfs_mount_data"->addr, reject if its sin_family is not AF_INET. [1] https://syzkaller.appspot.com/bug?id=599993614e7cbbf66bc2656a919ab2a95fb5d75c Reported-by: syzbot Signed-off-by: Tetsuo Handa Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2041,7 +2041,8 @@ static int nfs23_validate_mount_data(voi memcpy(sap, &data->addr, sizeof(data->addr)); args->nfs_server.addrlen = sizeof(data->addr); args->nfs_server.port = ntohs(data->addr.sin_port); - if (!nfs_verify_server_address(sap)) + if (sap->sa_family != AF_INET || + !nfs_verify_server_address(sap)) goto out_no_address; if (!(data->flags & NFS_MOUNT_TCP))