linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* increase AT_VECTOR_SIZE to terminate saved_auxv properly
@ 2007-09-14 11:00 Olaf Hering
  2007-09-15 14:01 ` Jakub Jelinek
  2007-09-18 11:55 ` [PATCH] " Olaf Hering
  0 siblings, 2 replies; 7+ messages in thread
From: Olaf Hering @ 2007-09-14 11:00 UTC (permalink / raw)
  To: linux-kernel

include/asm-powerpc/elf.h has 6 entries in ARCH_DLINFO.
fs/binfmt_elf.c has 14 unconditional NEW_AUX_ENT entries and 2
conditional NEW_AUX_ENT entries.
So in the worst case, saved_auxv does not get an AT_NULL entry at the
end.

Is an AT_NULL entry required or must userspace use the AT_VECTOR_SIZE
to not loop past the end of the array?
If AT_NULL is required, AT_VECTOR_SIZE should be changed from 44 to 46.


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

* Re: increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-14 11:00 increase AT_VECTOR_SIZE to terminate saved_auxv properly Olaf Hering
@ 2007-09-15 14:01 ` Jakub Jelinek
  2007-09-17  8:54   ` Olaf Hering
  2007-09-18 11:55 ` [PATCH] " Olaf Hering
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2007-09-15 14:01 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linux-kernel

On Fri, Sep 14, 2007 at 01:00:57PM +0200, Olaf Hering wrote:
> include/asm-powerpc/elf.h has 6 entries in ARCH_DLINFO.
> fs/binfmt_elf.c has 14 unconditional NEW_AUX_ENT entries and 2
> conditional NEW_AUX_ENT entries.
> So in the worst case, saved_auxv does not get an AT_NULL entry at the
> end.
> 
> Is an AT_NULL entry required or must userspace use the AT_VECTOR_SIZE
> to not loop past the end of the array?

Of course it is required, AT_VECTOR_SIZE is a kernel implementation detail.

> If AT_NULL is required, AT_VECTOR_SIZE should be changed from 44 to 46.

No, it should be computed instead from the number of target independent aux
vector pairs and then from an per-arch macro which says how many arch
specific aux vector pairs are needed.

	Jakub

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

* Re: increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-15 14:01 ` Jakub Jelinek
@ 2007-09-17  8:54   ` Olaf Hering
  0 siblings, 0 replies; 7+ messages in thread
From: Olaf Hering @ 2007-09-17  8:54 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: linux-kernel

On Sat, Sep 15, Jakub Jelinek wrote:

> > If AT_NULL is required, AT_VECTOR_SIZE should be changed from 44 to 46.
> 
> No, it should be computed instead from the number of target independent aux
> vector pairs and then from an per-arch macro which says how many arch
> specific aux vector pairs are needed.

How should I define the arch specific part? ARCH_DLINFO is in asm/elf.h.
I suspect that sched.h should not include elh.h.
What asm/xyz.h would be a good place for AT_VECTOR_SIZE_ARCH?
The attempt below does currently not compile.


include/asm-powerpc/elf.h has 6 entries in ARCH_DLINFO.
fs/binfmt_elf.c has 14 unconditional NEW_AUX_ENT entries and 2
conditional NEW_AUX_ENT entries.
So in the worst case, saved_auxv does not get an AT_NULL entry at the
end.

The saved_auxv array must be terminated with an AT_NULL entry.
Make the size of mm_struct->saved_auxv arch dependend,
based on the number of ARCH_DLINFO entries.

---
 include/asm-alpha/elf.h   |    1 +
 include/asm-i386/elf.h    |    1 +
 include/asm-ia64/elf.h    |    1 +
 include/asm-powerpc/elf.h |    1 +
 include/asm-sh/elf.h      |    1 +
 include/linux/auxvec.h    |    4 +++-
 include/linux/elf.h       |    5 +++++
 include/linux/sched.h     |    1 -
 8 files changed, 13 insertions(+), 2 deletions(-)

--- a/include/asm-alpha/elf.h
+++ b/include/asm-alpha/elf.h
@@ -155,6 +155,7 @@ extern int alpha_l1d_cacheshape;
 extern int alpha_l2_cacheshape;
 extern int alpha_l3_cacheshape;
 
+#define AT_VECTOR_SIZE_ARCH 4
 #define ARCH_DLINFO						\
   do {								\
     NEW_AUX_ENT(AT_L1I_CACHESHAPE, alpha_l1i_cacheshape);	\
--- a/include/asm-i386/elf.h
+++ b/include/asm-i386/elf.h
@@ -152,6 +152,7 @@ extern int arch_setup_additional_pages(s
 
 extern unsigned int vdso_enabled;
 
+#define AT_VECTOR_SIZE_ARCH 2
 #define ARCH_DLINFO							\
 do if (vdso_enabled) {							\
 		NEW_AUX_ENT(AT_SYSINFO,	VDSO_ENTRY);			\
--- a/include/asm-ia64/elf.h
+++ b/include/asm-ia64/elf.h
@@ -192,6 +192,7 @@ extern int dump_task_fpu (struct task_st
 
 #define GATE_EHDR	((const struct elfhdr *) GATE_ADDR)
 
+#define AT_VECTOR_SIZE_ARCH 2
 #define ARCH_DLINFO								\
 do {										\
 	extern char __kernel_syscall_via_epc[];					\
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -282,6 +282,7 @@ extern int arch_setup_additional_pages(s
  * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
  *   even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
  */
+#define AT_VECTOR_SIZE_ARCH 6
 #define ARCH_DLINFO							\
 do {									\
 	/* Handle glibc compatibility. */				\
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -133,6 +133,7 @@ extern void __kernel_vsyscall;
 #define VDSO_BASE		((unsigned long)current->mm->context.vdso)
 #define VDSO_SYM(x)		(VDSO_BASE + (unsigned long)(x))
 
+#define AT_VECTOR_SIZE_ARCH 1
 #define ARCH_DLINFO						\
 do {								\
 	if (vdso_enabled)					\
--- a/include/linux/auxvec.h
+++ b/include/linux/auxvec.h
@@ -26,6 +26,8 @@
 
 #define AT_SECURE 23   /* secure mode boolean */
 
-#define AT_VECTOR_SIZE  44 /* Size of auxiliary table.  */
+#ifdef __KERNEL__
+#define AT_VECTOR_SIZE_BASE  (14 + 2) /* generic entries in auxiliary table. */
+#endif
 
 #endif /* _LINUX_AUXVEC_H */
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -6,6 +6,11 @@
 #include <linux/elf-em.h>
 #include <asm/elf.h>
 
+#ifndef AT_VECTOR_SIZE_ARCH
+#define AT_VECTOR_SIZE_ARCH 0
+#endif
+#define AT_VECTOR_SIZE (AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)
+
 struct file;
 
 #ifndef elf_read_implies_exec
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1,7 +1,6 @@
 #ifndef _LINUX_SCHED_H
 #define _LINUX_SCHED_H
 
-#include <linux/auxvec.h>	/* For AT_VECTOR_SIZE */
 
 /*
  * cloning flags:

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

* [PATCH] increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-14 11:00 increase AT_VECTOR_SIZE to terminate saved_auxv properly Olaf Hering
  2007-09-15 14:01 ` Jakub Jelinek
