mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 1/1] compat_alloc_user
@ 2007-06-29  0:17 Davide Libenzi
  0 siblings, 0 replies; only message in thread
From: Davide Libenzi @ 2007-06-29  0:17 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton, Linus Torvalds

I noticed that is not possible ATM to allocate two or more blocks
of userspace memory. Would a compat_alloc_user() like the one below
make sense (patch untested)?



Signed-off-by: Davide Libenzi <davidel@xmailserver.org>


- Davide



---
 include/asm-ia64/compat.h    |    8 ++++++++
 include/asm-mips/compat.h    |    8 ++++++++
 include/asm-parisc/compat.h  |    8 ++++++++
 include/asm-powerpc/compat.h |    8 ++++++++
 include/asm-s390/compat.h    |    8 ++++++++
 include/asm-sparc64/compat.h |    8 ++++++++
 include/asm-x86_64/compat.h  |    8 ++++++++
 7 files changed, 56 insertions(+)

Index: linux-2.6.mod/include/asm-x86_64/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-x86_64/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-x86_64/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -202,6 +202,14 @@
 	return (void __user *)regs->rsp - len; 
 }
 
+static __inline__ void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0x7UL);
+	return *prev;
+}
+
 static inline int is_compat_task(void)
 {
 	return current_thread_info()->status & TS_COMPAT;
Index: linux-2.6.mod/include/asm-sparc64/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-sparc64/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-sparc64/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -180,6 +180,14 @@
 	return (void __user *) usp;
 }
 
+static inline void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0x7UL);
+	return *prev;
+}
+
 struct compat_ipc64_perm {
 	compat_key_t key;
 	__compat_uid32_t uid;
Index: linux-2.6.mod/include/asm-s390/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-s390/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-s390/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -171,6 +171,14 @@
 	return (void __user *) (stack - len);
 }
 
+static inline void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0x7UL);
+	return *prev;
+}
+
 struct compat_ipc64_perm {
 	compat_key_t key;
 	__compat_uid32_t uid;
Index: linux-2.6.mod/include/asm-powerpc/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-powerpc/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-powerpc/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -146,6 +146,14 @@
 	return (void __user *) (usp - len);
 }
 
+static inline void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0x7UL);
+	return *prev;
+}
+
 /*
  * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
  * it we may as well define it.
Index: linux-2.6.mod/include/asm-parisc/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-parisc/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-parisc/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -150,6 +150,14 @@
 	return (void __user *)regs->gr[30];
 }
 
+static __inline__ void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? : compat_alloc_user_space(len);
+	*prev = data + ((len + 0x7UL) & ~0x7UL);
+	return data;
+}
+
 static inline int __is_compat_task(struct task_struct *t)
 {
 	return test_ti_thread_flag(task_thread_info(t), TIF_32BIT);
Index: linux-2.6.mod/include/asm-mips/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-mips/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-mips/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -148,6 +148,14 @@
 	return (void __user *) (regs->regs[29] - len);
 }
 
+static inline void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0x7UL);
+	return *prev;
+}
+
 struct compat_ipc64_perm {
 	compat_key_t key;
 	__compat_uid32_t uid;
Index: linux-2.6.mod/include/asm-ia64/compat.h
===================================================================
--- linux-2.6.mod.orig/include/asm-ia64/compat.h	2007-06-13 17:48:27.000000000 -0700
+++ linux-2.6.mod/include/asm-ia64/compat.h	2007-06-13 17:48:32.000000000 -0700
@@ -202,4 +202,12 @@
 	return (void __user *) (((regs->r12 & 0xffffffff) & -16) - len);
 }
 
+static __inline__ void __user *compat_alloc_user(void __user **prev, long len)
+{
+	void __user *data;
+	data = *prev ? (*prev - len): compat_alloc_user_space(len);
+	*prev = (void __user *) ((unsigned long) data & ~0xfUL;
+	return *prev;
+}
+
 #endif /* _ASM_IA64_COMPAT_H */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-29  0:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-29  0:17 [patch 1/1] compat_alloc_user Davide Libenzi

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®