Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5173655imm; Wed, 12 Sep 2018 02:07:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYiVw3y4fpq66sHfoUr0mRCUkzD3mE+knDu3GD2yehsHOpd6ZfSwMmWwWuRPGccUXWZIaBK X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr1086927plf.126.1536743259539; Wed, 12 Sep 2018 02:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536743259; cv=none; d=google.com; s=arc-20160816; b=Gbc0hDxyUmlvwO9f06yX5NK2zOAbQNDm2yVkNthYttO8jWVtdRGThF/364BZEsck9T wlsuwUx0R5JQkfbz++jX64cWM/2HQw9O627doUA6uOc3SbVZz1QLSh68ekOaOOp6CApN lym7jWbG7YEhV0E8g+G5J479fxokeVwUClOmbJoChpJKUHC9hV5gmwrIc+Kho36QXZiU vETMw2k01NueQ8//g0a5+dgETfc5O/zkHPrtR6Fbam5Q4TPAsfIiSm8jenyp4awO/UpZ BbCtLaqOxE5Z2rLvTH5/R3rxNFVbPMAycJWjerFyGrFSEH1eKlRkXuNcLE5p56i6Up1/ bBFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=mEcNjRGiBF/5UXb6xDK3UFUmkgGjZkUJU3bHO8gcuL4=; b=ijRpvWxj6s4B/HvBf/3S91bUHPziA0xPb5g0sBFrR/Dk/jX+U7IC5J70W97zNyQ47C z3+sq8cZKVlU5MjWf0vX+i0cHsfAaTSdBwU1RhJUSE2kWRKGyK8q4TEwnMvuWaQzZ6au YTQqteVhktdX4dGPy/NAVWwA23p+AKUNS8OXA6jalf39FVPm25tWzfcw78kckhkLwdBt y62S0XKK8tGjnNzkrNq0uC4fXg6ZpVM+ZL5MOKYiJvXRu75LRCruISLqkpVRBshj+E1V iYrQ1GWTdfWF9TYysRwxF3/sP9muM3IxPhBxPdlak9USS1U+92PgXcyK9uD4x1PmjVPx Zt2g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 a5-v6si464238pgd.400.2018.09.12.02.07.23; Wed, 12 Sep 2018 02:07:39 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727968AbeILOI7 (ORCPT + 99 others); Wed, 12 Sep 2018 10:08:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:48644 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727702AbeILOI7 (ORCPT ); Wed, 12 Sep 2018 10:08:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5BA13AE78; Wed, 12 Sep 2018 09:05:22 +0000 (UTC) Date: Wed, 12 Sep 2018 11:05:20 +0200 (CEST) From: Jiri Kosina To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Josh Poimboeuf , Andrea Arcangeli , "Woodhouse, David" , Andi Kleen , Tim Chen , "Schaufler, Casey" cc: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH v6 0/3] Harden spectrev2 userspace-userspace protection In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, linux kernel is basically not preventing userspace-userspace spectrev2 attack, because: - IBPB is basically unused (issued only for tasks that marked themselves explicitly non-dumpable, which is absolutely negligible minority of all software out there), therefore cross-process branch buffer posioning using spectrev2 is possible - STIBP is completely unused, therefore cross-process branch buffer poisoning using spectrev2 between processess running on two HT siblings thread s is possible This patchset changes IBPB semantics, so that it's now applied whenever context-switching between processess that can't use ptrace() to achieve the same. This admittedly comes with extra overhad on a context switch; systems that don't care about could disable the mitigation using nospectre_v2 boot option. The IBPB implementaion is heavily based on original patches by Tim Chen. In addition to that, we unconditionally turn STIBP on so that HT siblings always have separate branch buffers. We've been carrying IBPB implementation with the same semantics in our (SUSE) trees since january disclosure; STIBP was more or less ignored up to today. v1->v2: include IBPB changes v2->v3: fix IBPB 'who can trace who' semantics wire up STIBP flipping to SMT hotplug v3->v4: dropped ___ptrace_may_access(), as it's not needed fixed deadlock with LSM/audit/selinux (Andrea Arcangeli) statically patch out the ptrace check if !IBPB v4->v5: fix MSR writing logic (Thomas Gleixner, Josh Poimboeuf) v5->v6: propagate X86_FEATURE_RSB_CTXSW setting to sysfs propagate STIBP setting to sysfs (Thomas Gleixner) simplify arch_smt_update() (Thomas Gleixner) Jiri Kosina (3): x86/speculation: apply IBPB more strictly to avoid cross-process data leak x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation x86/speculation: Propagate information about RSB filling mitigation to sysfs arch/x86/kernel/cpu/bugs.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ arch/x86/mm/tlb.c | 31 ++++++++++++++++++++----------- include/linux/ptrace.h | 4 ++++ kernel/cpu.c | 11 ++++++++++- kernel/ptrace.c | 12 ++++++++---- 5 files changed, 96 insertions(+), 22 deletions(-) -- Jiri Kosina SUSE Labs