netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: ncardwell@google.com
Cc: edumazet@google.com, netdev@vger.kernel.org
Subject: Re: [PATCH net] inet_diag: fix oops for IPv4 AF_INET6 TCP SYN-RECV state
Date: Fri, 07 Dec 2012 13:20:19 -0500 (EST)	[thread overview]
Message-ID: <20121207.132019.1647690876686095833.davem@davemloft.net> (raw)
In-Reply-To: <1354808546-644-1-git-send-email-ncardwell@google.com>

From: Neal Cardwell <ncardwell@google.com>
Date: Thu,  6 Dec 2012 10:42:26 -0500

> Fix inet_diag to be aware of the fact that AF_INET6 TCP connections
> instantiated for IPv4 traffic and in the SYN-RECV state were actually
> created with inet_reqsk_alloc(), instead of inet6_reqsk_alloc(). This
> means that for such connections inet6_rsk(req) returns a pointer to a
> random spot in memory up to roughly 64KB beyond the end of the
> request_sock.
> 
> With this bug, for a server using AF_INET6 TCP sockets and serving
> IPv4 traffic, an inet_diag user like `ss state SYN-RECV` would lead to
> inet_diag_fill_req() causing an oops or the export to user space of 16
> bytes of kernel memory as a garbage IPv6 address, depending on where
> the garbage inet6_rsk(req) pointed.
> 
> Signed-off-by: Neal Cardwell <ncardwell@google.com>

Thanks for this fix, but it opens up more questions.

We don't seem to make any validations upon inet_diag_hostcond's
prefix_len.  That parameter we pass into bitstring_match() can
be just about anything.

As another example, what if we do an ipv6 128-bit compare on what's
actually an ipv4 address in the inet request sock?

I think we need to, using cond->family, make some kind of validations
upon cond->prefix_len.

  reply	other threads:[~2012-12-07 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-06 15:42 [PATCH net] inet_diag: fix oops for IPv4 AF_INET6 TCP SYN-RECV state Neal Cardwell
2012-12-07 18:20 ` David Miller [this message]
2012-12-08  2:30   ` Neal Cardwell
2012-12-08  3:36     ` Neal Cardwell

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=20121207.132019.1647690876686095833.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ncardwell@google.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).