@ 2007-09-18 11:55 ` Olaf Hering
  2007-09-20  6:44   ` Andrew Morton
  1 sibling, 1 reply; 7+ messages in thread
From: Olaf Hering @ 2007-09-18 11:55 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton


include/asm-powerpc/elf.h has 6 entries in ARCH_DLINFO.
fs/binfmt_elf.c has 14 unconditional NEW_AUX_ENT entries and 2
conditional NEW_AUX_ENT entries.
So in the worst case, saved_auxv does not get an AT_NULL entry at the
end.

The saved_auxv array must be terminated with an AT_NULL entry.
Make the size of mm_struct->saved_auxv arch dependend,
based on the number of ARCH_DLINFO entries.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

---
 include/asm-alpha/system.h   |    1 +
 include/asm-i386/system.h    |    1 +
 include/asm-ia64/system.h    |    2 ++
 include/asm-powerpc/system.h |    1 +
 include/asm-sh/system.h      |    1 +
 include/linux/auxvec.h       |    4 +++-
 include/linux/elf.h          |    1 -
 include/linux/sched.h        |    6 +++++-
 8 files changed, 14 insertions(+), 3 deletions(-)

--- a/include/asm-alpha/system.h
+++ b/include/asm-alpha/system.h
@@ -48,6 +48,7 @@
 
 #ifndef __ASSEMBLY__
 #include <linux/kernel.h>
+#define AT_VECTOR_SIZE_ARCH 4
 
 /*
  * This is the logout header that should be common to all platforms
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -7,6 +7,7 @@
 #include <asm/cmpxchg.h>
 
 #ifdef __KERNEL__
+#define AT_VECTOR_SIZE_ARCH 2
 
 struct task_struct;	/* one of the stranger aspects of C forward declarations.. */
 extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
