Received: by 10.223.176.5 with SMTP id f5csp1115208wra; Tue, 6 Feb 2018 12:59:24 -0800 (PST) X-Google-Smtp-Source: AH8x227kuXqDvHscqT/FuQkHdNZfrGixvSwuzqRLpuS0WQiio9NLkHsN53/F70NYLJFgXOWmYerC X-Received: by 2002:a17:902:7c86:: with SMTP id y6-v6mr3621905pll.24.1517950764624; Tue, 06 Feb 2018 12:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517950764; cv=none; d=google.com; s=arc-20160816; b=tLh40ULwTR9t8RSWIyLDqs4BV3XcEhisoEyzUDzcL0cp2ABHA44ttrQLEC/2xKV99X NvwZboEEoZmOWpBHOYjBtiUn+PvMV6FAYZ3sFJwH2P3HL9YBijYfEFNrZUid2XBdZwgL ZIb/Ynd9gTIyupur5QuGXe95WH9GdBP2ZlsPgua4N49GIMBN5iYCdH/v//cBN6DbkqIE b1GhTtgOllyXlLrspTsyOo4S7mHYScrNJ+5C+t+IASXrO5r9qhhbC0JmioxMn6IlBCiZ RzUeRbEgnqOTU1hnvxv9VbYA+AQcbM3Ik5EAQTM5+MUuw7n2eirgSe96Yi3uGISE0Udr ssbQ== 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=w5Njh8HugnDq92qceM9wlSGI8tpLQx6Ay1uVosh9kWc=; b=YRi9Z3XGmwuvRC566ZYI+UU6IiQFGpSy+MeWN+U5Xus+miZrmylUtteul7D9ZB8E8U QDMbKmnp/kak4nQxnAj3OE/7f6OaqihxJ3A6Dxnf8J+v8E7+pfkY4eVaRGXoC9FhSFho ypo90jKOtgZTwDrF3Q2mpJujxj1sOvs9P2xraKCptQJcqYtxBcrfbraEFU7mqv7/Z6hE evLrdIsDmGQhyI6tU0PRM3hb4iwjG9kAfz+TDkB3VjDI6X8X6RoV32VhcJEgyc+mXTY0 Zd7Vx3/0rIQLvO2BCG6KSlEo+Y18Y+E18NDxGjHSJ9pBFAQ9lmTG2roNVRfgS3YsijSq 9u1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=eeYQOIfN; 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 w1si5532311pgt.182.2018.02.06.12.59.10; Tue, 06 Feb 2018 12:59:24 -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=eeYQOIfN; 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 S1753973AbeBFU6c (ORCPT + 99 others); Tue, 6 Feb 2018 15:58:32 -0500 Received: from mail-it0-f45.google.com ([209.85.214.45]:56144 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752514AbeBFU62 (ORCPT ); Tue, 6 Feb 2018 15:58:28 -0500 Received: by mail-it0-f45.google.com with SMTP id b66so4215208itd.5; Tue, 06 Feb 2018 12:58:28 -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=w5Njh8HugnDq92qceM9wlSGI8tpLQx6Ay1uVosh9kWc=; b=eeYQOIfNBxr4JbgJ2bDnC/nhs2OiIHVZ3znat1mPBLWGFOjS5JivFYvAYVLOn5OxR5 /9W5co3GpmdJtun6MDEa249ZnpRId2m9eTl2it8NcL+yekNsb4+986HeVQzxIE0Owgq+ hB1LVsjkVkVA1NwBCY0zx3eSWJi2eepSDpXPN7RtNiCaQmZHFmtpQ/fBNU9ZVmCoCny7 L1+huE7/vQ/Kv3HFuZ4OZPNeJssyicAl80HpoydUkKC5T7jiT7gDxQ+0FwAFlx92lg2+ MmbqX/mNCjFd6xYW9n0RPDo+TUCA9sauezqYQSy9ll2Wxkp8+9U/cuRJC1QXNJpnrRhb miaA== 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=w5Njh8HugnDq92qceM9wlSGI8tpLQx6Ay1uVosh9kWc=; b=G73FB6ukXAG1m+1UbN49prtP+v0p2boKAMYugUyleumtow3fdCweReAr+vH2wxE17m D0M+R4gFVrqOnaPJA37kaSXK8mp/3mqeQ/V4XQeFRnbgspr403K0emxxkqgaykMvk/mO arjBj5etfHKYaLyiph2OSoThjbxQwtnLY0b8p842bOJwXhzU4TVvPo4/d0vO4G9l3oKJ 07c2zQBwJX/mmPDGpHanS4zjZbmzDx+fb1wzuffMtcyLCbui/MTPNLhri6LbkwxXioL+ RzXF6fGHUtM3qRmfraKcLprLn5vzYDdXh2QTl/GT980iWmT7fR/LDQ3PhDt/g+jgnjge gsDg== X-Gm-Message-State: APf1xPBv/FbZluzJ+NJb+wyhkl9Wif6asW8eRkI6rPPrG0JX8Pc2I0zD 2EvCswREEudG2iN0QpLvu2OKVX5SHvfrZKGmKvfQlgVh X-Received: by 10.36.172.67 with SMTP id m3mr4987183iti.139.1517950707949; Tue, 06 Feb 2018 12:58:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.59.196 with HTTP; Tue, 6 Feb 2018 12:58:27 -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:58:27 -0800 X-Google-Sender-Auth: SvoU4KpQKcRtIDULILL7PgBmuVo Message-ID: Subject: Re: [PATCH v4 07/10] x86: narrow out of bounds syscalls to sys_read under speculation To: Andy Lutomirski Cc: Dan Williams , Luis Henriques , Linux Kernel Mailing List , linux-arch , Kernel Hardening , Greg KH , X86 ML , Ingo Molnar , "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:49 PM, Andy Lutomirski wrote: > > Can you use @cc to make an asm statement that outputs both the masked > array index and the "if" condition? I can never remember the syntax, > but something like: Yes. Although I'd actually suggest just using an "asm goto" if we really want to optimize this. Give the "index_mask_nospec()" a third argument that is the label to jump to for overflow. Then you can just decide how to implement it best for any particular architecture (and compiler limitation). Linus