mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: sasha.levin@oracle.com
Cc: kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
	kaber@trash.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ipv4: raw: don't agree to 0 sized headers
Date: Thu, 31 Jul 2014 12:24:32 -0700 (PDT)	[thread overview]
Message-ID: <20140731.122432.358447367571730334.davem@davemloft.net> (raw)
In-Reply-To: <1406726468-19035-1-git-send-email-sasha.levin@oracle.com>

From: Sasha Levin <sasha.levin@oracle.com>
Date: Wed, 30 Jul 2014 09:21:08 -0400

> For raw sockets, we'd always assume that a header is supplied and will attempt
> to copy it into the ip header space using memcpy_fromiovecend():
> 
> 	if (memcpy_fromiovecend((void *)iph, from, 0, length))
> 		goto error_free;
> 
> The problem is that memcpy_fromiovecend() assumes that there are actual data
> to read from the iovec and doesn't deal with cases where there are none:
> 
> 	int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
> 				int offset, int len)
> 	{
> 		/* Skip over the finished iovecs */
> 		while (offset >= iov->iov_len) {
> 			offset -= iov->iov_len;
> 			iov++;
> 		}
> 		[...]
> 
> So when offset == 0 and iov->iov_len == 0, we'll just run iov into random
> kernel memory until it hits something bad and dies in a BUG/panic - either
> killing the kernel or leaking memory and held locks.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>

I sincerely think that memcpy_fromiovecend() is the part at fault here.

Defensively it should handle zero length copies, as memcpy_fromiovec()
right above it does.

      reply	other threads:[~2014-07-31 19:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30 13:21 Sasha Levin
2014-07-31 19:24 ` David Miller [this message]

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=20140731.122432.358447367571730334.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sasha.levin@oracle.com \
    --cc=yoshfuji@linux-ipv6.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

all inboxes | Powered by JetHome®