[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1509471336.2748.58.camel@decadent.org.uk>
Date: Tue, 31 Oct 2017 17:35:36 +0000
From: Ben Hutchings <ben@...adent.org.uk>
To: Kees Cook <keescook@...omium.org>,
"David S. Miller" <davem@...emloft.net>
Cc: Alexander Potapenko <glider@...gle.com>,
Kostya Serebryany <kcc@...gle.com>,
Andrey Konovalov <andreyknvl@...gle.com>,
Eric Dumazet <edumazet@...gle.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, security@...nel.org
Subject: Re: [PATCH] net: recvmsg: Unconditionally zero struct
sockaddr_storage
On Tue, 2017-10-31 at 09:14 -0700, Kees Cook wrote:
> 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 <glider@...gle.com>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: netdev@...r.kernel.org
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
> 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));
That's a fairly large structure (128 bytes), most of which won't
normally be used. We already initialise msg_namelen to 0 before
calling the per-protocol handler, which means by default nothing leaks.
Only cases where msg_namelen is set but msg_name[] is not initialised
up to that length are a problem. I would have thought they were not
too hard to find and fix.
Ben.
> msg_sys->msg_name = &addr;
>
> if (MSG_CMSG_COMPAT & flags)
> --
> 2.7.4
>
>
--
Ben Hutchings
It is a miracle that curiosity survives formal education. - Albert
Einstein
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists