mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>,
	libc-alpha <libc-alpha@sourceware.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>,  Brian Gerst <brgerst@gmail.com>
Subject: 32-bit vdso syscall cancellation proposal
Date: Thu, 27 Aug 2015 18:44:22 -0700	[thread overview]
Message-ID: <CALCETrVWZi55S9tBHfiu3O6oo6iB_Dcf3j=oVGBPLmD=Hid1bA@mail.gmail.com> (raw)

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


                 reply	other threads:[~2015-08-28  1:44 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='CALCETrVWZi55S9tBHfiu3O6oo6iB_Dcf3j=oVGBPLmD=Hid1bA@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=brgerst@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=musl@lists.openwall.com \
    --cc=x86@kernel.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).