Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1221544imd; Thu, 1 Nov 2018 12:07:55 -0700 (PDT) X-Google-Smtp-Source: AJdET5fFphGbREynEooyQzCLJfm9DGquQeFDngo6AE/Yg7M5FEexnZRzlRc80m6/q7P2qLwbuLE4 X-Received: by 2002:a63:cf0e:: with SMTP id j14-v6mr8249790pgg.195.1541099275479; Thu, 01 Nov 2018 12:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541099275; cv=none; d=google.com; s=arc-20160816; b=uXNow8EeblOPVQXpdHVH+SQy7VttuKf4QenfSYCoO6QxF1KxRNRB5MFtFBBVZsDvt0 ivIx7PXk3Q0D3T3TjTrZQiLWlUYxH55fBTV1AnGvj01qGvUiGRQviP/sHBbAhUbVPm+1 lNT+nMFfW7XXG/HFTNBWTMjbs2B5G9t1VuskhWPbwX1E/Qb/9DVD5IqgYFMLqpJglbgi HUkUCA+qGyI7CSKML27UNIL+5tEMVkzzQi1liilL9qIHjHJ86EEFP/uqqzx7Rgki9sfz LSFZ7Q5/VbnzUeQrW2wSEaxFaj8IsK2wvuQUtN47oak0tmT6po4j/6JOSDGpbtHPC1gG At5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sAdyijJANdHXrZS7Rhy3SlpitoiP+F4HljNHFT3Q6h0=; b=eAU2aDYDIylqFi8Lj74/VGqHNvigKaXQnfPZR7LA/C3JgbUXwzi1TVpUiRNcoMSWlT 5uqvOo3CECotKZh11CVLR7mHAf0N+4sAjvsYO80lGqJVS4hAJIlbQ1IVUTgzaGxXNYWO b4iwJI5buby5IK70EsDbKZMdBzsfQT2ZN9WP2Z9Z90DtQlfBTUZCDJiYjkT59PNKCeVZ c6NZ2VNQODQqvP26q1RmztIFzadsoBouNiK73kzXtlcB+Mm0uAmjZrUxkdQ4Ce8uZWT0 IFifZ+B7Wx9M7/6uGW2zvpMTrceWF7PfURXHNc6np198MHWvFtMDvtb57PmqFlbWPUSp vEMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QLm6iK3y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si10227216plc.282.2018.11.01.12.07.40; Thu, 01 Nov 2018 12:07:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QLm6iK3y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbeKBEK4 (ORCPT + 99 others); Fri, 2 Nov 2018 00:10:56 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41507 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725722AbeKBEK4 (ORCPT ); Fri, 2 Nov 2018 00:10:56 -0400 Received: by mail-lf1-f65.google.com with SMTP id c16so14971130lfj.8 for ; Thu, 01 Nov 2018 12:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sAdyijJANdHXrZS7Rhy3SlpitoiP+F4HljNHFT3Q6h0=; b=QLm6iK3yWs27nIzZ2pM2WZg7LUjUDqDg6URDt6pOhlyh7k3cN660A+J6c18S1uCc/y tnr/I7p4mnFgSUp1kKhTS23iB5r1GfpvS5afsvW42SSgPiQgKGNAbVhs8EMfYgndu93g jrqkQ7wkUdB0OzKlCzqwTIoBCMuuAmFqL5ScE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sAdyijJANdHXrZS7Rhy3SlpitoiP+F4HljNHFT3Q6h0=; b=iIBHiIkRyRQlX2HrRqFZaPbQDOonDokPBfVDGBubq+0wJ0DcKUdUT8cbHruH8Xk2aV AjByDgdZkd2mrs/tCXjhjhP+gcWPz2gORL2A0exZhcaVJsGXR2z1+aDUe+bZDQhzJfT+ hLja4bF7sPhv9TEBqWbsZOXv3g2WE1JPjurNNXZohwlsOeayatGth+BEEhn0reSu2gDA lFX/97XCphVo7fyisLD54ByI6120oVO89VwP55MuRSl78XXoQr6OWM3cY39eyMAfegJj sFkoF9j2Eye+BNznsbPg1nQSFGX4KUBb8ROwOxOqMqUMwY6xQMoLrf5P1ywug7AslSYs ShCw== X-Gm-Message-State: AGRZ1gKyWdTeQQPW7weUczV3LXkXRt8YkTZqrLYaxu8hIuEvvesuVoy7 SSCMyYQG2PT2iHxD3VCqzZut6x5sVIvsNQ== X-Received: by 2002:a19:db4a:: with SMTP id s71mr5289551lfg.36.1541099199732; Thu, 01 Nov 2018 12:06:39 -0700 (PDT) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id p134-v6sm5188886lfd.80.2018.11.01.12.06.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 12:06:38 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id f3-v6so19029764ljk.9 for ; Thu, 01 Nov 2018 12:06:38 -0700 (PDT) X-Received: by 2002:a2e:95c6:: with SMTP id y6-v6mr5513348ljh.59.1541099197588; Thu, 01 Nov 2018 12:06:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Thu, 1 Nov 2018 12:06:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: userspace exception fixups To: luto@kernel.org Cc: dave.hansen@linux.intel.com, sean.j.christopherson@intel.com, jethro@fortanix.com, jarkko.sakkinen@linux.intel.com, fweimer@redhat.com, linux-api@vger.kernel.org, Jann Horn , x86@kernel.org, linux-arch@vger.kernel.org, Linux Kernel Mailing List , Peter Zijlstra , dalias@libc.org, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, Ingo Molnar , bp@alien8.de Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 1, 2018 at 10:53 AM Andy Lutomirski wrote: > > There's been some discussion of adding a vDSO entry point to wrap > EENTER and do something sensible with the exceptions, I think that's likely the right thing to do, and would be similar to sysenter. > The basic idea would be to allow libc, or maybe even any library, to > register a handler that gets a chance to act on an exception caused by > a user instruction before a signal is delivered. As a straw-man > example for how this could work, there could be a new syscall: > > long register_exception_handler(void (*handler)(int, siginfo_t *, void *)); I'm not a huge fan of signals, but the above is an abomination. It has all the problems of signals _and_ then some. And it in absolutely no way fixes the problem with libraires. In fact, it arguably makes it much much worse, since now there's only one single library that can register it. Yes yes, maybe a library would then expose _another_ interface to other libraries and act as some kind of dispatch point, but on the whole the above is just crazy and fundamentally broken. If you want to register an exception, you need to make it clear (a) which _thread_ the exception registration is valid for (b) which _range_ the exception registration is valid for (c) which _fault_ the exception registration is valid for (page fault, div-by-zero, whatever) (d) which save area (aka stack) and exception handler point. Note that (b) might be more than just an exception IP range. It might well be interesting to register the exception by page fault address (in addition to code range). If you do something that does all of (a)-(d), and you allow some limited number of exception registrations, then maybe. Because at that point, you have something that is actually actively more powerful than signal handling is. But your suggested "just register a broken form of signal handling for a special case" is just wrong. Don't do it. Linus