Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp914958imm; Fri, 22 Jun 2018 07:26:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6yNgwkKflqsXN8rL6idsRjne1wMde63xeShyqltTQwmVqIgT41CAu5N/yYJiGqBD4B/+H X-Received: by 2002:a65:65d6:: with SMTP id y22-v6mr1643450pgv.270.1529677589573; Fri, 22 Jun 2018 07:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529677589; cv=none; d=google.com; s=arc-20160816; b=rZPqop6nzZANuuKPCe8vxAfsuH3+N2aqqzicg0ovM/C8zh6YvxlsHkGNTul+YALqfj 2OItS56nQJtbX6YkKV6iEKp1YVARGQ2n8Tgso2qt9jdKreOBikgRA5+KUVMU9aS46dft 8SnK0xVD1R+uJKTcv13I9KAFh7ic4VINDGuAkQZIhZTiOHFjyy9WHcc184YzLm/chBoJ zWRKBx8xBOkMuc1vGVIbZHGCUlJ/o2jw2l0QiDJ3KobaNbhLTjZ/G1ku6JpJg33pR7vL Tngwv9N8ZQWGdLnKIYZ+ATBDxWhm1mPX4AcMNKwfZtL7MSgLwaB2nHKP3sR7K5bLGD89 zNaA== 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 :arc-authentication-results; bh=/SF0b5+fK8nWHRJXbrj0+TBzGlK6bHwgUXUJhORaqRU=; b=uz3fZuaOyeU7te4qB2mUUVR0zji7eH3TDuwIWGTt7mdkDaYnPvRjT6DgZm3wRgC0wk rs9EnojoEVpfY5XObbgh0DboaszLwkg/4U+gZ1hiwi6xVMJIX1ZxNGzvdcb/XKhZZ0DE G1HuxeL0L0T3FvVqkeC5BCWMr+DNUOYoyiKbgzUm8GT1KTgnewEusGdV9BeIF1CCLc/a SXYBbZJ8T12KuslTz+Cq20TmRVX0A8LnmYJ6/h/szXYzaoJJHwDHjMdsn7OTNKeaBDij IojP+UrCP4rgEFg8b8z0KvyHefuzwrulYnnSYrIkLCAc6S7i64/G3bLaRLs941kg1PAG d6sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yALX+4h6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 184-v6si6021823pgd.343.2018.06.22.07.26.15; Fri, 22 Jun 2018 07:26:29 -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=@kernel.org header.s=default header.b=yALX+4h6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932973AbeFVOZL (ORCPT + 99 others); Fri, 22 Jun 2018 10:25:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeFVOZK (ORCPT ); Fri, 22 Jun 2018 10:25:10 -0400 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) (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 ED01E2439E for ; Fri, 22 Jun 2018 14:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529677510; bh=I/HiUBPB9TPpxxikgcULTKc79trJ8CEg9P3m/Ufr1cs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=yALX+4h6EMwndSoup5qK5yQbydmVso+sWuywe7Cm0mNC7ekRFpZ4azFk8tFo1Enld 3fhinXfS0AuWP+iO2ecJA4FUtBbmg6/rfGsZ5U9LWHL+gaPm2UeJkvQ5u8aZ16mJ2Q X+RKKPlWIVmOH+qNkPiMES2wRifzCnqhFgvpHqYg= Received: by mail-wm0-f47.google.com with SMTP id o13-v6so2430692wmf.4 for ; Fri, 22 Jun 2018 07:25:09 -0700 (PDT) X-Gm-Message-State: APt69E2H1M81+zYzFOP+XUiNlPPaF9O/jYCbn+a+HnH3xYfawqm164t/ LdyaOUSJqqbdt7L+7/mpt6VEgjCSsB6N0H3s9kqITw== X-Received: by 2002:a1c:4a9d:: with SMTP id n29-v6mr1783036wmi.46.1529677508417; Fri, 22 Jun 2018 07:25:08 -0700 (PDT) MIME-Version: 1.0 References: <20180621211754.12757-1-h.peter.anvin@intel.com> <20180621211754.12757-2-h.peter.anvin@intel.com> In-Reply-To: <20180621211754.12757-2-h.peter.anvin@intel.com> From: Andy Lutomirski Date: Fri, 22 Jun 2018 07:24:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/7] x86/ldt: refresh %fs and %gs in refresh_ldt_segments() To: "H. Peter Anvin" Cc: LKML , "H. Peter Anvin" , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Andrew Lutomirski , "Bae, Chang Seok" , "Metzger, Markus T" 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, Jun 21, 2018 at 2:18 PM H. Peter Anvin, Intel wrote: > > From: "H. Peter Anvin" > > It is not only %ds and %es which contain cached user descriptor > information, %fs and %gs do as well. > > To make sure we don't do something stupid that will affect processes > which wouldn't want this requalification, be more restrictive about > which selector numbers will be requalified: they need to be LDT > selectors (which by definition are never null), have an RPL of 3 > (always the case in user space unless null), and match the updated > descriptor. That RPL3 part is false. The following program does: #include int main() { unsigned short sel; asm volatile ("mov %%ss, %0" : "=rm" (sel)); sel &= ~3; printf("Will write 0x%hx to GS\n", sel); asm volatile ("mov %0, %%gs" :: "rm" (sel & ~3)); asm volatile ("mov %%gs, %0" : "=rm" (sel)); printf("GS = 0x%hx\n", sel); return 0; } prints: Will write 0x28 to GS GS = 0x28 The x86 architecture is *insane*. Other than that, this patch seems generally sensible. But my objection that it's incorrect with FSGSBASE enabled for %fs and %gs still applies.