From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbdHJRcZ (ORCPT ); Thu, 10 Aug 2017 13:32:25 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:36558 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559AbdHJRcY (ORCPT ); Thu, 10 Aug 2017 13:32:24 -0400 MIME-Version: 1.0 In-Reply-To: <28ab1c38-f8a7-3fca-7a5a-e44248bec69f@imgtec.com> References: <1502195022-18161-1-git-send-email-matt.redfearn@imgtec.com> <28ab1c38-f8a7-3fca-7a5a-e44248bec69f@imgtec.com> From: Kees Cook Date: Thu, 10 Aug 2017 10:32:22 -0700 X-Google-Sender-Auth: vjUkHbGzi7f2w_4Jh_dSdO48D7o Message-ID: Subject: Re: [PATCH] MIPS: usercopy: Implement stack frame object validation To: Matt Redfearn Cc: Ralf Baechle , Linux MIPS Mailing List , "kernel-hardening@lists.openwall.com" , LKML , James Hogan , Paul Burton , Josh Poimboeuf 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, Aug 10, 2017 at 1:24 AM, Matt Redfearn wrote: > Hi Kees, > > > On 08/08/17 20:11, Kees Cook wrote: >> >> On Tue, Aug 8, 2017 at 5:23 AM, Matt Redfearn >> wrote: >>> >>> This implements arch_within_stack_frames() for MIPS that validates if an >>> object is wholly contained by a kernel stack frame. >>> >>> With CONFIG_HARDENED_USERCOPY enabled, MIPS now passes the LKDTM tests >>> USERCOPY_STACK_FRAME_TO, USERCOPY_STACK_FRAME_FROM and >>> USERCOPY_STACK_BEYOND on a Creator Ci40. >>> >>> Since the MIPS kernel does not use frame pointers, we re-use the MIPS >>> kernels stack frame unwinder which uses instruction inspection to deduce >>> the stack frame size. As such it introduces a larger performance penalty >>> than on arches which use the frame pointer. >> >> Hmm, given x86's plans to drop the frame pointer, I wonder if the >> inter-frame checking code should be gated by a CONFIG. This (3%) is a >> rather high performance hit to take for a relatively small protection >> (it's mainly about catching too-large-reads, since most >> too-large-writes will be caught by the stack canary). >> >> What do you think? > > > If x86 is going to move to a more expensive stack unwinding method than the > frame pointer then I guess it may end up seeing a similar performance hit to > what we see on MIPS. In that case it might make sense to add a CONFIG for > this such that only those who wish to make the trade off of performance for > the added protection need enable it. Sounds good. Can you send a v2 that adds a CONFIG, maybe something like CONFIG_HARDENED_USERCOPY_UNWINDER with a description of the trade-offs? Then x86 can do this too when it drops frame pointers. Thanks! -Kees -- Kees Cook Pixel Security