linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.21.1] i386: save registers before intra-privilege syscall
@ 2007-05-17 22:06 Philipp Kohlbecher
  2007-05-17 22:16 ` H. Peter Anvin
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Kohlbecher @ 2007-05-17 22:06 UTC (permalink / raw
  To: Dave Jones, H. Peter Anvin; +Cc: Arnd Bergmann, linux-kernel, linux-assembly

From: Philipp Kohlbecher <pk031698@uni-greifswald.de>

The kernel_execve function issues a software interrupt (int 0x80) to make
a system call to sys_execve. This function expects to find the stack segment
and stack pointer of the function that issued the system call in the pt_regs
struct. The syscall entry code that sets up this struct expects the stack
segment and the stack pointer of the issuing function already on the stack.
But the Intel processor saves these registers only if a stack-switch occurs,
i.e. for inter-privilege interrupts and exceptions (cf. Intel Software
Developer’s Manual, Vol. 3A, p. 5-17,
http://www.intel.com/design/processor/manuals/253668.pdf).
For an intra-privilege interrupt like the one issued in kernel_execve, these
registers must be saved manually.

Signed-off-by: Philipp Kohlbecher <pk031698@uni-greifswald.de>

---

I am a total newbie and this is my first patch, so please be merciful...
Also, please CC me, I am not on the list.

--- a/arch/i386/kernel/sys_i386.c	2007-05-13 18:40:33.000000000 +0200
+++ b/arch/i386/kernel/sys_i386.c	2007-05-13 17:23:10.000000000 +0200
@@ -258,7 +258,8 @@ int kernel_execve(const char *filename,
 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
 {
 	long __res;
-	asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx"
+	asm volatile ("push %%ebx ; movl %2,%%ebx ; push %%ss ; push %%esp;"
+				"int $0x80 ; addl $(4*2),%%esp ; pop %%ebx"
 	: "=a" (__res)
 	: "0" (__NR_execve),"ri" (filename),"c" (argv), "d" (envp) : "memory");
 	return __res;
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2007-05-21 10:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-17 22:06 [PATCH 2.6.21.1] i386: save registers before intra-privilege syscall Philipp Kohlbecher
2007-05-17 22:16 ` H. Peter Anvin
2007-05-17 23:27   ` Philipp Kohlbecher
2007-05-17 23:33     ` H. Peter Anvin
2007-05-18  8:32       ` Philipp Kohlbecher
2007-05-18 22:41         ` H. Peter Anvin
2007-05-18 23:08           ` H. Peter Anvin
2007-05-21 10:48           ` Philipp Kohlbecher

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 read-only IMAP folder(s) and NNTP newsgroup(s).