netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: hannes@stressinduktion.org
Cc: eric.dumazet@gmail.com, mpb.mail@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH v4] inet: prevent leakage of uninitialized memory to user in recv syscalls
Date: Mon, 18 Nov 2013 15:14:30 -0500 (EST)	[thread overview]
Message-ID: <20131118.151430.75221704090778394.davem@davemloft.net> (raw)
In-Reply-To: <20131118032045.GJ16541@order.stressinduktion.org>

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Mon, 18 Nov 2013 04:20:45 +0100

> Only update *addr_len when we actually fill in sockaddr, otherwise we
> can return uninitialized memory from the stack to the caller in the
> recvfrom, recvmmsg and recvmsg syscalls. Drop the the (addr_len == NULL)
> checks because we only get called with a valid addr_len pointer either
> from sock_common_recvmsg or inet_recvmsg.
> 
> If a blocking read waits on a socket which is concurrently shut down we
> now return zero and set msg_msgnamelen to 0.
> 
> Reported-by: mpb <mpb.mail@gmail.com>
> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
> This is the first round, fixing the callees of sock_common_recvmsg and
> inet_recvmsg. I guess there are some more problems of this kind with
> recvmsg called directly via proto_ops->recvmsg. I will have a look at
> them in the next days.
> 
> We could actually leave out filling in msg_name if the user didn't request
> (src_addr == NULL in recvfrom). I'll put this on my TODO for net-next.
> Also it is possible to just update msg->msg_namelen directly here and simplify
> sock_common_recvmsg and inet_recvmsg, also for net-next.

This looks a lot better than your previous attempts, nice work.

Applied and queued up for -stable.

The handling of msg_name/msg_namelen in the ->recvmsg proto op is decidedly
non-trivial.  Can I suggest that we at least add some documentation about
this semantic above "(*recvmsg)" in the definition of proto_ops in
include/linux/net.h?

Thanks.

  parent reply	other threads:[~2013-11-18 20:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAApbN=Jm=zuDaVYALmGg5z_QfJJ3q13e9tshb7OpAtPQ8Ema1w@mail.gmail.com>
2013-11-13 20:07 ` Fwd: Cross thread shutdown of connected UDP socket, unexpected recvfrom behavior mpb
2013-11-15  4:05   ` Hannes Frederic Sowa
2013-11-16  5:43   ` [PATCH] socket: don't return uninitialized addresses on concurrent socket shutdown Hannes Frederic Sowa
2013-11-16  5:48     ` [PATCH v2] " Hannes Frederic Sowa
2013-11-16  6:32       ` Eric Dumazet
2013-11-16  6:39         ` Hannes Frederic Sowa
2013-11-16  6:42           ` Hannes Frederic Sowa
2013-11-16 19:19       ` [PATCH v3] net: " Hannes Frederic Sowa
2013-11-16 20:46         ` Eric Dumazet
2013-11-16 21:57           ` mpb
2013-11-16 22:43           ` Hannes Frederic Sowa
2013-11-17  0:36             ` Eric Dumazet
2013-11-17 19:22               ` Hannes Frederic Sowa
2013-11-18  3:20                 ` [PATCH v4] inet: prevent leakage of uninitialized memory to user in recv syscalls Hannes Frederic Sowa
2013-11-18 16:13                   ` Eric Dumazet
2013-11-18 20:14                   ` David Miller [this message]
2013-11-18 22:14                     ` Hannes Frederic Sowa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131118.151430.75221704090778394.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=mpb.mail@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).