From patchwork Thu Jun 22 17:13:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 106223 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp231993qgd; Thu, 22 Jun 2017 10:14:58 -0700 (PDT) X-Received: by 10.99.168.5 with SMTP id o5mr3696610pgf.33.1498151698290; Thu, 22 Jun 2017 10:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498151698; cv=none; d=google.com; s=arc-20160816; b=Q9nIKxKkL29lqu7G3HZFQi7/DEixI7jTRRRw5+GuezL53wrPcNRxae61Oaf5xmiKxE ybub30Zq6YjYdm58PmGSngvmNJN2N5VwsWD44qoFE6poTDYKVztuQUKDxTDKn3/uxxU8 J3G7LkiLulqzg2b9PclWcbiUvJqtg+IKB0kBgf+XWS55qCbvrR2ZTJhHUvdIgUis2mjh 3lWxcgOxJidSxd3GxqB5u6hzhoo+45Ux3vZ8Oar1dO3og/r9ltjt+ApVwA8lerHa2bEV L0D2PonlOiZC0KeIeV7n4l/arVEMEzPIORNCUC9dQsxn+SlanjhF9TUP/0TeBGnq90fW ekhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=PeT1huAZA6jUkFre6f8WF/gyFKq0psj5/B64vZdeaNY=; b=oktse8g4ToHy38jA1UvaUX3ulQRVZYPwOlllgAvdArEyqaMay3kI4/qslCad6IDQSN iDgQf1bbxyiAnfochdp1lnidZ9vnXvxzPNKeH3n0tMXBHERJAcm14VQD5kBrTjRN4J7q TEruZbgRAD7w4u73mPMPRZ6UsbL2qfHSGV4XhlzaXr6PW1AtBHutsi7fh1X6lPz215+g u/IKRTuG9j91r7qpN2JLSRlIpIUCHwKSf5vghFahrLum92nMp07IRtXEE/ymrNMCkfBJ evgm72AKmoPwrNRjLsl7lKwLzx2DHua2G0vnIdykHS7rkM19WN1BycUwHJ0uvin8joFp C3aQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i133si1530506pgc.544.2017.06.22.10.14.58; Thu, 22 Jun 2017 10:14:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbdFVROu (ORCPT + 25 others); Thu, 22 Jun 2017 13:14:50 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:57817 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753343AbdFVROr (ORCPT ); Thu, 22 Jun 2017 13:14:47 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MalH0-1d3f7816La-00KP9l; Thu, 22 Jun 2017 19:14:04 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Masahiro Yamada , Michal Marek , Kees Cook , Ingo Molnar , "David S . Miller" , linux-kbuild@vger.kernel.org, Samuel Thibault , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 01/11] compiler: introduce noinline_if_stackbloat annotation Date: Thu, 22 Jun 2017 19:13:45 +0200 Message-Id: <20170622171355.267192-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170622171355.267192-1-arnd@arndb.de> References: <20170622171355.267192-1-arnd@arndb.de> X-Provags-ID: V03:K0:+WjSpekZ+FakdXqmxAOHN3T2TVYJTDeaiDI8xrycc9xU67FRnLn Xq/c+T1z1H+7+k4tCF34E4uLlvO10f4qHbDuroQYrwU+z9ALpYSdbgUF1DuAVW5lukCWJ81 DzDwp5ndBEBv0ID0rFK3vngRWz9MUDwN/X3Zg85rIIg2M5d8GNiHnqZB1oT3my5R7tCmnH4 7bUMFDbtgKNdn4Xyxp0uw== X-UI-Out-Filterresults: notjunk:1; V01:K0:uq+IzDIduIs=:wzD/iAU967MSiHSUITO84m afQT1OGEi5LtmpYNun70ZPp6ZOFyTvyOwxLqs6Ja3s0bCHbt4DE5vv/q/H0L3zFQZq896L60N Ufu/RO7AO8fnbAxlf2dJVaXX0yjJUjZHkM/xI6C9GScJFPkx2sdIFnFh3FMUaCTCWsZiaKfLC YC6MFv6XtVQyjQ6zzBt4sa7SyIzr6/fT6o8shsMofPfGy2CJzaY2GjHqy6+QyGzwKwpQtZk0l O1QThbPMC0Av8HmiP/+bSgQLro/rYy758mw2Pf31Bc2dO19jzfBWlnuSQQEguP5NPH2X+nOKE AdEKVIbswqFVU38GbJ6tkWQ7PbqRYIPoyddwIU6exFVxCCwaKIoZiCYEcjQOGWCK4x0My9uaL 4p+c5mhHZMm3lv7CWdoef+zpSR2BWXjXQpkmsacyvwxsQJbR4cOsS7919nMLq7NdyynQsvEZu q7iCxOKFVsDbL1mT8dBHW4Gmpxho+1GyPxDYJA0Fo6ZofyxIpyPXwXdHMHYf/rAtWe0MuqC9y X8IQu8PlXhd64yUUQX/Px/AdjhqCOS7TYHz2mubTfGKgcVSS6sUsmdL+o/Ja+soWA9oqh14+/ ccRATJWzr+FhRG1Vtk8nb6qfCGMq+qBXJmJs4Prr2QAB6lRkZ0WtnzMICAEiSodkFw3sCWEyJ 8XWeiv3RlHrLn9YG0C6+vHgTnCOyeln4GOQ8DBNcUPUZLLV2guTVFsAx02WBmH++vzpY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.9.0 diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 219f82f3ec1a..a402c43c07d2 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -412,6 +412,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_if_stackbloat noinline __maybe_unused +#else +#define noinline_if_stackbloat inline +#endif + #ifndef __always_inline #define __always_inline inline #endif