public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Set TIF_IRET in more places
@ 2003-01-06 21:34 Zack Weinberg
  2003-01-07 11:19 ` Jamie Lokier
  0 siblings, 1 reply; 15+ messages in thread
From: Zack Weinberg @ 2003-01-06 21:34 UTC (permalink / raw)
  To: linux-kernel


Linus Torvalds wrote:

> - note that for normal asynchronous signals, it _is_ important that
>   we return with all registers saved, but right now that is handled
>   by the fact that the signal trampoline we build in do_signal()
>   will always use "int 0x80" for the sys_sigreturn() call, and will
>   thus use "iret" when restoring the registers. The synchronous
>   "[rt_]sigsuspend()" really is a special case in that respect.

Consider SA_RESTORER - there isn't a guarantee that user space will
use the same code as the kernel's trampoline.  glibc happens to, but
only because GDB has a hardwired idea of what a signal trampoline
looks like.  Of course, you could simply document that sigreturn() is
another of the system calls that must be made through int 0x80.

It occurs to me that the kernel-provided signal trampoline could go in
the page at 0xffff0000, instead of on the user stack, which would
eliminate the need for glibc to set SA_RESTORER (it's a pure
optimization).

Tangentially, I've seen people claim that the trampoline ought to be
able to avoid entering the kernel, although I'm not convinced (how
does the signal mask get reset, otherwise?)

zw

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH] Set TIF_IRET in more places
@ 2003-01-06 14:46 Luca Barbieri
  2003-01-06 16:04 ` Linus Torvalds
  0 siblings, 1 reply; 15+ messages in thread
From: Luca Barbieri @ 2003-01-06 14:46 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux-Kernel ML

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

This patch adds code to set TIF_IRET in sigsuspend and rt_sigsuspend
(since they change registers to invoke signal handlers) and ptrace
setregs.  This prevents clobbering of %ecx and %edx.


diff --exclude-from=/home/ldb/src/exclude -urNdp --exclude='speedtouch.*' --exclude='atmsar.*' linux-2.5.54/arch/i386/kernel/ptrace.c linux-2.5.54-ldb/arch/i386/kernel/ptrace.c
--- linux-2.5.54/arch/i386/kernel/ptrace.c	2003-01-02 04:21:29.000000000 +0100
+++ linux-2.5.54-ldb/arch/i386/kernel/ptrace.c	2003-01-04 19:06:07.000000000 +0100
@@ -74,6 +74,8 @@ static inline int put_stack_long(struct 
 static int putreg(struct task_struct *child,
 	unsigned long regno, unsigned long value)
 {
+	set_tsk_thread_flag(child, TIF_IRET);
+
 	switch (regno >> 2) {
 		case FS:
 			if (value && (value & 3) != 3)
diff --exclude-from=/home/ldb/src/exclude -urNdp --exclude='speedtouch.*' --exclude='atmsar.*' linux-2.5.54/arch/i386/kernel/signal.c linux-2.5.54-ldb/arch/i386/kernel/signal.c
--- linux-2.5.54/arch/i386/kernel/signal.c	2003-01-02 04:21:53.000000000 +0100
+++ linux-2.5.54-ldb/arch/i386/kernel/signal.c	2003-01-04 19:06:07.000000000 +0100
@@ -44,6 +44,7 @@ sys_sigsuspend(int history0, int history
 	spin_unlock_irq(&current->sig->siglock);
 
 	regs->eax = -EINTR;
+	set_thread_flag(TIF_IRET);
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
@@ -73,6 +74,7 @@ sys_rt_sigsuspend(sigset_t *unewset, siz
 	spin_unlock_irq(&current->sig->siglock);
 
 	regs->eax = -EINTR;
+	set_thread_flag(TIF_IRET);	
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();

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

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

end of thread, other threads:[~2003-01-09  6:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-06 21:34 [PATCH] Set TIF_IRET in more places Zack Weinberg
2003-01-07 11:19 ` Jamie Lokier
2003-01-07 17:42   ` Linus Torvalds
2003-01-07 19:27   ` Zack Weinberg
2003-01-08  1:21     ` Richard Henderson
2003-01-08  2:33       ` Linus Torvalds
2003-01-08  3:32         ` Daniel Jacobowitz
2003-01-08 16:29       ` Jamie Lokier
2003-01-09  6:49         ` Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
2003-01-06 14:46 Luca Barbieri
2003-01-06 16:04 ` Linus Torvalds
2003-01-06 18:17   ` Luca Barbieri
2003-01-06 18:42     ` Ulrich Drepper
2003-01-06 18:49     ` Linus Torvalds
2003-01-06 20:26       ` Luca Barbieri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox