From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337AbcGGR1K (ORCPT ); Thu, 7 Jul 2016 13:27:10 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:34870 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145AbcGGR1G (ORCPT ); Thu, 7 Jul 2016 13:27:06 -0400 MIME-Version: 1.0 In-Reply-To: <577E04FF.1090000@de.ibm.com> References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> From: Kees Cook Date: Thu, 7 Jul 2016 13:27:03 -0400 X-Google-Sender-Auth: KKrymtWMg5dezXqayw50cxf8z3c Message-ID: Subject: Re: [PATCH 0/9] mm: Hardened usercopy To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , "linux-arm-kernel@lists.infradead.org" , linux-ia64@vger.kernel.org, "linuxppc-dev@lists.ozlabs.org" , sparclinux , linux-arch , Linux-MM , "kernel-hardening@lists.openwall.com" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Subject: Re: [PATCH 0/9] mm: Hardened usercopy Date: Thu, 7 Jul 2016 13:27:03 -0400 Message-ID: References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <577E04FF.1090000@de.ibm.com> Sender: owner-linux-mm@kvack.org To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly List-Id: linux-arch.vger.kernel.org On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com ([74.125.82.54]:37321 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753164AbcGGR1G (ORCPT ); Thu, 7 Jul 2016 13:27:06 -0400 Received: by mail-wm0-f54.google.com with SMTP id a66so40430388wme.0 for ; Thu, 07 Jul 2016 10:27:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <577E04FF.1090000@de.ibm.com> References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> From: Kees Cook Date: Thu, 7 Jul 2016 13:27:03 -0400 Message-ID: Subject: Re: [PATCH 0/9] mm: Hardened usercopy Content-Type: text/plain; charset=UTF-8 Sender: linux-arch-owner@vger.kernel.org List-ID: To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , "linux-arm-kernel@lists.infradead.org" , linux-ia64@vger.kernel.org, "linuxppc-dev@lists.ozlabs.org" , sparclinux , linux-arch , Linux-MM , "kernel-hardening@lists.openwall.com" Message-ID: <20160707172703.tWyOb6TynQkbUEtJy9zQzIt1FOPBqKa1glB6hiddXAU@z> On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Date: Thu, 07 Jul 2016 17:27:03 +0000 Subject: Re: [PATCH 0/9] mm: Hardened usercopy Message-Id: List-Id: References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> In-Reply-To: <577E04FF.1090000@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , "linux-arm-kernel@lists.infradead.org" , linux-ia64@vger.kernel.org, "linuxppc-dev@lists.ozlabs.org" , sparclinux , linux-arch , Linux-MM , "kernel-hardening@lists.openwall.com" On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f72.google.com (mail-lf0-f72.google.com [209.85.215.72]) by kanga.kvack.org (Postfix) with ESMTP id 32F986B025E for ; Thu, 7 Jul 2016 13:27:06 -0400 (EDT) Received: by mail-lf0-f72.google.com with SMTP id a4so15286655lfa.1 for ; Thu, 07 Jul 2016 10:27:06 -0700 (PDT) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com. [2a00:1450:400c:c09::22b]) by mx.google.com with ESMTPS id 184si4354971wml.128.2016.07.07.10.27.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 10:27:04 -0700 (PDT) Received: by mail-wm0-x22b.google.com with SMTP id a66so40430358wme.0 for ; Thu, 07 Jul 2016 10:27:04 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <577E04FF.1090000@de.ibm.com> References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> From: Kees Cook Date: Thu, 7 Jul 2016 13:27:03 -0400 Message-ID: Subject: Re: [PATCH 0/9] mm: Hardened usercopy Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , "linux-arm-kernel@lists.infradead.org" , linux-ia64@vger.kernel.org, "linuxppc-dev@lists.ozlabs.org" , sparclinux , linux-arch , Linux-MM , "kernel-hardening@lists.openwall.com" On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: keescook@chromium.org (Kees Cook) Date: Thu, 7 Jul 2016 13:27:03 -0400 Subject: [PATCH 0/9] mm: Hardened usercopy In-Reply-To: <577E04FF.1090000@de.ibm.com> References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security From mboxrd@z Thu Jan 1 00:00:00 1970 Reply-To: kernel-hardening@lists.openwall.com MIME-Version: 1.0 Sender: keescook@google.com In-Reply-To: <577E04FF.1090000@de.ibm.com> References: <1467843928-29351-1-git-send-email-keescook@chromium.org> <577E04FF.1090000@de.ibm.com> From: Kees Cook Date: Thu, 7 Jul 2016 13:27:03 -0400 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [kernel-hardening] Re: [PATCH 0/9] mm: Hardened usercopy To: Christian Borntraeger Cc: LKML , Rik van Riel , Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , "x86@kernel.org" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , "linux-arm-kernel@lists.infradead.org" , linux-ia64@vger.kernel.org, "linuxppc-dev@lists.ozlabs.org" , sparclinux , linux-arch , Linux-MM , "kernel-hardening@lists.openwall.com" List-ID: On Thu, Jul 7, 2016 at 3:30 AM, Christian Borntraeger wrote: > On 07/07/2016 12:25 AM, Kees Cook wrote: >> Hi, >> >> This is a start of the mainline port of PAX_USERCOPY[1]. After I started >> writing tests (now in lkdtm in -next) for Casey's earlier port[2], I >> kept tweaking things further and further until I ended up with a whole >> new patch series. To that end, I took Rik's feedback and made a number >> of other changes and clean-ups as well. >> >> Based on my understanding, PAX_USERCOPY was designed to catch a few >> classes of flaws around the use of copy_to_user()/copy_from_user(). These >> changes don't touch get_user() and put_user(), since these operate on >> constant sized lengths, and tend to be much less vulnerable. There >> are effectively three distinct protections in the whole series, >> each of which I've given a separate CONFIG, though this patch set is >> only the first of the three intended protections. (Generally speaking, >> PAX_USERCOPY covers what I'm calling CONFIG_HARDENED_USERCOPY (this) and >> CONFIG_HARDENED_USERCOPY_WHITELIST (future), and PAX_USERCOPY_SLABS covers >> CONFIG_HARDENED_USERCOPY_SPLIT_KMALLOC (future).) >> >> This series, which adds CONFIG_HARDENED_USERCOPY, checks that objects >> being copied to/from userspace meet certain criteria: >> - if address is a heap object, the size must not exceed the object's >> allocated size. (This will catch all kinds of heap overflow flaws.) >> - if address range is in the current process stack, it must be within the >> current stack frame (if such checking is possible) or at least entirely >> within the current process's stack. (This could catch large lengths that >> would have extended beyond the current process stack, or overflows if >> their length extends back into the original stack.) >> - if the address range is part of kernel data, rodata, or bss, allow it. >> - if address range is page-allocated, that it doesn't span multiple >> allocations. >> - if address is within the kernel text, reject it. >> - everything else is accepted >> >> The patches in the series are: >> - The core copy_to/from_user() checks, without the slab object checks: >> 1- mm: Hardened usercopy >> - Per-arch enablement of the protection: >> 2- x86/uaccess: Enable hardened usercopy >> 3- ARM: uaccess: Enable hardened usercopy >> 4- arm64/uaccess: Enable hardened usercopy >> 5- ia64/uaccess: Enable hardened usercopy >> 6- powerpc/uaccess: Enable hardened usercopy >> 7- sparc/uaccess: Enable hardened usercopy > > Was there a reason why you did not change s390? No reason -- just didn't have a good build setup for testing it. (Everything but arm64 was already in grsecurity, and I was able to build-test arm64 when I added it there.) I would love to include s390 too! -Kees -- Kees Cook Chrome OS & Brillo Security