[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
setcontext and signal mask on Linux/ia64
From: |
Peter A. Buhr |
Subject: |
setcontext and signal mask on Linux/ia64 |
Date: |
Thu, 1 May 2003 16:21:49 -0400 |
Our team has discovered two bugs in the implementation of setcontext
for Linux on the ia64.
Bug 1: setcontext does not install signal mask
The first section of the setcontext function inlines a call to the
rt_sigprocmask syscall. It only passes three arguments, however,
rt_sigprocmask expects a fourth argument, which must be sizeof(sigset_t). This
missing argument causes rt_sigprocmask to fail with EINVAL, but this error is
ignored by setcontext.
Bug 2: setcontext installs the wrong value as signal mask
The inlined call to rt_sigprocmask uses the hardcoded offset SC_MASK
(0x9d0) to get the signal mask for the new context from the input
struct sigcontext. But offsetof( struct sigcontext, sc_mask ) is
0xa50, so the value of sc_rbs_base (which happens to be at offset
0x9d0) is used instead.
The following patch fixes both problems.
diff -Nru glibc-2.3.2/sysdeps/unix/sysv/linux/ia64/setcontext.S
glibc-2.3.2-work/sysdeps/unix/sysv/linux/ia64/setcontext.S
- --- glibc-2.3.2/sysdeps/unix/sysv/linux/ia64/setcontext.S Sat Jul 7
15:21:34 2001
+++ glibc-2.3.2-work/sysdeps/unix/sysv/linux/ia64/setcontext.S Thu May 1
11:50:08 2003
@@ -32,7 +32,7 @@
other than the PRESERVED state. */
ENTRY(__setcontext)
- - alloc r16 = ar.pfs, 1, 0, 3, 0
+ alloc r16 = ar.pfs, 1, 0, 4, 0
// sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL):
@@ -42,6 +42,7 @@
mov out0 = SIG_SETMASK
add out1 = r2, in0
mov out2 = 0
+ mov out3 = 8 // sizeof( sigset_t )
invala
break __BREAK_SYSCALL
diff -Nru glibc-2.3.2/sysdeps/unix/sysv/linux/ia64/ucontext_i.h
glibc-2.3.2-work/sysdeps/unix/sysv/linux/ia64/ucontext_i.h
- --- glibc-2.3.2/sysdeps/unix/sysv/linux/ia64/ucontext_i.h Sat Jul 7
15:21:35 2001
+++ glibc-2.3.2-work/sysdeps/unix/sysv/linux/ia64/ucontext_i.h Thu May 1
13:02:51 2003
@@ -35,7 +35,7 @@
#define SC_BR 0x088
#define SC_GR 0x0c8
#define SC_FR 0x1d0
- -#define SC_MASK 0x9d0
+#define SC_MASK 0xa50
#define rTMP r16
------- End of forwarded message -------
- setcontext and signal mask on Linux/ia64,
Peter A. Buhr <=