dccp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: dccp@vger.kernel.org
Subject: RE: get rid of the address_space override in setsockopt v2
Date: Mon, 27 Jul 2020 14:09:09 +0000	[thread overview]
Message-ID: <5d958e937db54849b4ef9046e7e12277@AcuMS.aculab.com> (raw)
In-Reply-To: <20200720124737.118617-1-hch@lst.de>

From: Al Viro
> Sent: 27 July 2020 14:48
> 
> On Mon, Jul 27, 2020 at 09:51:45AM +0000, David Laight wrote:
> 
> > I'm sure there is code that processes options in chunks.
> > This probably means it is possible to put a chunk boundary
> > at the end of userspace and continue processing the very start
> > of kernel memory.
> >
> > At best this faults on the kernel copy code and crashes the system.
> 
> Really?  Care to provide some details, or is it another of your "I can't
> be possibly arsed to check what I'm saying, but it stands for reason
> that..." specials?

I did more 'homework' than sometimes :-)
Slightly difficult without a searchable net-next tree.
However, as has been pointed out is a different thread
this code is used to update IPv6 flow labels:

> > -		if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen))
> > +		sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq)));
> > +		if (copy_from_sockptr(fl->opt + 1, optval, olen))
> >  			goto done;

and doesn't work because the advances are no longer cumulative.

Now access_ok() has to take the base address and length to stop
'running into' kernel space, but the code above can advance from
a valid user pointer (which won't fault) to a kernel address.

If there were always an unmapped 'guard' page in the user address
space the access_ok() check prior to copy_to/from_user() wouldn't
need the length.
So I surmise that no such guard page exists and so the above
can advance from user addresses into kernel ones.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      parent reply	other threads:[~2020-07-27 14:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 12:47 get rid of the address_space override in setsockopt Christoph Hellwig
2020-07-20 16:38 ` Eric Biggers
2020-07-20 17:43 ` Christoph Hellwig
2020-07-20 20:47 ` Alexei Starovoitov
2020-07-21  9:38 ` David Laight
2020-07-21 10:26 ` David Laight
2020-07-22  7:56 ` Christoph Hellwig
2020-07-22  8:06 ` 'Christoph Hellwig'
2020-07-22  8:07 ` 'Christoph Hellwig'
2020-07-22  8:21 ` David Laight
2020-07-22 17:09 ` Alexei Starovoitov
2020-07-23  6:08 ` get rid of the address_space override in setsockopt v2 Christoph Hellwig
2020-07-24 22:43 ` David Miller
2020-07-26  7:03 ` Christoph Hellwig
2020-07-26  7:08 ` Andreas Schwab
2020-07-26  7:46 ` David Miller
2020-07-27  9:51 ` David Laight
2020-07-27 13:48 ` Al Viro
2020-07-27 14:09 ` David Laight [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=5d958e937db54849b4ef9046e7e12277@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=dccp@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 read-only IMAP folder(s) and NNTP newsgroup(s).