From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8383 Path: news.gmane.org!not-for-mail From: Andy Lutomirski Newsgroups: gmane.comp.lib.glibc.alpha,gmane.linux.lib.musl.general,gmane.linux.kernel Subject: 32-bit vdso syscall cancellation proposal Date: Thu, 27 Aug 2015 18:44:22 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1440726297 5306 80.91.229.3 (28 Aug 2015 01:44:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Aug 2015 01:44:57 +0000 (UTC) To: "musl@lists.openwall.com" , libc-alpha , "linux-kernel@vger.kernel.org" , X86 ML , Brian Gerst Original-X-From: libc-alpha-return-62771-glibc-alpha=m.gmane.org@sourceware.org Fri Aug 28 03:44:54 2015 Return-path: Envelope-to: glibc-alpha@plane.gmane.org Original-Received: from server1.sourceware.org ([209.132.180.131] helo=sourceware.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZV8iq-00016t-5E for glibc-alpha@plane.gmane.org; Fri, 28 Aug 2015 03:44:52 +0200 DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=jrPmzys8igiQmRiYiPv26xwEAynRG 1Xttgq6GOmPltQdf3778iETIDzYVOrPcDYjy/rg1D2J1KZVLSUYXG6RxyPE+erd1 g1Hgb6xjDdrBbVf92Pw5CvhEEWsWqg9OnbPspbDCM9odg6rF9SB1VTJi8ui6rSyF RaJJqB0MRfwvCs= 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:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=bx0o6hHUTJaV3BQ7jX2YAWKfdZw=; b=toC 0IXG4r4HO6KlIeKwL4p1sRZ3fe5FLA4jvZm2EsFlmxVIajiUpa1o43WWSKVwwJAo 257nozVva5adcaszBaKZEMUaRWH+2yf84gl1Gdv1HJ5/Bk/3szZr35cq7PT57YeQ ItK6QjBA7Hsr6+jJ6Y9I6GOd9VtTMZAyRwsJqidg= Original-Received: (qmail 73097 invoked by alias); 28 Aug 2015 01:44:46 -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: , Original-Sender: libc-alpha-owner@sourceware.org Original-Received: (qmail 73085 invoked by uid 89); 28 Aug 2015 01:44:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f52.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=8irWD4BqM+99p2MiIXrEbrjTa1F/no8dN+548Xh68p4=; b=i98N23YamEtDcAQ4EGbtHTT+GrhBtCBdSLPq9BX/avt5u4QJf982V88m9Z7O59GDWL EB+ER1YykzrW1c3S+smdz7HqVgNPOXgjIA/9K4mFfV1M5Hvm1GLf8qyEQwYAm2qiqWVy 2Nf9+HkQkkSLij/dtJys9X3GbwmgItUJJmWZV2dEx1QJqIRuEq/8DF1qKWOoq2WonJxL M9/WIp2FOzgpWRdorgnFwhAjJ5ADUY/S/qZ9OdBxhwXDDMn+PzXQw5avyxzKiTtCLt5m NW6dWuXHPZcA0C508iAdnRrM4gQD1oCXi/rJhZ1SZwMLNVe2OcH+XFEVo8S2A7jOCs0R TZZw== X-Gm-Message-State: ALoCoQmhV9cMcp5+hbGQzE+P5xFKfB4cU5tl8+vtRfFzX/3QKWJe5wOeU/NBm7eQSEe09V4LsNd1 X-Received: by 10.202.75.2 with SMTP id y2mr4251219oia.116.1440726282241; Thu, 27 Aug 2015 18:44:42 -0700 (PDT) Xref: news.gmane.org gmane.comp.lib.glibc.alpha:55051 gmane.linux.lib.musl.general:8383 gmane.linux.kernel:2028298 Archived-At: Hi- After chatting with Rich Felker on IRC, he's convinced me that the 32-bit vsyscall mechanism is annoying for syscall cancellation. To help, I propose we add two functions: unsigned long __vdso_pending_vsyscall_eip(void *context); If context is a signal context pointing to the AT_SYSINFO entry and if that entry has *not* executed its syscall yet (or if it has but it's about to resume it), then returns the EIP to which the vsyscall will return. Otherwise returns -1. int __vdso_cancel_pending_vsyscall(void *context); If not in a valid pending vsyscall, returns -EINVAL. Otherwise clobbers all vsyscall return registers except ESP, EIP, and EAX and arranges for EAX to be -ENOSYS on return and for the vsyscall to be skipped. Returns 0. (Musl would slightly prefer -EINTR, but that's harder to implement. Musl would like the ability to *change* the return EIP even more, but that's considerably harder, given that the location of the saved EIP will vary depending on where we are in the vsyscall.) Ingo, if I implement something like this, it'll come with a careful test case. I already have a test case that tests the CFI annotations (by single-stepping through a syscall and asserting that it unwinds correctly from every single SIGTRAP). It'll also be on top of a series that turns __kernel_vsyscall into a *single* function. __vdso_pending_vsyscall_eip can't be reliably implemented using the CFI annotations, because you can't tell which side of the syscall you're on. __vdso_cancel_pending_vsyscall could be, but that's quite heavyweight, and implementing it directly will only be a couple lines of code. --Andy -- Andy Lutomirski AMA Capital Management, LLC