All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: kernel-hardening@lists.openwall.com
Subject: Re: [kernel-hardening] [RFC] x86, mm: start mmap allocation for libs from low addresses
Date: Sun, 4 Sep 2011 11:21:31 +0400	[thread overview]
Message-ID: <20110904072131.GA3307@albatros> (raw)
In-Reply-To: <20110903121205.GB2743@albatros>

On Sat, Sep 03, 2011 at 16:12 +0400, Vasiliy Kulikov wrote:
> > > +		/* We don't want to reduce brk area of not DYNAMIC elf binaries
> > > +		 * with sysctl kernel.randomize_va_space < 2. */
> > > +		if (mm->brk && addr > mm->brk)
> > > +			goto failed;
> > 
> > Does this check come from RHEL?
> 
> Partly, see below.
> 
> 
> >  I don't fully understand it.  We also
> > check for "vma->vm_end >= ASCII_ARMOR_MAX_ADDR" below.  Does this imply
> > that we choose to handle the case of mm->brk being lower than
> > ASCII_ARMOR_MAX_ADDR here?  Is it a practically relevant case?
> 
> It's possible to have a weird case: PIE is disabled, exec image is lower
> than 0x01000000, kernel.randomize_va_space=0.  It means brk area starts
> in ASCII-armor zone.  If we try to jump over brk, then next brk growth
> would fail as we've loaded some library just after the last brk page.
> 
> (Also it would touch brk guard pages, which I didn't investigate.)
> 
> 
> >  Or was
> > this check possibly less redundant on RHEL?
> 

Sorry, I was precluded and have mixed things.  This should be read as:

> At first, RHEL tries to allocate a region without brk check:
> 
> 		addr = !should_randomize() ? SHLIB_BASE :
> 			randomize_range(SHLIB_BASE, 0x01000000, len);
> 
> 
> Then if it fails, exec-shield tries to find a region in a cycle, without
> the brk check.

s/without/with/

			/*
			 * Must not let a PROT_EXEC mapping get into the
			 * brk area:
			 */
			if (addr + len > mm->brk)
				goto failed;

>  Then if it overruns 0x01000000, it starts to do brk
> check:
> 
> 			if (addr >= 0x01000000 && should_randomize()) {
> 				tmp = randomize_range(0x01000000,
> 					PAGE_ALIGN(max(mm->start_brk,
> 					(unsigned long)0x08000000)), len);
> 
> So, they don't care about this rare case.

They care, but it is inconsistent - sometimes they check it, sometimes
not.  If the first guess failed - they do, otherwise don't.


> I heard many times about legacy randomize_va_space=0 systems, which
> disable brk randomization because of some ancient proprietary software.
> Non-PIE binaries are very often nowadays.  I didn't see these 3 cases at
> once (non-PIE, low mmap exec base, no brk randomization), but I don't
> see why it's impossible.  If you know why it is, I'll remove the check.

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

  parent reply	other threads:[~2011-09-04  7:21 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12 10:29 [RFC] x86, mm: start mmap allocation for libs from low addresses Vasiliy Kulikov
2011-08-12 10:29 ` [kernel-hardening] " Vasiliy Kulikov
2011-08-12 10:29 ` Vasiliy Kulikov
2011-08-12 10:58 ` [kernel-hardening] " Solar Designer
2011-08-12 11:05   ` Vasiliy Kulikov
2011-08-25 17:19   ` Vasiliy Kulikov
2011-08-25 17:39     ` Solar Designer
2011-09-02 18:29     ` Solar Designer
2011-09-03 11:18       ` Vasiliy Kulikov
2011-09-03 23:57         ` Solar Designer
2011-09-05 12:46           ` Vasiliy Kulikov
2011-09-06  5:05             ` Solar Designer
2011-09-07  9:09               ` Vasiliy Kulikov
2011-09-07  9:30                 ` Solar Designer
2011-09-07  9:34                   ` Vasiliy Kulikov
2011-09-07  9:43                     ` Solar Designer
2011-09-07  9:55                       ` Vasiliy Kulikov
2011-09-07 10:16                         ` Solar Designer
2011-09-07 11:01                           ` Vasiliy Kulikov
2011-09-02 23:34     ` Solar Designer
2011-09-03 12:12       ` Vasiliy Kulikov
2011-09-03 23:40         ` Solar Designer
2011-09-04  7:21         ` Vasiliy Kulikov [this message]
2011-08-12 23:19 ` H. Peter Anvin
2011-08-12 23:19   ` [kernel-hardening] " H. Peter Anvin
2011-08-12 23:19   ` H. Peter Anvin
2011-08-13  6:26   ` Vasiliy Kulikov
2011-08-13  6:26     ` [kernel-hardening] " Vasiliy Kulikov
2011-08-13  6:26     ` Vasiliy Kulikov
2011-08-16  9:05   ` Vasiliy Kulikov
2011-08-16  9:05     ` [kernel-hardening] " Vasiliy Kulikov
2011-08-16  9:05     ` Vasiliy Kulikov
2011-08-22 10:17     ` Vasiliy Kulikov
2011-08-22 10:17       ` [kernel-hardening] " Vasiliy Kulikov
2011-08-22 10:17       ` Vasiliy Kulikov
2011-08-22 17:24       ` H. Peter Anvin
2011-08-22 17:24         ` [kernel-hardening] " H. Peter Anvin
2011-08-22 17:24         ` H. Peter Anvin
2011-08-22 20:14         ` Vasiliy Kulikov
2011-08-22 20:14           ` [kernel-hardening] " Vasiliy Kulikov
2011-08-22 20:14           ` Vasiliy Kulikov
2011-08-22 20:17           ` H. Peter Anvin
2011-08-22 20:17             ` [kernel-hardening] " H. Peter Anvin
2011-08-22 20:17             ` H. Peter Anvin
2011-08-23  6:41             ` Vasiliy Kulikov
2011-08-23  6:41               ` [kernel-hardening] " Vasiliy Kulikov
2011-08-23  6:41               ` Vasiliy Kulikov

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=20110904072131.GA3307@albatros \
    --to=segoon@openwall.com \
    --cc=kernel-hardening@lists.openwall.com \
    /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.