linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] Keep 3 high personality bytes across exec
@ 2008-06-18  6:06 Eric B Munson
  2008-06-18  6:12 ` Paul Mackerras
  2008-06-18 21:15 ` [RFC PATCH V2] " Eric B Munson
  0 siblings, 2 replies; 3+ messages in thread
From: Eric B Munson @ 2008-06-18  6:06 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]

Currently when a 32 bit process is exec'd on a powerpc 64 bit host the values
of the top three bytes of the personality are clobbered.  This patch adds a
check in the SET_PERSONALITY macro that will carry all the values in the top
three bytes across the exec.

Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>

---

Based on 2.6.26-rc6

 include/asm-powerpc/elf.h   |    3 ++-
 include/linux/personality.h |    6 ++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index 9080d85..2f11a0e 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -257,7 +257,8 @@ do {								\
 	else							\
 		clear_thread_flag(TIF_ABI_PENDING);		\
 	if (personality(current->personality) != PER_LINUX32)	\
-		set_personality(PER_LINUX);			\
+		set_personality(PER_LINUX |			\
+			(current->personality & PER_INHERIT));	\
 } while (0)
 /*
  * An executable for which elf_read_implies_exec() returns TRUE will
diff --git a/include/linux/personality.h b/include/linux/personality.h
index a84e9ff..362eb90 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -36,6 +36,12 @@ enum {
 	ADDR_LIMIT_3GB = 	0x8000000,
 };
 
+/* Mask for the above personality values */
+#define PER_INHERIT (ADDR_NO_RANDOMIZE|FDPIC_FUNCPTRS|MMAP_PAGE_ZERO| \
+			ADDR_COMPAT_LAYOUT|READ_IMPLIES_EXEC|ADDR_LIMIT_32BIT| \
+			SHORT_INODE|WHOLE_SECONDS|STICKY_TIMEOUTS| \
+			ADDR_LIMIT_3GB)
+
 /*
  * Security-relevant compatibility flags that must be
  * cleared upon setuid or setgid exec:


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [RFC PATCH] Keep 3 high personality bytes across exec
  2008-06-18  6:06 [RFC PATCH] Keep 3 high personality bytes across exec Eric B Munson
@ 2008-06-18  6:12 ` Paul Mackerras
  2008-06-18 21:15 ` [RFC PATCH V2] " Eric B Munson
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Mackerras @ 2008-06-18  6:12 UTC (permalink / raw)
  To: Eric B Munson; +Cc: linuxppc-dev, linux-kernel

Eric B Munson writes:

> Currently when a 32 bit process is exec'd on a powerpc 64 bit host the values
> of the top three bytes of the personality are clobbered.  This patch adds a
> check in the SET_PERSONALITY macro that will carry all the values in the top
> three bytes across the exec.
> 
> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>

Your commit message needs to remind us what is in those bytes, and
tell us what bad things happen if we don't keep them, and what is the
benefit of keeping them.  And if there are any user-visible aspects of
this change, they need to be flagged.

Paul.

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

* [RFC PATCH V2] Keep 3 high personality bytes across exec
  2008-06-18  6:06 [RFC PATCH] Keep 3 high personality bytes across exec Eric B Munson
  2008-06-18  6:12 ` Paul Mackerras
@ 2008-06-18 21:15 ` Eric B Munson
  1 sibling, 0 replies; 3+ messages in thread
From: Eric B Munson @ 2008-06-18 21:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2491 bytes --]

Currently when a 32 bit process is exec'd on a powerpc 64 bit host the value
in the top three bytes of the personality is clobbered.  This patch adds a
check in the SET_PERSONALITY macro that will carry all the values in the top
three bytes across the exec.

These three bytes currently carry flags to disable address randomisation,
limit the address space, force zeroing of an mmapped page, etc.  Should an
application set any of these bits they will be maintained and honoured on
homogeneous environment but discarded and ignored on a heterogeneous
environment.  So if an application requires all mmapped pages to be initialised
to zero and a wrapper is used to setup the personality and exec the target,
these flags will remain set on an all 32 or all 64 bit envrionment, but they
will be lost in the exec on a mixed 32/64 bit environment.  Losing these bits
means that the same application would behave differently in different
environments.  Tested on a POWER5+ machine with 64bit kernel and a mixed
64/32 bit user space.

Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>

---
V2

Changes from V1:
Updated changelog with a better description of why this change is useful

Based on 2.6.26-rc6

 include/asm-powerpc/elf.h   |    3 ++-
 include/linux/personality.h |    6 ++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index 9080d85..2f11a0e 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -257,7 +257,8 @@ do {								\
 	else							\
 		clear_thread_flag(TIF_ABI_PENDING);		\
 	if (personality(current->personality) != PER_LINUX32)	\
-		set_personality(PER_LINUX);			\
+		set_personality(PER_LINUX |			\
+			(current->personality & PER_INHERIT));	\
 } while (0)
 /*
  * An executable for which elf_read_implies_exec() returns TRUE will
diff --git a/include/linux/personality.h b/include/linux/personality.h
index a84e9ff..362eb90 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -36,6 +36,12 @@ enum {
 	ADDR_LIMIT_3GB = 	0x8000000,
 };
 
+/* Mask for the above personality values */
+#define PER_INHERIT (ADDR_NO_RANDOMIZE|FDPIC_FUNCPTRS|MMAP_PAGE_ZERO| \
+			ADDR_COMPAT_LAYOUT|READ_IMPLIES_EXEC|ADDR_LIMIT_32BIT| \
+			SHORT_INODE|WHOLE_SECONDS|STICKY_TIMEOUTS| \
+			ADDR_LIMIT_3GB)
+
 /*
  * Security-relevant compatibility flags that must be
  * cleared upon setuid or setgid exec:


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2008-06-18 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-18  6:06 [RFC PATCH] Keep 3 high personality bytes across exec Eric B Munson
2008-06-18  6:12 ` Paul Mackerras
2008-06-18 21:15 ` [RFC PATCH V2] " Eric B Munson

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).