Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp921394pxu; Fri, 23 Oct 2020 17:27:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbD2Gm5vLwnWUoMaj8p/rUhVItS3x3he2ItPKmV91mK5zTZ9nwi4keGO1tafVet2tVnmqK X-Received: by 2002:a05:6402:c12:: with SMTP id co18mr4701093edb.162.1603499257233; Fri, 23 Oct 2020 17:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603499257; cv=none; d=google.com; s=arc-20160816; b=sXguNz8vykp/w8xCaIVJ89nm5CjPdnsXwDuUPXkkZzjS+nVo++gYNb9S882GsmbGph 6lv68cDG0dhkEXd9VXHdNWPe1wVSLNS0gTGgs3O7PzRZYRmilXp4uW5BbR1J0UPmrY9u HdP83Hc3s22Uk/kDa3fdRspTuj9wFvXiTQTZ5HNvyLpsMIXVJFaIlZvSHO9nLxgpnCi9 iYl7PH+mgRvvwf1ZVb0irJ381iEufknkbiA0TkumqFhLos+AWOdqF3Ps3TlwMKOsada6 Wxhv9McpGI4cuEf693RlQzT/2wMWz2LfpVS+Nr5mcmu5L533ZziAuCkDtKZXswaFqE/D WbFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=H8PIAcZB+49cL/qkEaQxKoNrp5mF5VZb6QoBdo21438=; b=xpb/lQuNrUOkIpbxHs6Jo0LByPaf+ApUE3mls770qRvU1dysUWHwtKn8teGzt2CpFb /1WvcmYvOvzXIjWNISjyiEl4Z2DFnr7i7TKYr8NQU8rlvnjmImXJPgSpQigP+Efz09Hf nvrk6zj7YXHInW23gF+HjThoqFb+hYDXGo9Fwjp8d+Jqa5PBu9UekG1/RwzhThr3+KSB Wjy12ZnZ0nHUS0d9yv4voFGsYhXCY1Ua5D2Dyk7+cDhbVp2StPCETWeEYHClcK0LOxEa 4mYEt9pcP+YzSm4RWq6H3k6U3cGlpUZ5Jg/Bj0MylQ5+1U9gEcHqMLEheUJkT6C3GGwF zNFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=JAZXaC93; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs10si1923390edb.190.2020.10.23.17.27.15; Fri, 23 Oct 2020 17:27:37 -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=@linux-foundation.org header.s=google header.b=JAZXaC93; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756422AbgJWUxU (ORCPT + 99 others); Fri, 23 Oct 2020 16:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756412AbgJWUxT (ORCPT ); Fri, 23 Oct 2020 16:53:19 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 844D3C0613CE for ; Fri, 23 Oct 2020 13:53:17 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id x16so2977301ljh.2 for ; Fri, 23 Oct 2020 13:53:17 -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=H8PIAcZB+49cL/qkEaQxKoNrp5mF5VZb6QoBdo21438=; b=JAZXaC931XIpk3gt8AMxYg7YUQT1MXzQoOMEiIryFhi3PMtcehAhMwzTLjfi9ZiPp6 IrWiK/S1OM0h6zf1hO34JH6gYZ8rvU2TTGjpDYhDCpP4Oex4/ZP0jryouAu6IlOxz3Yu OBKb9xXBU3PjhQEg0A1OeU3fcpQsr5UFb25YQ= 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=H8PIAcZB+49cL/qkEaQxKoNrp5mF5VZb6QoBdo21438=; b=ipYWsrQwpMD1vo4u4pv5SFO06qsZL+xYB3r3gQCwY8FDl5WkK30Dq+8uYLmn420gDJ 74FKdCkBv0mk3np+6IIL/7cUFXdBOMDOZ+i6jCHZv/LYDwatjUeDQM6Z+LjpaglnUkci x8WTu7tQcKlSsXOQ6RrNOrZujNEw3cD7SFTgCUsUYfReQF3Nwu3QSGY7X2aT3V0S3Ktd mT3Kf81+4sdBDw0BE29PLM7LTwwdIlaApqSjEZmKs2ZYWc5Vb36iC96+pYt4Oy9vnz+e ImMh5xTCXGK/o551SQLzBpXkJuGSzRD1SSFkZ5V5JK984AjhjUGW0Ve/UgqAuNDHb+Zl kktA== X-Gm-Message-State: AOAM5339xuDo9LrM81kQXGF8z8STmLestfpvJS5lNSp7li3aHbdkDu/l YGhEkaatD7TIHT/YNc4iHC7BBNR/V2Skxw== X-Received: by 2002:a2e:8596:: with SMTP id b22mr1466033lji.455.1603486395699; Fri, 23 Oct 2020 13:53:15 -0700 (PDT) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id r15sm238199lfn.65.2020.10.23.13.53.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 13:53:14 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id j30so3673215lfp.4 for ; Fri, 23 Oct 2020 13:53:14 -0700 (PDT) X-Received: by 2002:a19:83c9:: with SMTP id f192mr1269013lfd.148.1603486394019; Fri, 23 Oct 2020 13:53:14 -0700 (PDT) MIME-Version: 1.0 References: <20201023203154.27335-1-linux@rasmusvillemoes.dk> In-Reply-To: From: Linus Torvalds Date: Fri, 23 Oct 2020 13:52:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/uaccess: fix code generation in put_user() To: Andy Lutomirski Cc: Rasmus Villemoes , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "H. Peter Anvin" , Sean Christopherson , Naresh Kamboju , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 23, 2020 at 1:42 PM Andy Lutomirski wrote: > > This looks like the patch is an improvement, but this is still IMO > likely to be very fragile. Can we just do the size-dependent "a" vs > "A" selection method instead? Sure, it's a little more code, but it > will be Obviously Correct. As it stands, I can easily see our code > failing on some gcc or clang version and the compiler authors telling > us that we're relying on unsupportable behavior. Well, the "register asm()" thing actually _is_ documented, and it's something we've used before too (and still use in other places). We actually have quite a bit of them - just do a git grep 'register.*asm(' to see literally hundreds of them. So gcc (and clang) actually has a lot of test-cases for it. In many ways, x86 actually tends to need _fewer_ of these than most other architectures, since on x86, we almost always have specific register naming in ways that other architectures often don't (because x86 has all those specific register rules). So the 64-bit issue for x86-32 is a bit of a special case for x86, but this is in no way a special case in general, and is quite the common pattern on other architectures. The fact that KASAN could generate code in between the register asm assignment was something I just overlooked (and embarrassingly similar to the issues we had with objdump checking STAC/CLAC back when we inlined that all). It's a bit sad that gcc doesn't _warn_ about this kind of issue, since the compiler certainly should see "oh, we just had a register clash". But it is what it is.. Linus