From patchwork Fri May 5 10:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 9713397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1ED8B60362 for ; Fri, 5 May 2017 10:53:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C1526E54 for ; Fri, 5 May 2017 10:53:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F28C52869A; Fri, 5 May 2017 10:53:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id ECCF926E54 for ; Fri, 5 May 2017 10:53:31 +0000 (UTC) Received: (qmail 13936 invoked by uid 550); 5 May 2017 10:53:30 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 13912 invoked from network); 5 May 2017 10:53:29 -0000 Date: Fri, 5 May 2017 11:52:47 +0100 From: Mark Rutland To: Daniel Micay Cc: Kees Cook , kernel-hardening@lists.openwall.com, ard.biesheuvel@linaro.org, matt@codeblueprint.co.uk Message-ID: <20170505105247.GC699@leverpostej> References: <20170504142435.10175-1-danielmicay@gmail.com> <20170504154850.GE20461@leverpostej> <1493920184.1596.4.camel@gmail.com> <20170504180917.GB19929@leverpostej> <20170505103839.GB699@leverpostej> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170505103839.GB699@leverpostej> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [kernel-hardening] [PATCH] add the option of fortified string.h functions X-Virus-Scanned: ClamAV using ClamSMTP On Fri, May 05, 2017 at 11:38:39AM +0100, Mark Rutland wrote: > On Thu, May 04, 2017 at 07:09:17PM +0100, Mark Rutland wrote: > From a walk up the call chain, I saw mm/kasan/kasan.c's memcpy was being > called recursively. Somehow the fortified memcpy() instrumentation > results in kasan's memcpy() calling itself rather than __memcpy(). > > The resulting stack overflow ends up clobbering the vectors (adn > everythigg else) as this is happening early at boot when everything is > mapepd RW. > > That can be avoided with: > > ---->8---- > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index f742596..b5327f5 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -18,7 +18,8 @@ cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt > > KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ > $(call cc-option,-ffreestanding) \ > - $(call cc-option,-fno-stack-protector) > + $(call cc-option,-fno-stack-protector) \ > + -D__NO_FORTIFY > > GCOV_PROFILE := n > KASAN_SANITIZE := n > ---->8---- Whoops; wrong diff. That should have been: ---->8---- ---->8---- Thanks, Mark. diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile index 2976a9e..747423b 100644 --- a/mm/kasan/Makefile +++ b/mm/kasan/Makefile @@ -5,6 +5,7 @@ KCOV_INSTRUMENT := n CFLAGS_REMOVE_kasan.o = -pg # Function splitter causes unnecessary splits in __asan_load1/__asan_store1 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533 -CFLAGS_kasan.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) +CFLAGS_kasan.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) \ + -D__NO_FORTIFY obj-y := kasan.o report.o kasan_init.o quarantine.o