From patchwork Thu Mar 2 16:38:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9601045 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 8CDC560522 for ; Thu, 2 Mar 2017 17:12:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79452285BB for ; Thu, 2 Mar 2017 17:12:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67B2A27F94; Thu, 2 Mar 2017 17:12:31 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB72C285BB for ; Thu, 2 Mar 2017 17:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753852AbdCBRMQ (ORCPT ); Thu, 2 Mar 2017 12:12:16 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:61372 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754117AbdCBRLS (ORCPT ); Thu, 2 Mar 2017 12:11:18 -0500 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LtAB1-1cHnbA2iDb-012rVW; Thu, 02 Mar 2017 17:38:47 +0100 From: Arnd Bergmann To: kasan-dev@googlegroups.com Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-wireless@vger.kernel.org, kernel-build-reports@lists.linaro.org, "David S . Miller" , Arnd Bergmann Subject: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Date: Thu, 2 Mar 2017 17:38:09 +0100 Message-Id: <20170302163834.2273519-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170302163834.2273519-1-arnd@arndb.de> References: <20170302163834.2273519-1-arnd@arndb.de> X-Provags-ID: V03:K0:dTt3v1JAGlJI8AFD/Ved6I1K5tyuJacbpS8VYAhNyuUaMG362+l JBrY2X0WEhLmfvWZRyasWWJDW79PlIWo+qZvFWheyow/1UyxTeclDEU5lI96REiLQJcYgb8 EGFPQtwxUcydPK34LPbIzDpFqzCaOVrppGhMN/Fx3jkEOOmLrsp6EV8jyENzkhkJxpxUuR2 HWo1ay+DDXqtr0wLf9kqQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:tRjJx9T9dls=:E1Xf3Lbfw3PZ10a13QCKZv SyriuJ7+UiyfL91e0PBWtJyGkOgOUgFdBCbpVEPm/wEjGqG5gSF9mdyYxn/eXqqEWMDNKG3Vw GsjQauU8cPYC7bVNmVWbn1kDRIv1MlSAQvXNbTtWXwrsbTmJlXlp+fRVKR/mPc1n48xTR5X5x 3PJQLl3mTR2wM/eILiD5tcGmVcPyFa1uOvrQYjVDCnmgdTfFG7IkdvF6e+ABGjB26Nb6IG8+q 4ELcFALYI9tSgXCpxg4IcWDLbIhldKZh4aYBGBJLibwELjfWbLMVfkPXUhqzjD3KtX2GhULCa yIoUuE99z2hPZIdqseLbq5i9ChOzGBI6/Q93daHWWscAydqM4/kTmR1vh8sD4W3IDCz+3P940 CMYmsFdGsDMuFw46fkXaQNxkY55h2kOu0dC4DNMfNTi7q9CUFeqTc+UAzDbtIgwlsJeTnfrLz VFgvWL+S4RCH7oZnOGOl9h9KBf3CyKVBo+DHPaB5AlVbWf/bL6iHYxe1nvpJZdc5R2Lw5rIV2 gQPfPt84vDXIpnwf0lA8ySQpt3lO608e1DK8T03TTi/N5x+meWCa1uvfNR68O8nC+XwgDdmhZ 8PAhPOvjhi0jyqmI0e0ouedmnBiqwP/kGtgjEl449bHDwVEzhbMV/evRiVq46wpnwvuzeEuUG pmYH/udzzYhWCe2zPZDaypN4diVzqxDgoC9NT7Q1xvm3gGGGeOEvhs8z6ypbW6vsg/PA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When CONFIG_KASAN is set, we can run into some code that uses incredible amounts of kernel stack: drivers/staging/dgnc/dgnc_neo.c:1056:1: error: the frame size of 11112 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/media/i2c/cx25840/cx25840-core.c:4960:1: error: the frame size of 94000 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] This happens when a sanitizer uses stack memory each time an inline function gets called. This introduces a new annotation for those functions to make them either 'inline' or 'noinline' dependning on the CONFIG_KASAN symbol. Signed-off-by: Arnd Bergmann --- include/linux/compiler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index f8110051188f..56b90897a459 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -416,6 +416,17 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s */ #define noinline_for_stack noinline +/* + * CONFIG_KASAN can lead to extreme stack usage with certain patterns when + * one function gets inlined many times and each instance requires a stack + * ckeck. + */ +#ifdef CONFIG_KASAN +#define noinline_for_kasan noinline __maybe_unused +#else +#define noinline_for_kasan inline +#endif + #ifndef __always_inline #define __always_inline inline #endif