Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755505AbeAJBDw (ORCPT + 1 other); Tue, 9 Jan 2018 20:03:52 -0500 Received: from mga04.intel.com ([192.55.52.120]:32326 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755308AbeAJBDs (ORCPT ); Tue, 9 Jan 2018 20:03:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,337,1511856000"; d="scan'208";a="18834366" From: Andi Kleen To: tglx@linutronix.de Cc: x86@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com, luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com, tim.c.chen@linux.intel.com, gregkh@linux-foundation.org, dave.hansen@intel.com, jikos@kernel.org Subject: x86/clearregs: Register sanitizing at kernel entry for speculation hygiene Date: Tue, 9 Jan 2018 17:03:20 -0800 Message-Id: <20180110010328.22163-1-andi@firstfloor.org> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: This patch kit implements clearing of all unused registers on kernel entries, including system calls and all exceptions and interrupt. This doesn't fix any known issue, but will make it harder in general to exploit the kernel with speculation because it will be harder to get user controlled values into kernel code. The patchkit is a bit more complicated because it attempts to clear unused argument registers, which requires on 64bit to know how many arguments each system call has. I used some scripting to derive the number of system calls from the SYSCALL_DEFINE*s and add it to the x86 system call tables. Everything else is relatively simple and straight forward, and could be used independently. I assume this mostly isn't 4.15 material, but should be considered for 4.16 Possibly some of the simpler patches could be considered for 4.15 Original patches were from Tim Chen, but changed significantly by AK. git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc.git spec/clearregs-1 v1: Initial post