public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Samuel Thibault <sthibaul@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] hurd: Fix using altstack while in an RPC call to be aborted
Date: Tue, 10 Dec 2019 23:33:00 -0000	[thread overview]
Message-ID: <20191210233354.36894.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e46efff89550a8e693a3362976f85070762c5cb8

commit e46efff89550a8e693a3362976f85070762c5cb8
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Dec 11 00:23:00 2019 +0100

    hurd: Fix using altstack while in an RPC call to be aborted
    
    * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Always check
    for interrupted code being with esp pointing at mach_msg arguments, even
    when using an altstack. If we need to abort the RPC we will need
    this.

Diff:
---
 sysdeps/mach/hurd/i386/trampoline.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
index a6928a6..0c5d5a1 100644
--- a/sysdeps/mach/hurd/i386/trampoline.c
+++ b/sysdeps/mach/hurd/i386/trampoline.c
@@ -74,12 +74,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
      interrupted RPC frame.  */
   state->basic.esp = state->basic.uesp;
 
-  if ((ss->actions[signo].sa_flags & SA_ONSTACK)
-      && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
-    {
-      sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
-      ss->sigaltstack.ss_flags |= SS_ONSTACK;
-    }
   /* This code has intimate knowledge of the special mach_msg system call
      done in intr-msg.c; that code does (see intr-msg.h):
 					movl %esp, %ecx
@@ -91,13 +85,20 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
      We must check for the window during which %esp points at the
      mach_msg arguments.  The space below until %ecx is used by
      the _hurd_intr_rpc_mach_msg frame, and must not be clobbered.  */
-  else if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp
-	   && state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored)
-    /* The SP now points at the mach_msg args, but there is more stack
-       space used below it.  The real SP is saved in %ecx; we must push the
-       new frame below there, and restore that value as the SP on
-       sigreturn.  */
-    sigsp = (char *) (state->basic.uesp = state->basic.ecx);
+  if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp
+      && state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored)
+  /* The SP now points at the mach_msg args, but there is more stack
+     space used below it.  The real SP is saved in %ecx; we must push the
+     new frame below there (if not on the altstack), and restore that value as
+     the SP on sigreturn.  */
+    state->basic.uesp = state->basic.ecx;
+
+  if ((ss->actions[signo].sa_flags & SA_ONSTACK)
+      && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
+    {
+      sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+      ss->sigaltstack.ss_flags |= SS_ONSTACK;
+    }
   else
     sigsp = (char *) state->basic.uesp;


                 reply	other threads:[~2019-12-10 23:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191210233354.36894.qmail@sourceware.org \
    --to=sthibaul@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).