From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752799AbdGFUuV (ORCPT ); Thu, 6 Jul 2017 16:50:21 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:57870 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbdGFUuS (ORCPT ); Thu, 6 Jul 2017 16:50:18 -0400 Date: Thu, 6 Jul 2017 22:48:46 +0200 (CEST) From: Thomas Gleixner To: Thomas Garnier cc: Kees Cook , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Paolo Bonzini , Rik van Riel , Oleg Nesterov , Josh Poimboeuf , Petr Mladek , Miroslav Benes , Al Viro , Arnd Bergmann , Dave Hansen , David Howells , Russell King , Andy Lutomirski , Will Drewry , Will Deacon , Catalin Marinas , Mark Rutland , Pratyush Anand , Chris Metcalf , "x86@kernel.org" , LKML , Linux API , "linux-arm-kernel@lists.infradead.org" , "kernel-hardening@lists.openwall.com" Subject: Re: [PATCH v10 1/3] x86/syscalls: Check address limit on user-mode return In-Reply-To: Message-ID: References: <20170615011203.144108-1-thgarnie@google.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Jul 2017, Thomas Garnier wrote: > On Wed, Jun 28, 2017 at 10:52 AM, Kees Cook wrote: > > > > On Tue, Jun 20, 2017 at 1:24 PM, Kees Cook wrote: > > > On Wed, Jun 14, 2017 at 6:12 PM, Thomas Garnier wrote: > > >> Ensure the address limit is a user-mode segment before returning to > > >> user-mode. Otherwise a process can corrupt kernel-mode memory and elevate > > >> privileges [1]. > > >> > > >> The set_fs function sets the TIF_SETFS flag to force a slow path on > > >> return. In the slow path, the address limit is checked to be USER_DS if > > >> needed. > > >> > > >> The addr_limit_user_check function is added as a cross-architecture > > >> function to check the address limit. > > >> > > >> [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990 > > >> > > >> Signed-off-by: Thomas Garnier > > > > > > Thanks for reworking this series! > > > > > > The bad state correctly BUGs under the LKDTM test: > > > > > > [ 21.171586] lkdtm: Performing direct entry CORRUPT_USER_DS > > > [ 21.172791] lkdtm: setting bad task size limit > > > [ 21.173742] ------------[ cut here ]------------ > > > [ 21.174641] kernel BUG at ./include/linux/syscalls.h:220! > > > ... > > > [ 21.193166] Call Trace: > > > [ 21.193617] ? trace_hardirqs_on_thunk+0x1a/0x1c > > > [ 21.194443] entry_SYSCALL64_slow_path+0x25/0x25 > > > > > > > > > Tested-by: Kees Cook > > > > Is everyone happy with this patch for x86? Does this need anything > > more/different? > > Asking again. Additional feedback? Anyone wants to pick-it up? Can do. This needs to be a combo of all 3 I assume as the x86 one contains the function used by all of them, right? Thanks, tglx