From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360AbdAPKXn (ORCPT ); Mon, 16 Jan 2017 05:23:43 -0500 Received: from ozlabs.org ([103.22.144.67]:47441 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbdAPKXm (ORCPT ); Mon, 16 Jan 2017 05:23:42 -0500 From: Michael Ellerman To: Arnd Bergmann , Kees Cook , Greg Kroah-Hartman Cc: Arnd Bergmann , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lkdtm: hide stack overflow warning for corrupt-stack test In-Reply-To: <20170111145711.810229-1-arnd@arndb.de> References: <20170111145711.810229-1-arnd@arndb.de> User-Agent: Notmuch/0.21 (https://notmuchmail.org) Date: Mon, 16 Jan 2017 21:23:35 +1100 Message-ID: <87inpfcnh4.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann writes: > After the latest change to make sure the compiler actually does a memset, > it is now smart enough to flag the stack overflow at compile time, > at least with gcc-7.0: > > drivers/misc/lkdtm_bugs.c: In function 'lkdtm_CORRUPT_STACK': > drivers/misc/lkdtm_bugs.c:88:144: warning: 'memset' writing 64 bytes into a region of size 8 overflows the destination [-Wstringop-overflow=] > > To outsmart the compiler again, this moves the memset into a noinline > function where (for now) it doesn't see that we intentionally write > broken code here. Heh, darn it. I suspect this is an arms race we are eventually going to lose. At some point we might have to switch to writing some of these in asm :/ cheers