Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp849437ybt; Wed, 1 Jul 2020 11:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5ebvthbJ9Vrb2zhZxGi1wgSTZQG/pjSffINEMCAWge9uXfDNOpMH0+IEw9LKw0OZMkA1H X-Received: by 2002:a17:906:d9c4:: with SMTP id qk4mr25504225ejb.100.1593628332531; Wed, 01 Jul 2020 11:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593628332; cv=none; d=google.com; s=arc-20160816; b=BZ56mLlJ28ricD4J7hsoYxBJiz+ewy8zC3+rOq3z6E6uowYcAB6jhW4PmSaPrhMaNS vF/Vt0aCaF5IwtUU27nvf+0/UxFNi0dQpMeHra95j0MQ+TuRxuQNDdUo1EATbustTz/4 vWrWG92lQ0hhoqjnTwrXVguDYuBtW+Nj8hAn9QMugFssqh5hWrdslAh8BCwsl76tPc1/ Xv8D++w6MACujXEdWsz/9eonqln76vo0FYjP9/rBTEBHsLKvo8cSjCRfwWo0p7WxSIis w4ylhD9kV/GQ2cfkctk/XEv3NrKxEn42DGxm01oDwS2CBboZsUG3Gm14y3FGCllWB/sA /Wgg== 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=wXULU8jqAzrxOdRJkt9uk9sATj+ZNdOMm69rSFp74/c=; b=F8wZjlC7ZJnkzhUcFseNYZk/wug/bCSQGXuGiFTEBzjbPn8RR/Z4uNiaV5mPRBIgV+ RL8hxs1GrmMVbnkGOj8+1dHN3uTuIVBFYClPSjrWL8ODmCwD6xvGlvcVoWDa/LXJDk3C jzrE1XTmKNvNHXKQB612GjzNHvImodwPwbSbZjOMChk963npQXMDfH6HkqJyEFvs8mDd BekBUZwjrityGExBNzEm+HTjB1BI2YCyCydbJmp41raR5eOxPdkFUdBs/6BjDhMsyGNK w+MmOv9kEQr6z9JLEIBAz35bo12ZcClYzAJhjrtwZedK7WK6DbV9XowLQT3LsyuIKdWO d+zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=koYoPpbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si4372428ejx.641.2020.07.01.11.31.49; Wed, 01 Jul 2020 11:32:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=koYoPpbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732903AbgGAS3k (ORCPT + 99 others); Wed, 1 Jul 2020 14:29:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732868AbgGAS3k (ORCPT ); Wed, 1 Jul 2020 14:29:40 -0400 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 17C6120870 for ; Wed, 1 Jul 2020 18:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593628179; bh=crJp7T1y7h3ms6pwMfWZ/AF2fWLGrg8o4SQlljPWaBA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=koYoPpbuXs4RL3kuuTS4M38hj6vbQXRpA+8X1x+3+l6Ca7Ih5M5KYi5+zo0xoyZxc 0XJ1XPXYHosn6pwnI0rREMraFQOBtNRHgvmcwQJc+Ede0SpTX3uI+XWawvteONx0Y4 A7dWqqpc8Ca1e8Xc47VJAPamVnRW98S8TLWntw0k= Received: by mail-wr1-f42.google.com with SMTP id z13so25145645wrw.5 for ; Wed, 01 Jul 2020 11:29:39 -0700 (PDT) X-Gm-Message-State: AOAM531nDZro1HaGok5yvjfwd6bFah82s491uOZKyM/jzLYtDBv/6OIS Bklx42onY32vxqHVN/zbahcXRq3Cn+vGcjHNfcpcKw== X-Received: by 2002:a5d:458a:: with SMTP id p10mr27397725wrq.184.1593628177649; Wed, 01 Jul 2020 11:29:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Wed, 1 Jul 2020 11:29:26 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: objtool clac/stac handling change.. To: Linus Torvalds Cc: Josh Poimboeuf , Peter Zijlstra , "the arch/x86 maintainers" , Linux Kernel Mailing List 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 Wed, Jul 1, 2020 at 11:22 AM Linus Torvalds wrote: > > Josh / PeterZ, > it turns out that clang seems to now have fixed the last known > nagging details with "asm goto" with outputs, so I'm looking at > actually trying to merge the support for that in the kernel. > > The main annoyance isn't actually using "asm goto" at all, the main > annoyance is just that it will all have to be conditional on whether > the compiler supports it or not. We have the config option for that > already, but it will just end up with two copies of the code depending > on that option. > > It's not a huge deal: the recent cleanups wrt the x86 uaccess code > have made the code _much_ more straightforward and legible, and I'm > not so worried about it all. > > Except that when I looked at this, I realized that I really had picked > the wrong model for how exceptions are handled wrt stac/clac. In > particular user access exceptions return with stac set, so we end up > having a code pattern where the error case will also have to do the > user_access_end() to finish the STAC region. > > Adding a user_access_end() to the user exception fault handler is trivial. > > But the thing I'm asking you for is how nasty it would be to change > objtool to have those rules? > > IOW, right now we have > > if (!user_acces_begin(...)) > goto efault; > unsafe_get/put_user(ptr, val, label); > user_access_end(); > return 0; > > label: > user_access_end(); > efaulr: > return -EFAULT; > > and I'd like to make the "label" case just go to "efault", with > objtool knowing that the exception handling already did the > user_access_end(). Do we really want the exception handling to do the CLAC? Having unsafe_get_user() do CLAC seems surprising to me, and it will break use cases like: if (!user_access_begin(...) goto out; ret = unsafe_get_user(...); user_access_end(); check ret; I have no problem with a special ex_handler_uaccess_clac, but I don't think it should be the default. --Andy