public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Galbraith <umgwanakikbuti@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: linux-kernel@vger.kernel.org, netdev <netdev@vger.kernel.org>
Subject: Re: recvmmsg/sendmmsg result types inconsistent, integer overflows?
Date: Wed, 11 Jun 2014 07:24:21 +0200	[thread overview]
Message-ID: <1402464261.5195.21.camel@marge.simpson.net> (raw)
In-Reply-To: <20140611041243.GA1475@brightrain.aerifal.cx>

(CCs network wizard hangout)

On Wed, 2014-06-11 at 00:12 -0400, Rich Felker wrote: 
> While looking to add support for the recvmmsg and sendmmsg syscalls in
> musl libc, I ran into some disturbing findings on the kernel side. In
> the struct mmsghdr, the field where the result for each message is
> stored has type int, which is inconsistent with the return type
> ssize_t of recvmsg/sendmsg. So I tried to track down what happens when
> the result is or would be larger than 2GB, and quickly found an
> explanation for why the type in the structure was defined wrong:
> internally, the kernel uses int as the return type for revcmsg and
> sendmsg. Oops.
> 
> A bit more RTFS'ing brought me to tcp_sendmsg in net/ipv4/tcp.c (I
> figured let's look at a stream-based protocol, since datagrams can
> likely never be that big for any existing protocol), and as far as I
> can tell, it's haphazardly mixing int and size_t with no checks for
> overflows. I looked for anywhere the kernel might try to verify before
> starting that the sum of the lengths of all the iovec components
> doesn't overflow INT_MAX or even SIZE_MAX, but didn't find any such
> checks.
> 
> Is there some magic that makes this all safe, or is this a big mess of
> possibly-security-relevant bugs?
> 
> Rich
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

       reply	other threads:[~2014-06-11  5:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140611041243.GA1475@brightrain.aerifal.cx>
2014-06-11  5:24 ` Mike Galbraith [this message]
2014-06-11  5:50   ` recvmmsg/sendmmsg result types inconsistent, integer overflows? Eric Dumazet
2014-06-11 15:15     ` Rich Felker
2014-06-12  6:04       ` Michael Kerrisk (man-pages)
2014-06-12 14:13         ` Rich Felker
2014-06-12 18:53           ` Michael Kerrisk (man-pages)

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=1402464261.5195.21.camel@marge.simpson.net \
    --to=umgwanakikbuti@gmail.com \
    --cc=dalias@libc.org \
    --cc=linux-kernel@vger.kernel.org \
    --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