From patchwork Fri Dec 13 02:25:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1208937 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-108038-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="UQ+FK1V4"; 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 47YvfL0XCTz9sPT for ; Fri, 13 Dec 2019 13:25:45 +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:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=BOUtVFz+cDE5HFTSdMtMbhmu6+etqL0cpWGA31lcUT0lPxBaqmTvE LlytgexJAO4piTYtL7VmwhkfErmqXbIacQI5TO3/PhzY1W2JydQoC86AOb9qK+PD HZUWU+RhPtSsjUzSAfLorjd/eRl9NTgddrR9Z2dyATq/415LBriPZE= 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:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=cnT/k2UYx5rXwjln8dOMljT8z5g=; b=UQ+FK1V4B8hDH8aOg95KiyJ1kTRr bNhxnBajNFtNaAm2xAslhAXrf/z1HsXxpqX+DHmWiDZWwW3Byc9Tn9oYsC5zvah8 rJOcFDYnfG8WkVCBnWPrEvlTGmAOVU9fIgFNuS3Ozgn6Ixe8M2S4y5xhg57CRCcG k7I+6EIv4QEBTuk= Received: (qmail 123835 invoked by alias); 13 Dec 2019 02:25:30 -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 123783 invoked by uid 89); 13 Dec 2019 02:25:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=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=7412, 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: Fri, 13 Dec 2019 03:25:17 +0100 Message-Id: <20191213022519.164161-2-samuel.thibault@ens-lyon.org> In-Reply-To: <20191213022519.164161-1-samuel.thibault@ens-lyon.org> References: <20191213022519.164161-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;