All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Leonard den Ottolander
	<leonard-lists-2Avth2y2NeLyQNdsBcn8aGZHpeb/A1Y/@public.gmane.org>,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: binfmts.h MAX_ARG_STRINGS excessive value allows heap spraying
Date: Thu, 9 Mar 2017 09:35:13 -0500	[thread overview]
Message-ID: <2222c69b-cee9-dfc9-242f-344eeeaa13f5@redhat.com> (raw)
In-Reply-To: <1489068270.1026.6.camel@quad>

On 03/09/2017 09:04 AM, Leonard den Ottolander wrote:
> On Wed, 2017-03-08 at 16:05 -0500, Carlos O'Donell wrote: 
>> On 03/08/2017 01:18 PM, Leonard den Ottolander wrote:
>>> Note that 128KiB * 4096 arguments still adds up to 512MiB!!!
>>>
>>> If you don't feel the limit of 4096 arguments is sufficient please
>>> provide us with an example where that limit is insufficient.
>>
>> (a) Justification.
>>
>> A good design should not unduly limit what users can do without a good
>> justification.
> 
> The justification is that the excessive value of the MAX_ARG_STRINGS
> allows heap spraying on 32 bit processes. Or more precisely, the fact
> that the multiplication of MAX_ARG_STRINGS and MAX_ARG_STRLEN being
> equal to or larger than the 2^32 allows heap spraying.
> 
>> It is my opinion that it is not enough data to say that a kernel build
>> is sufficient to justify a limit that will affect all applications.
>>
>> Minimally I'd expect you to run with such a kernel patch through an entire
>> distro build cycle to see if anything else breaks.
> 
> I don't think that's really necessary. We can argue whether that value
> should be a bit bigger, but a limit is necessary to disable the very
> serious attack vector that heap spraying is. In any binary, not just
> setuid ones. It's a jumping board to launch any attack via the heap
> sprayed binary.

It is my opinion that your justification is insufficient to limit all
of userspace to the newer more restrictive limit without any remedy
should existing build systems start to fail. One could argue the use of
@file support in the compiler, static linker, and assembler might help,
but that doesn't fix all issues and could be costly to re-architect such
build systems.

We should pursue other avenues to limit the attack vector first.

> Of course an extra value limiting this multiplier could be added
> (MAX_ARG_STRSLEN along the lines of MAX_ARG_PAGES) and used in exec.c to
> limit the total amount of reserved memory. This would allow for the
> multiplication of MAX_ARG_STRINGS and MAX_ARG_STRLEN to go beyond 2^32.

This sounds like a much better option, particularly if as a remedy the
system administrator can control the max pages allowed for this to a
configurable limit.

> I have not been dtracing for, but I've not encountered any issue with
> kernels using MAX_ARG_STRLEN 65536 and MAX_ARG_STRINGS 4096 so far
> (running a.o. on this desktop).

This is insufficient research into the problem to justify lowering
the limit.

>> (c) What limit is appropriate?
>>
>> No limit is appropriate. Users should be able to use all of their system
>> resources to accomplish whatever task they need to get done.
> 
> Oh the poor user. So you rather leave the user exposed to attacks that
> leverage heap spraying than imposing a limit?

There is a balance between keeping large build systems functional and
limiting arguments.

My position is that I would rather harden malloc metadata than limit
argument lengths. Florian Weimer on my team (Red Hat glibc team) is
already looking at this:

https://sourceware.org/ml/libc-alpha/2016-10/msg00531.html

This would force attackers to have to find entirely new ways to attack
the heap metadata.
 
> The point is that this value (the multiplication of both really) allows
> an adversary to launch any attack in his inventory using a heap sprayed
> binary. That is not a situation you want to prolong.

This is hyperbole. You have to take a common sense approach to closing
these attack vectors and balance them against system usability.

-- 
Cheers,
Carlos.

  reply	other threads:[~2017-03-09 14:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 14:44 binfmts.h MAX_ARG_STRINGS excessive value allows heap spraying Leonard den Ottolander
2017-03-08 17:54 ` Carlos O'Donell
     [not found]   ` <f7f9f60b-0f39-7dce-1778-3aa40ba198ef-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-08 18:18     ` Leonard den Ottolander
2017-03-08 18:21       ` Leonard den Ottolander
2017-03-08 20:47       ` Joseph Myers
2017-03-08 21:05       ` Carlos O'Donell
     [not found]         ` <f16cd7f8-f996-cf66-d640-50b0ccee06c7-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-09 14:04           ` Leonard den Ottolander
2017-03-09 14:35             ` Carlos O'Donell [this message]
2017-03-09 14:14           ` Leonard den Ottolander
2017-03-09 20:34             ` Carlos O'Donell
     [not found]               ` <81d8e14e-e110-4b96-5d45-8bb3b56f4866-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-10 12:10                 ` Leonard den Ottolander
2017-03-14  0:51                   ` Carlos O'Donell
     [not found]                     ` <b736f01f-ef0a-56de-bf57-c6d3d74262a4-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-17 13:12                       ` Leonard den Ottolander
2017-03-09 23:10             ` Joseph Myers
     [not found]               ` <alpine.DEB.2.20.1703092304110.23273-9YEB1lltEqivcGRMvF24k2I39yigxGEX@public.gmane.org>
2017-03-10  0:01                 ` Carlos O'Donell
2017-03-08 18:48     ` Leonard den Ottolander
  -- strict thread matches above, loose matches on Subject: below --
2017-03-06 15:29 Leonard den Ottolander

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=2222c69b-cee9-dfc9-242f-344eeeaa13f5@redhat.com \
    --to=carlos-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=leonard-lists-2Avth2y2NeLyQNdsBcn8aGZHpeb/A1Y/@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.