aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-10-09 23:40:09 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-10-28 10:26:01 +0100
commit32ad5b3328e0ce53ca27e185a89ca44c1d0acd0c (patch)
tree6987a11aa93afba1de0aed2cb70d8bb7a201bf3f /sysdeps
parent2d0d1d38761cd9aeb7063c5cce1993cec909f67f (diff)
downloadglibc-32ad5b3328e0ce53ca27e185a89ca44c1d0acd0c.zip
glibc-32ad5b3328e0ce53ca27e185a89ca44c1d0acd0c.tar.gz
glibc-32ad5b3328e0ce53ca27e185a89ca44c1d0acd0c.tar.bz2
hurd: Fix race between calling RPC and handling a signal
* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make _hurd_intr_rpc_msg_about_to global point to start of controlled assembly snippet. Make it check canceled flag again. * hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed the _hurd_intr_rpc_msg_about_to point. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation issue.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/i386/intr-msg.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h
index 64f05f8..baa9ba9 100644
--- a/sysdeps/mach/hurd/i386/intr-msg.h
+++ b/sysdeps/mach/hurd/i386/intr-msg.h
@@ -20,21 +20,29 @@
/* Note that we must mark OPTION and TIMEOUT as outputs of this operation,
to indicate that the signal thread might mutate them as part
of sending us to a signal handler. */
-#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
+
+/* After _hurd_intr_rpc_msg_about_to we need to make a last check of cancel, in
+ case we got interrupted right before _hurd_intr_rpc_msg_about_to. */
+#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify, cancel_p) \
({ \
error_t err; \
- asm (".globl _hurd_intr_rpc_msg_do_trap\n" \
- ".globl _hurd_intr_rpc_msg_in_trap\n" \
+ asm (".globl _hurd_intr_rpc_msg_about_to\n" \
".globl _hurd_intr_rpc_msg_cx_sp\n" \
+ ".globl _hurd_intr_rpc_msg_do_trap\n" \
+ ".globl _hurd_intr_rpc_msg_in_trap\n" \
".globl _hurd_intr_rpc_msg_sp_restored\n" \
- " movl %%esp, %%ecx\n" \
+ "_hurd_intr_rpc_msg_about_to: cmpl $0, %4\n" \
+ " jz _hurd_intr_rpc_msg_do\n" \
+ " movl %5, %%eax\n" \
+ " jmp _hurd_intr_rpc_msg_sp_restored\n" \
+ "_hurd_intr_rpc_msg_do: movl %%esp, %%ecx\n" \
" leal %3, %%esp\n" \
"_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \
"_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \
"_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \
"_hurd_intr_rpc_msg_sp_restored:" \
: "=a" (err), "+m" (option), "+m" (timeout) \
- : "m" ((&msg)[-1]) \
+ : "m" ((&msg)[-1]), "m" (*cancel_p), "i" (EINTR) \
: "ecx"); \
err; \
})