mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 1/1] personality handling: fix PER_CLEAR_ON_SETID for security  reasons
@ 2009-06-26 18:27 Julien Tinnes
  2009-06-28 20:40 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Tinnes @ 2009-06-26 18:27 UTC (permalink / raw)
  To: hch; +Cc: security, taviso, linux-kernel

Hello,

We have found that the current PER_CLEAR_ON_SETID mask on Linux
doesn't include neither ADDR_COMPAT_LAYOUT, nor MMAP_PAGE_ZERO.

The current mask is READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE.

We believe it is important to add MMAP_PAGE_ZERO, because by using
this personality it is possible to have the first page mapped inside a
process running as setuid root. This could be used in those scenarios:

- Exploiting a NULL pointer dereference issue in a setuid root binary
- Bypassing the mmap_min_addr restrictions of the Linux kernel: by
running a setuid binary that would drop privileges before giving us
control back (for instance by loading a user-supplied library), we
could get the first page mapped in a process we control. By further
using mremap and mprotect on this mapping, we can then completely
bypass the mmap_min_addr restrictions.

Less importantly, we believe ADDR_COMPAT_LAYOUT should also be added
since on x86 32bits it will in practice disable most of the address
space layout randomization (only the stack will remain randomized).

Signed-off-by: Julien Tinnes <jt@cr0.org> and Tavis Ormandy
<taviso@sdf.lonestar.org>

---


diff -r f70f443c9ead include/linux/personality.h
--- a/include/linux/personality.h	Fri Jun 26 19:59:33 2009 +0200
+++ b/include/linux/personality.h	Fri Jun 26 20:00:40 2009 +0200
@@ -40,7 +40,7 @@ enum {
  * Security-relevant compatibility flags that must be
  * cleared upon setuid or setgid exec:
  */
-#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
+#define PER_CLEAR_ON_SETID
(READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE|ADDR_COMPAT_LAYOUT|MMAP_PAGE_ZERO)

 /*
  * Personality types.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch 1/1] personality handling: fix PER_CLEAR_ON_SETID for security reasons
  2009-06-26 18:27 [patch 1/1] personality handling: fix PER_CLEAR_ON_SETID for security reasons Julien Tinnes
@ 2009-06-28 20:40 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2009-06-28 20:40 UTC (permalink / raw)
  To: Julien Tinnes; +Cc: hch, security, taviso, linux-kernel

On Fri, Jun 26, 2009 at 08:27:40PM +0200, Julien Tinnes wrote:
> Hello,
> 
> We have found that the current PER_CLEAR_ON_SETID mask on Linux
> doesn't include neither ADDR_COMPAT_LAYOUT, nor MMAP_PAGE_ZERO.
> 
> The current mask is READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE.
> 
> We believe it is important to add MMAP_PAGE_ZERO, because by using
> this personality it is possible to have the first page mapped inside a
> process running as setuid root. This could be used in those scenarios:

I agree.

> Less importantly, we believe ADDR_COMPAT_LAYOUT should also be added
> since on x86 32bits it will in practice disable most of the address
> space layout randomization (only the stack will remain randomized).

Agree on this on, too.

> -#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
> +#define PER_CLEAR_ON_SETID
> (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE|ADDR_COMPAT_LAYOUT|MMAP_PAGE_ZERO)

#define PER_CLEAR_ON_SETID \
	(READ_IMPLIES_EXEC | \
	 ADDR_NO_RANDOMIZE | \
	 ADDR_COMPAT_LAYOUT | \
	 MMAP_PAGE_ZERO)

to make it a little more readable (and work around your mailer
corrupting long lines :))

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-28 20:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26 18:27 [patch 1/1] personality handling: fix PER_CLEAR_ON_SETID for security reasons Julien Tinnes
2009-06-28 20:40 ` Christoph Hellwig

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®