From patchwork Tue Dec 10 23:34:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1207329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107937-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Wmz149ID"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Xbxh2l1bz9sPK for ; Wed, 11 Dec 2019 10:34:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=mke +rKSRRSYEqBgTW3uinlPzf3QAQWI+i8SSVToSjehzZ5e/V/IP4+N7cdmbKM0K+pb PN8sHllFlR1WMfvGrYIeOR2NLYd9Dd1TE0n84uCMYFo9etmm0qANKEQFi5iCJyIK 0xogfTSCGhrwAEkizdMhDoJTRm7Cxa9Mo0UIClBY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=cnT/k2UYx 5rXwjln8dOMljT8z5g=; b=Wmz149IDqjrQsDRmDJ5+40llKGTAJhrocdAZLE08G 6eWxQIX5bDnDAvnojryrIUWKpJgeSnIzhXvHrJ41IDrETTEy1t8hKyVpLQYHtqqa ukexycAHzUQTWip/sntPPq8Mk5SRd2RudblJrQnGX1c4o084cd2qwotEajVN8+xy Fk= Received: (qmail 37488 invoked by alias); 10 Dec 2019 23:34:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 37480 invoked by uid 89); 10 Dec 2019 23:34:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] hurd: Fix using altstack while in an RPC call to be aborted Date: Wed, 11 Dec 2019 00:34:18 +0100 Message-Id: <20191210233418.231668-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 * 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. --- 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 a6928a607b..0c5d5a194c 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;