--- a/include/asm-ia64/system.h
+++ b/include/asm-ia64/system.h
@@ -32,6 +32,8 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 
+#define AT_VECTOR_SIZE_ARCH 2
+
 struct pci_vector_struct {
 	__u16 segment;	/* PCI Segment number */
 	__u16 bus;	/* PCI Bus number */
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -40,6 +40,7 @@
 #define set_mb(var, value)	do { var = value; mb(); } while (0)
 
 #ifdef __KERNEL__
+#define AT_VECTOR_SIZE_ARCH 6
 #ifdef CONFIG_SMP
 #define smp_mb()	mb()
 #define smp_rmb()	rmb()
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -11,6 +11,7 @@
 #include <asm/types.h>
 #include <asm/ptrace.h>
 
+#define AT_VECTOR_SIZE_ARCH 1
 /*
  *	switch_to() should switch tasks to task nr n, first
  */
--- a/include/linux/auxvec.h
+++ b/include/linux/auxvec.h
@@ -26,6 +26,8 @@
 
 #define AT_SECURE 23   /* secure mode boolean */
 
-#define AT_VECTOR_SIZE  44 /* Size of auxiliary table.  */
+#ifdef __KERNEL__
+#define AT_VECTOR_SIZE_BASE  (14 + 2) /* generic entries in auxiliary table. */
+#endif
 
 #endif /* _LINUX_AUXVEC_H */
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -2,7 +2,6 @@
 #define _LINUX_ELF_H
 
 #include <linux/types.h>
-#include <linux/auxvec.h>
 #include <linux/elf-em.h>
 #include <asm/elf.h>
 
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1,7 +1,6 @@
 #ifndef _LINUX_SCHED_H
 #define _LINUX_SCHED_H
 
-#include <linux/auxvec.h>	/* For AT_VECTOR_SIZE */
 
 /*
  * cloning flags:
@@ -90,6 +89,11 @@ struct exec_domain;
 struct futex_pi_state;
 struct bio;
 
+#include <linux/auxvec.h>
+#ifndef AT_VECTOR_SIZE_ARCH
+#define AT_VECTOR_SIZE_ARCH 0
+#endif
+#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
 /*
  * List of flags we want to share for kernel threads,
  * if only because they are not used by them anyway.

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

* Re: [PATCH] increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-18 11:55 ` [PATCH] " Olaf Hering
@ 2007-09-20  6:44   ` Andrew Morton
  2007-09-20 19:19     ` Olaf Hering
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-09-20  6:44 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linux-kernel

On Tue, 18 Sep 2007 13:55:04 +0200 Olaf Hering <olaf@aepfle.de> wrote:

> include/asm-powerpc/elf.h has 6 entries in ARCH_DLINFO.
> fs/binfmt_elf.c has 14 unconditional NEW_AUX_ENT entries and 2
> conditional NEW_AUX_ENT entries.
> So in the worst case, saved_auxv does not get an AT_NULL entry at the
> end.
> 
> The saved_auxv array must be terminated with an AT_NULL entry.
> Make the size of mm_struct->saved_auxv arch dependend,
> based on the number of ARCH_DLINFO entries.

I'm not very confident that this will work well with the
already-queued move-mm_struct-and-vm_area_struct.patch.

It moves the saved_auxv[AT_VECTOR_SIZE] definition over into
mm_types.h and mm_types.h doesn't include sched.h.

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

* Re: [PATCH] increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-20  6:44   ` Andrew Morton
@ 2007-09-20 19:19     ` Olaf Hering
  2007-09-20 20:22       ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Olaf Hering @ 2007-09-20 19:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Wed, Sep 19, Andrew Morton wrote:

> I'm not very confident that this will work well with the
> already-queued move-mm_struct-and-vm_area_struct.patch.

You want me to redo my patch agains the current -mm kernel?

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

* Re: [PATCH] increase AT_VECTOR_SIZE to terminate saved_auxv properly
  2007-09-20 19:19     ` Olaf Hering
@ 2007-09-20 20:22       ` Andrew Morton
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2007-09-20 20:22 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linux-kernel

On Thu, 20 Sep 2007 21:19:44 +0200
Olaf Hering <olaf@aepfle.de> wrote:

> On Wed, Sep 19, Andrew Morton wrote:
> 
> > I'm not very confident that this will work well with the
> > already-queued move-mm_struct-and-vm_area_struct.patch.
> 
> You want me to redo my patch agains the current -mm kernel?

Would be appreciated, thanks.  If there are any problems then they'll
probably be build-time ones only, but they could be substantial ones -
refactoring our crappy header files always hurts.



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

end of thread, other threads:[~2007-09-20 20:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-14 11:00 increase AT_VECTOR_SIZE to terminate saved_auxv properly Olaf Hering
2007-09-15 14:01 ` Jakub Jelinek
2007-09-17  8:54   ` Olaf Hering
2007-09-18 11:55 ` [PATCH] " Olaf Hering
2007-09-20  6:44   ` Andrew Morton
2007-09-20 19:19     ` Olaf Hering
2007-09-20 20:22       ` Andrew Morton

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