Received: by 10.223.176.5 with SMTP id f5csp1103249wra; Tue, 6 Feb 2018 12:43:22 -0800 (PST) X-Google-Smtp-Source: AH8x225LWv6DKhDmYK3SkLGthDMEmjTcqkxS3SDmBGOJYGnrevyTazK7xrmp1TpZsosVWNQCvfII X-Received: by 2002:a17:902:581a:: with SMTP id m26-v6mr3573919pli.158.1517949802835; Tue, 06 Feb 2018 12:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517949802; cv=none; d=google.com; s=arc-20160816; b=jF4mCrUxap1ODYs0pe9nW1k5l2wFaEl1tBVn/1pm5iLfw88jLinAXIrGk3gwd2OQJw cwFCxKjDjk8uT3tAhlc4BS7TLCZ8T08geqn8MaWOYxp7lIyffxB/bQNhQwy40i0hD3Qq lYFinb6PivN0nx9CJH1Q7F0SVued5LZ5fyIl+6/p1v717k+chdMz4RFR96V7/fUX54tm 1jMfH2nAlsL/2ijh+FFOqCCV5C0z+ngkYCI18mCEGKcpEHxHstag8e/8oM56y8fSunDR LLCJTLnl4qNRSoYVhoieDpaJbyIwZ5CrGqnoAnkh37BCBREIVgRB9/A5290LnwhU4NL9 QAzQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HmSuJ0Ln96HzQ25RmLoBJfNJ/1Bx8Er0G88Hvb2CWo8=; b=RXVzij8rn8bzRV0D1RsnwcKfZwV0Q5I1BP5uUf30x7s0p7vCxrZuFwDEC+3dKyx2Lg +I8uubIfCMmp/izWEugDxHHYEsAACWWni5sZgjgwSZIBkHZhyb06fZ4yD+UulmuDxKFJ Y8+MVs7hZ7ljiLIroYkCYaMkFtSpcq53f9FTv5UfGEN9YnPHwnoGLeVlccdoJO4JgeLm zU+BHkVFGqj4iHxBPR6+Zl7Pshi5srRBGyiPzFjbbNIPMBgnq00cLxiEDA2KQ1kPmsJL trrnBJonQP/4Z+IP6OWZnmhUx74jetTYbBiVLlKyX7ECFyRf/O8Uk2L+KOraGaygxjHM 9Gxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JjtzRoXh; 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 b6-v6si2023246plx.805.2018.02.06.12.43.08; Tue, 06 Feb 2018 12:43:22 -0800 (PST) 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=fail header.i=@gmail.com header.s=20161025 header.b=JjtzRoXh; 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 S1753497AbeBFUma (ORCPT + 99 others); Tue, 6 Feb 2018 15:42:30 -0500 Received: from mail-it0-f44.google.com ([209.85.214.44]:52461 "EHLO mail-it0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbeBFUm0 (ORCPT ); Tue, 6 Feb 2018 15:42:26 -0500 Received: by mail-it0-f44.google.com with SMTP id o13so3795929ito.2; Tue, 06 Feb 2018 12:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=HmSuJ0Ln96HzQ25RmLoBJfNJ/1Bx8Er0G88Hvb2CWo8=; b=JjtzRoXhFOAVaCFaFaDoALuBibBCGB8V4d//kS0XD6ybS1GWSehG3Z+SvGkVxgfPWZ fQEBzdKcuI+c9n385uGjmPfGvFhJC3Nj7dl3AtdvTdE47vk9ozYSuP8uNaJXdMmL+t/1 8WZTJDFENmPzStKwCpe0fsBL8A1XdVvwNYaJ9kwZEzsvhtWp8HIbQXn+cCaNkVxORqWU V75wEHlBFeGiuQShB3jKXKYH1DVlUBsw0weU1ZKovX4ARfIQxEDXW72u6U3Oi5w+h/3d OEQE/m/OXKsnBhZJ9Z8crhOZDBPC4iJr+j0dHsDYKI+mVTD89JiZBBMC7SYkXsdZY89a VC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=HmSuJ0Ln96HzQ25RmLoBJfNJ/1Bx8Er0G88Hvb2CWo8=; b=Ljt7NJrtNlIMNTUqrjx3IMBWk9wmdchbnGiF89R0m2Yn0Ji1k2MEs5LobNNYUF+G/2 NXn8L/BtlKtBN7/bQje3WgjG/vKqJxDu+2B+/+HBJixrqyh6kxQz1XBXUQESxgWtD6/Z f8qO3O7nt92lQ/ntNoLKSEl1HMA/tHepei0YwlUN+B/mXbERfO2Bk2A9GjmrSMKsKszo s73odKqnH9zKjY0XgHOgDAacFnZy3Ic4HwrwjmuxpumLyyQlyYMlE2JyZ9yTjJtazN71 jfN8L+veZep7/wEymutlhaVfL3llG4RgpYWdNn2IEhNJobgy8UtM6PU0q5QQN6uOuRuw jvRQ== X-Gm-Message-State: APf1xPC4a8DUMDSDaP+jaUpFJclm3V1odgIMo+edUbXaJKlEJGtLkQIZ RbsU7clj/AD/gSM/ijlOmml07mKOi1QqyFHyOsg= X-Received: by 10.36.248.134 with SMTP id a128mr4835504ith.152.1517949745365; Tue, 06 Feb 2018 12:42:25 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.59.196 with HTTP; Tue, 6 Feb 2018 12:42:24 -0800 (PST) In-Reply-To: References: <151632009605.21271.11304291057104672116.stgit@dwillia2-desk3.amr.corp.intel.com> <151632014097.21271.16980532033566583357.stgit@dwillia2-desk3.amr.corp.intel.com> <20180206192925.qkmghwsbaysr4iv2@hermes.olymp> From: Linus Torvalds Date: Tue, 6 Feb 2018 12:42:24 -0800 X-Google-Sender-Auth: gNdwm8oBfina1kT0TJpTDxK9qvo Message-ID: Subject: Re: [PATCH v4 07/10] x86: narrow out of bounds syscalls to sys_read under speculation To: Dan Williams Cc: Luis Henriques , Linux Kernel Mailing List , linux-arch , Kernel Hardening , Greg KH , X86 ML , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , Thomas Gleixner , Andrew Morton , Alan Cox 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 Tue, Feb 6, 2018 at 12:37 PM, Dan Williams wrote: > > Are there any compilers that would miscompile: > > mask = 0 - (index < size); > > That might be a way to improve the assembly. Sadly, that is *very* easy to miscompile. In fact, I'd be very surprised indeed if any compiler worth its name wouldn't combine the comparison with the conditional branch it accompanies, and just turn that into a constant. IOW, you'd get mask = 0 - (index < size); if (index <= size) { ... use mask .. and the compiler would just turn that into if (index <= size) { mask = -1; and be done with it. Linus