From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753593AbdJaQOv (ORCPT ); Tue, 31 Oct 2017 12:14:51 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:47560 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751516AbdJaQOt (ORCPT ); Tue, 31 Oct 2017 12:14:49 -0400 X-Google-Smtp-Source: ABhQp+SFRUpiqDKPqbVRcbtsFIDPIJsKs9LKf8hnkvSQ47U6GzflmLAdWM/Tvc0t9Gk92VRbdGP1CA== Date: Tue, 31 Oct 2017 09:14:45 -0700 From: Kees Cook To: "David S. Miller" Cc: Alexander Potapenko , Kostya Serebryany , Andrey Konovalov , Eric Dumazet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, security@kernel.org Subject: [PATCH] net: recvmsg: Unconditionally zero struct sockaddr_storage Message-ID: <20171031161445.GA140874@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some protocols do not correctly wipe the contents of the on-stack struct sockaddr_storage sent down into recvmsg() (e.g. SCTP), and leak kernel stack contents to userspace. This wipes it unconditionally before per-protocol handlers run. Note that leaks like this are mitigated by building with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y Reported-by: Alexander Potapenko Cc: "David S. Miller" Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- net/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/socket.c b/net/socket.c index c729625eb5d3..34183f4fbdf8 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2188,6 +2188,7 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg, struct sockaddr __user *uaddr; int __user *uaddr_len = COMPAT_NAMELEN(msg); + memset(&addr, 0, sizeof(addr)); msg_sys->msg_name = &addr; if (MSG_CMSG_COMPAT & flags) -- 2.7.4 -- Kees Cook Pixel Security