From patchwork Wed Jul 3 20:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168441 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1373257ilk; Wed, 3 Jul 2019 13:56:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjsl+2+lqguJz9zh//jQVXkFmd2I+B3x9m/dQQF4xI4qSyfsOO9fNtOEdeQwpbGgaFB7Zh X-Received: by 2002:a63:2ad5:: with SMTP id q204mr39564187pgq.140.1562187391143; Wed, 03 Jul 2019 13:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562187391; cv=none; d=google.com; s=arc-20160816; b=0yZBhFMZXg663B5JD77u33dkzj5Q+rryj5JB6TYuJT55mlxrQdiom87lOrkH+9jsWd rhW5nZYVhgMQt35tImuYkULK+wydOQTdbxGgzebBgUSRydXf0qlcZuJkWlLVcm0tah0f 4cJCJMMnuZkp1O9+Xrf7ZnYYcvuvY4b8qtomi/gaTR31Vo9qtDHKAIk8FB4ORy7F06To r6jUUDGnb1v+ss8X9gfDmwhhrU8CyDGhklqnFc/oFX1iYVdNVztDVkF2p3YAMdeH2gzD CXj95PTndGY0Hc8lx0hBkXnpe+WM2PUm4wSOWFO1sCpxiA0xopR+QbF0HO2m6qm54wyZ coDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OtpgfvAyzmDa6+kr7jhqubHmTmGSXxzmZ/gclzKmhEg=; b=nw7VoyxfcX4CbmB37v+awjH8eiU4ihRbD/X6GPcibHpLqyP7Z+iGM/a4fGU4ybq1WS rEroqyQif6OauoqaK/RK5XDxz+pHp6chl+a7tO8K6CJ5zIZSwoFoIoOZyhLCFj5WL43U ODpiWtAXn3+mKko8staBxX1kuEdDJ+gG/pV7QGz/syR2Tx6A71MRK7rJCDHFTBDdY4E3 LluQmRUDq+tf+rf8Xw1SLsn1GaTCJMJUqpmUW/DtippYNTj5bINTUmvQ3zUM9uvscUxE gMZ9lIXbP1EsNuUvC7wUecj/A4PWmE8X3ch+6XF0Wux/WbyBA7U6i3214ScaZaU9Wkj0 zvFw== 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 i17si2951816pju.96.2019.07.03.13.56.30; Wed, 03 Jul 2019 13:56:31 -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 S1727310AbfGCU4a (ORCPT + 30 others); Wed, 3 Jul 2019 16:56:30 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:44615 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfGCU41 (ORCPT ); Wed, 3 Jul 2019 16:56:27 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MqbDs-1iMWxP2do8-00masw; Wed, 03 Jul 2019 22:56:03 +0200 From: Arnd Bergmann To: Florian Fainelli , Andrey Ryabinin Cc: Abbott Liu , linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com, Linus Walleij , Arnd Bergmann , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek , Andrew Morton , Andrey Konovalov , Will Deacon , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH 2/3] kasan: disable CONFIG_KASAN_STACK with clang on arm32 Date: Wed, 3 Jul 2019 22:54:37 +0200 Message-Id: <20190703205527.955320-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190703205527.955320-1-arnd@arndb.de> References: <20190703205527.955320-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dVu6TB6bK7PiXC0nWCBWTtH4+VmEpXav81wxunH7qxb9O8LK6xY 9t1OBqgcoNKISokDJOGEmpsK9Olw4WiYxv3R4Yk0VHCPHCwbE5CfGGDvCGKORzYaTcZzpMZ m0fJ4OWUu8fhsgmIFep0j6SXmG5L3NTwAgbpxGDx8Qj04BISYNu2I01zggQ4J9AyAUBAt5n camESeoPyJjNiAUdUlgtA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:BtQ+/a+4hxk=:BXsO/jIoni0w1uZ5xMb/V6 h3BmSvC14FIsrbv1u2lvwtgR132tDDF864k1Mm0/o1613vabZUA4IFS/P8E4jRRI6wzptV5lM jniEHTkB7qHeV/3lCntpeY7GYB4gr9Vvv+AKKRatXz3x21fZBGm2/fGSYXAXY+ZYcmSlQRb0Z 3uc+P/LLZG12LdSV4N+0Jdl/ijlnTXia0VndfpbgkK0UMbzs9GaMSjIuFE72esecJiyh9QXlC jNr2Bequ/b5BgqDk6YfU+QnZsfElwGyaURabVnt6B5C4Ohxqk07JXMFYf1RDOphcRy1RG3a7g cX1kSgnBkWa6c7lXaA5Hp4HJ+c0RNNy3WS5G15hdnR29brBeN7LGOMTBv+bUvZj2fKB9A8rcd xDU4aHuOfToN3Mi0jKRBJbkqfK4pL2GQiLvrctVa9OboD57iyUbUJJQxSc64DPWyyv/TwAWg+ 4rlCQYskxhnYiA1upHe0T38dZpE4V+pDZ9UUdpPEEC+JaKy0Z7hPP3gDh8UQUk7wDeMlx43Ma Nj2f2RvuW0zBufN7CCC1gzXZZ7yj6LKcva/a4KeZ+T9LAHp/QTc4vBkJmaBeQePNHF7pDF9ty lgByqBiJ5vNeyY0IYOTYOX5SjHBdj73WL+AOjE6+yMAAfu05z4cLAPM2ewhkYRfsv/UNbfGFL 1jdoMMETbefmQEsOxl2/ok8E/gLyIPPUwGrnjqGFE8jZCT2/J0FOdGzP9k7kfPWx7NIPnmgMn vIN90lJ0ZDhmHtW8bJnYoKFXqd3tUJdj5FcRRA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The CONFIG_KASAN_STACK symbol tells us whether we should be using the asan-stack=1 parameter. On clang-8, this causes explosive kernel stack frame growth, so it is currently disabled, hopefully to be turned back on when a future clang version is fixed. Examples include drivers/media/dvb-frontends/mb86a20s.c:1942:12: error: stack frame size of 4128 bytes in function drivers/net/wireless/atmel/atmel.c:1307:5: error: stack frame size of 4928 bytes in function 'atmel_open' drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c:1521:1: error: stack frame size of 5440 bytes in function drivers/media/i2c/mt9t112.c:670:12: error: stack frame size of 9344 bytes in function 'mt9t112_init_camera' drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c:185:12: error: stack frame size of 10048 bytes For the 32-bit ARM build, the logic I introduced earlier does not work because $(CFLAGS_KASAN_SHADOW) is empty, and we don't add those flags. Moving the asan-stack= parameter down fixes this. No idea of any of the other parameters should also be moved though. Signed-off-by: Arnd Bergmann --- scripts/Makefile.kasan | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.0 diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 6410bd22fe38..fc57fcf49722 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -26,10 +26,11 @@ else CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \ $(call cc-param,asan-globals=1) \ $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ - $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ $(call cc-param,asan-instrument-allocas=1) endif +CFLAGS_KASAN += $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) + endif # CONFIG_KASAN_GENERIC ifdef CONFIG_KASAN_SW_TAGS From patchwork Wed Jul 3 20:54:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168442 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1373509ilk; Wed, 3 Jul 2019 13:56:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhjyakomER2FiO53UGS4XP3qQ0mg+SwtijjsQccsnX6nZuFxStuukggoTjpqjW1BRN6MKL X-Received: by 2002:a63:211c:: with SMTP id h28mr26273570pgh.438.1562187415886; Wed, 03 Jul 2019 13:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562187415; cv=none; d=google.com; s=arc-20160816; b=xSfQISA1a20Y0sy0CiftIQiS6wc04nt9wfywpKRJmU/9XdwqLx65ZcTb/T3DopNtRP Wvn4YWR2dRJ8tCBO07dtfrjcl5mtlKYc4ymCYbI9A3cMqORHVkSmD6I3utHjPXDJJpFj /tKHB8YioY/b6wBlILG7eNEa75z6dKCvWPGEJTT9CRVxT7gN5tpqqQzA4FARRKV31g4q 5ZipCAzVs1Ae6cpzvWBP8cvrInlAaegf7159hF4cLEtvcxjrGPeHPLX8+Som2FBLAOXg 3/IG2yT20xoLV5c7HvYjaBJdBUjg++SUbNw/phCU4L1iUpgks9tHfziZjTDcBXIBndlh s/2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JedBINZKkb5BYE6srGTfrrpmyMp18YxFHWY1mJ8AZxM=; b=h8aBpLZixV/Rl42+k+yNtnHr3QozG8LIwlnH+rL2hWfclfjs8mWazNqYVj4YcxJsdC ooTSKj7H5Rm+NZ8DBaBVjycolYJoWQxxV3YjK+Sh0kwKuESoRis4GroYeR5hGcY+CN5D Ns3WQy+BvWD9jeDUa5a0t3aQYXJXDFAUz2hcjumCRt8skzjLHlrb+clzpH0nr3AeldbP DHUH+2nqO1Kt2JY4aooZqFbPnmMR5IA7mMnr70XWJauwLmgHPjy1cHxKY1hbgNY4Yf3I bG9EgLSKCP6N5aCUGqpRpiA5loRk3+dfMmIJnP0FDxf5asslhtK0vlGVbuGJickcbTVh ODpQ== 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 x24si2797871pjt.88.2019.07.03.13.56.55; Wed, 03 Jul 2019 13:56:55 -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 S1727350AbfGCU4y (ORCPT + 30 others); Wed, 3 Jul 2019 16:56:54 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:40747 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfGCU4y (ORCPT ); Wed, 3 Jul 2019 16:56:54 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MCbZL-1hrszW1Wi3-009fcz; Wed, 03 Jul 2019 22:56:37 +0200 From: Arnd Bergmann To: Florian Fainelli Cc: Andrey Ryabinin , Abbott Liu , linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com, Linus Walleij , Arnd Bergmann , Andrew Morton , Masahiro Yamada , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] kasan: increase 32-bit stack frame warning limit Date: Wed, 3 Jul 2019 22:54:38 +0200 Message-Id: <20190703205527.955320-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190703205527.955320-1-arnd@arndb.de> References: <20190703205527.955320-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:8pSJiH+6Agod8nzM29uheH50kgOrBaKHZzl6ndhrvPiQDTdiHui W5pteQ/meterbUyb16uPXBdh/bTTq2+X7Dk5d7PAcip6R5BCBPu9tNJQGkCbISINyzxc4E3 ufLi+uJnI/JUTqJcROzbiTnzXM5lLSFjTSMLV+q7duZFqGKVqJd+NvheDVswutkffm0UA2T TfDWqX7IhnITKKyiWsxrA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:3Ix8Jf1u9lw=:pjqfTjTFLOmjIDonH9fhGO mHR6MCXiiA+Fcqph4cAytscXm6iAv/rKcr/9/TiHbHVVsjckLsemrX4ckG9DSoruNNgcyJZU6 iOh8oppdJ0CmQLWMXd9XwgOkCOhnP9vSEcCbJv0xxPSh5jCSx9DuUzhZyzfxwQUQSPTD8ZZ2i t8FXl40rX/HMeA4I13WzDKH/5A2FNnIENm7M9rUTO700Bd7uTcBKAa7mlM+VdnwpaYWJ2RRtA WfqrTrQsGfObU4oOpKitmyB50dNiiNQMY56Dn6Dsh76mVyRlLUnc6QHQ4N0elrylTNwYj/ihI 61Ox5FaGZmJDnXmnGoFY2sD2hny0rzusVuk5DpRThYWLJ5aatwd+B3ce7oeeO9NJRExGDIni4 BHuWsm+m/eCraU0WPVTSM87vm1asD/ayohcM1+LdMTcoMzb9LlWx0ALq9MJu/CKgV9De8/3b9 d3/VN94DYA9jeePRDe7XPFDTNj2Tn+7KpCruJu15FS9qth6rpir7mcXY3UcNbIiiAW0gMe7w+ /OOpsa7lPMhg8f39gUMxhnjD6EufdR5k/B56MNvwwXPkkoRSgsJHf6gc9m7CmmxVLAsNOqOJm hN2h21mCFCGBXsyB5O/KCiZHxoEKeC65vGSjC034oyin5/vtkSzw+IjuYpdEELk2rIyJOnRgX zFxLbriBO8AJIvgkUiCOqFp7zMO5cjWvACRnImwP8b5VHSmDtbyQA6vmdcyt/fVyBlbr/1b48 GyzK0D05aGULm/4LZ3MsFTAW2SkdaJZmX220Qg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enabling kasan on 32-bit ARM introduces some new warnings in the allmodconfig build due to mildly increased kernel stack usage, even when asan-stack is disabled: fs/select.c:621:5: error: stack frame size of 1032 bytes in function 'core_sys_select' net/mac80211/mlme.c:4047:6: error: stack frame size of 1032 bytes in function 'ieee80211_sta_rx_queued_mgmt' drivers/infiniband/sw/rxe/rxe_req.c:583:5: error: stack frame size of 1152 bytes in function 'rxe_requester' fs/ubifs/replay.c:1193:5: error: stack frame size of 1152 bytes in function 'ubifs_replay_journal' drivers/mtd/chips/cfi_cmdset_0001.c:1868:12: error: stack frame size of 1104 bytes in function 'cfi_intelext_writev' drivers/ntb/hw/idt/ntb_hw_idt.c:1041:27: error: stack frame size of 1032 bytes in function 'idt_scan_mws' drivers/mtd/nftlcore.c:674:12: error: stack frame size of 1120 bytes in function 'nftl_writeblock' drivers/net/wireless/cisco/airo.c:3793:12: error: stack frame size of 1040 bytes in function 'setup_card' drivers/staging/fbtft/fbtft-core.c:989:5: error: stack frame size of 1232 bytes in function 'fbtft_init_display' drivers/staging/fbtft/fbtft-core.c:907:12: error: stack frame size of 1072 bytes in function 'fbtft_init_display_dt' drivers/staging/wlan-ng/cfg80211.c:272:12: error: stack frame size of 1040 bytes in function 'prism2_scan' Some of these are intentionally high, others are from sloppy coding practice and should perhaps be reduced a lot. For 64-bit, the limit is currently much higher at 2048 bytes, which does not cause many warnings and could even be reduced. Changing the limit to 1280 bytes with KASAN also takes care of all cases I see. If we go beyond that with KASAN, or over the normal 1024 byte limit without it, that is however something we should definitely address in the code. Signed-off-by: Arnd Bergmann --- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.0 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 6d2799190fba..41b0ae9d05d9 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -251,7 +251,7 @@ config FRAME_WARN int "Warn for stack frames larger than (needs gcc 4.4)" range 0 8192 default 2048 if GCC_PLUGIN_LATENT_ENTROPY - default 1280 if (!64BIT && PARISC) + default 1280 if (!64BIT && (PARISC || KASAN)) default 1024 if (!64BIT && !PARISC) default 2048 if 64BIT help