From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 21 Jun 2017 09:16:01 +0100 From: Catalin Marinas Message-ID: <20170621081601.g6fsf6i3mxzar5sn@localhost> References: <20170615011203.144108-1-thgarnie@google.com> <20170615011203.144108-3-thgarnie@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170615011203.144108-3-thgarnie@google.com> Subject: [kernel-hardening] Re: [PATCH v10 3/3] arm64/syscalls: Check address limit on user-mode return To: Thomas Garnier Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Paolo Bonzini , Rik van Riel , Oleg Nesterov , Josh Poimboeuf , Petr Mladek , Miroslav Benes , Kees Cook , Al Viro , Arnd Bergmann , Dave Hansen , David Howells , Russell King , Andy Lutomirski , Will Drewry , Will Deacon , Mark Rutland , Pratyush Anand , Chris Metcalf , linux-api@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com List-ID: On Wed, Jun 14, 2017 at 06:12:03PM -0700, 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. > > [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990 > > Signed-off-by: Thomas Garnier > --- > v10 redesigns the change to use work flags on set_fs as recommended by > Linus and agreed by others. > > Based on next-20170609 > --- > arch/arm64/include/asm/thread_info.h | 4 +++- > arch/arm64/include/asm/uaccess.h | 3 +++ > arch/arm64/kernel/signal.c | 5 +++++ > 3 files changed, 11 insertions(+), 1 deletion(-) For arm64: Reviewed-by: Catalin Marinas From mboxrd@z Thu Jan 1 00:00:00 1970 From: Catalin Marinas Subject: Re: [PATCH v10 3/3] arm64/syscalls: Check address limit on user-mode return Date: Wed, 21 Jun 2017 09:16:01 +0100 Message-ID: <20170621081601.g6fsf6i3mxzar5sn@localhost> References: <20170615011203.144108-1-thgarnie@google.com> <20170615011203.144108-3-thgarnie@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20170615011203.144108-3-thgarnie-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Thomas Garnier Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Paolo Bonzini , Rik van Riel , Oleg Nesterov , Josh Poimboeuf , Petr Mladek , Miroslav Benes , Kees Cook , Al Viro , Arnd Bergmann , Dave Hansen , David Howells , Russell King , Andy Lutomirski , Will Drewry , Will Deacon , Mark Rutland , Pratyush Anand List-Id: linux-api@vger.kernel.org On Wed, Jun 14, 2017 at 06:12:03PM -0700, 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. > > [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990 > > Signed-off-by: Thomas Garnier > --- > v10 redesigns the change to use work flags on set_fs as recommended by > Linus and agreed by others. > > Based on next-20170609 > --- > arch/arm64/include/asm/thread_info.h | 4 +++- > arch/arm64/include/asm/uaccess.h | 3 +++ > arch/arm64/kernel/signal.c | 5 +++++ > 3 files changed, 11 insertions(+), 1 deletion(-) For arm64: Reviewed-by: Catalin Marinas From mboxrd@z Thu Jan 1 00:00:00 1970 From: catalin.marinas@arm.com (Catalin Marinas) Date: Wed, 21 Jun 2017 09:16:01 +0100 Subject: [PATCH v10 3/3] arm64/syscalls: Check address limit on user-mode return In-Reply-To: <20170615011203.144108-3-thgarnie@google.com> References: <20170615011203.144108-1-thgarnie@google.com> <20170615011203.144108-3-thgarnie@google.com> Message-ID: <20170621081601.g6fsf6i3mxzar5sn@localhost> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Jun 14, 2017 at 06:12:03PM -0700, 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. > > [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990 > > Signed-off-by: Thomas Garnier > --- > v10 redesigns the change to use work flags on set_fs as recommended by > Linus and agreed by others. > > Based on next-20170609 > --- > arch/arm64/include/asm/thread_info.h | 4 +++- > arch/arm64/include/asm/uaccess.h | 3 +++ > arch/arm64/kernel/signal.c | 5 +++++ > 3 files changed, 11 insertions(+), 1 deletion(-) For arm64: Reviewed-by: Catalin Marinas From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbdFUIQK (ORCPT ); Wed, 21 Jun 2017 04:16:10 -0400 Received: from foss.arm.com ([217.140.101.70]:48238 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751015AbdFUIQG (ORCPT ); Wed, 21 Jun 2017 04:16:06 -0400 Date: Wed, 21 Jun 2017 09:16:01 +0100 From: Catalin Marinas To: Thomas Garnier Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Paolo Bonzini , Rik van Riel , Oleg Nesterov , Josh Poimboeuf , Petr Mladek , Miroslav Benes , Kees Cook , Al Viro , Arnd Bergmann , Dave Hansen , David Howells , Russell King , Andy Lutomirski , Will Drewry , Will Deacon , Mark Rutland , Pratyush Anand , Chris Metcalf , linux-api@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH v10 3/3] arm64/syscalls: Check address limit on user-mode return Message-ID: <20170621081601.g6fsf6i3mxzar5sn@localhost> References: <20170615011203.144108-1-thgarnie@google.com> <20170615011203.144108-3-thgarnie@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170615011203.144108-3-thgarnie@google.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 14, 2017 at 06:12:03PM -0700, 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. > > [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990 > > Signed-off-by: Thomas Garnier > --- > v10 redesigns the change to use work flags on set_fs as recommended by > Linus and agreed by others. > > Based on next-20170609 > --- > arch/arm64/include/asm/thread_info.h | 4 +++- > arch/arm64/include/asm/uaccess.h | 3 +++ > arch/arm64/kernel/signal.c | 5 +++++ > 3 files changed, 11 insertions(+), 1 deletion(-) For arm64: Reviewed-by: Catalin Marinas