linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ramon de C Valle <rcvalle@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] New PT_GNU_COMPAT segment header extension
Date: Wed, 1 Feb 2012 14:13:11 -0800	[thread overview]
Message-ID: <20120201141311.05b873ab.akpm@linux-foundation.org> (raw)
In-Reply-To: <f298f914-2239-44e4-8aa1-a51282e7fac0@zmail15.collab.prod.int.phx2.redhat.com>

On Mon, 09 Jan 2012 06:54:19 -0500 (EST)
Ramon de C Valle <rcvalle@redhat.com> wrote:

> Hi,
> 
> These patches introduces the PT_GNU_COMPAT segment header to indicate the
> kernel whether an ELF binary or a shared library needs to have all readable
> virtual memory mappings also executable (i.e. READ_IMPLIES_EXEC personality)
> and if necessary, it allows more compatibility modes to be implemented in
> the future.
> 
> Currently, an binary that needs only executable stack have unnecessarily all
> readable virtual memory mappings also executable. This is because the kernel
> does not know if the PF_X flag set in the PT_GNU_STACK segment header of the
> binary indicates it needs only stack executable or all readable virtual
> memory mappings also executable. Consequently, the kernel sets the
> READ_IMPLIES_EXEC personality upon loading any binary with the PT_GNU_STACK
> segment header and the PF_X flag set.
> 
> Furthermore, if the PT_GNU_STACK segment header with the PT_X flag is set in
> any of the shared libraries a binary is linked, the kernel does not know if
> the PF_X flag set in the PT_GNU_STACK segment header of the shared library
> indicates it needs only stack executable or all readable virtual memory
> mappings also executable either. Consequently, GCC sets the PT_GNU_STACK
> segment header with the PF_X flag set upon compiling any binary linked to a
> shared library with the PT_GNU_STACK segment header and the PF_X flag set.
> 
> This can result in applications unnoticeably having not only the stack, but
> also all readable virtual memory mappings also executable. These patches
> returns the original meaning and purpose of the PT_GNU_STACK segment header.
> 
> >From the security standpoint, these binaries will rely upon lesser security
> extensions, such as heap consistency checking and others. Thus, improving
> the security of binaries that needs only the stack executable.
> 
> These patches does not affect the current binaries that have the
> PT_GNU_STACK segment header, neither legacy binaries that most likely does
> not have this segment header either. For the existing binaries that
> necessarily need to have all readable virtual memory mappings also
> executable, the PT_GNU_STACK segment header can be easily converted to a
> PT_GNU_COMPAT segment header without recompilation.
> 
> The following are important details about the changes made to the linker:
> 
>  * The PT_GNU_STACK and PT_GNU_COMPAT segment headers are mutually
>    exclusive.
>  * The PT_GNU_STACK segment header has precedence over the PT_GNU_COMPAT
>    segment header.
>  * The PT_GNU_COMPAT segment header IS NOT created by default.
>  * The PT_GNU_STACK segment header IS ALWAYS created by default--which is
>    the original behaviour of the linker.
> 
> These patches are completely non-intrusive. Over the time, once this
> compatibility mode is no longer needed, they can be removed with no
> subsequent effect.
> 

<I have been poked>

I saw the patch but it's one of those ones which looks tricky/risky,
and is in an area with which I'm not sufficiently familiar.  I used to
ask Roland McGrath to help out with this sort of thing, but he
dematerialised a while back.  Perhaps Linus can give it some thought? 
I'd suggest a resend: you've added useful info in later emails so there
would be benefit to bringing it all together in one place.

A couple of minor things:

- The patch will need a Signed-off-by:, as described in
  Documentation/SubmittingPatches.

- The term "compat" has a well-understood meaning in the kernel: it
  refers to the support of 32-bit executables under 64-bit kernels. 
  Adding an unrelated PT_GNU_COMPAT muddies this.  Can you think up a
  different term?



  reply	other threads:[~2012-02-01 22:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ae010933-d93f-4858-97c7-d5aeb3dd73bc@zmail15.collab.prod.int.phx2.redhat.com>
2012-01-09 11:54 ` [PATCH] New PT_GNU_COMPAT segment header extension Ramon de C Valle
2012-02-01 22:13   ` Andrew Morton [this message]
2012-02-06 12:08     ` Ramon de C Valle
     [not found] <90c73bcf-9c80-47c2-a0de-89bc066013d1@zmail15.collab.prod.int.phx2.redhat.com>
2012-01-13 13:56 ` Ramon de C Valle
2012-01-13 15:33   ` Ramon de C Valle
2012-01-13 16:03     ` Ramon de C Valle

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=20120201141311.05b873ab.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcvalle@redhat.com \
    --cc=torvalds@linux-foundation.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 NNTP newsgroup(s).