Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4024713imj; Tue, 19 Feb 2019 13:52:10 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibqomn82CEmvqNrvUq4IxTKn57KiMvkrjOWEiAGxYN5Hwr33qWKp8WYketmfcPxYvXTjV2L X-Received: by 2002:a63:2117:: with SMTP id h23mr25796141pgh.375.1550613130177; Tue, 19 Feb 2019 13:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550613130; cv=none; d=google.com; s=arc-20160816; b=0pZNQoG4cRCckCIkl+fd1o0hRRtH58Et9epKDqpiMdch/z+Qtf83IdRPc3Og7TjhC0 LSzLFrIF5FSFKv9inoKZQxpqVQICMWPZur2us1Gspw6XI9gnuSWSZ/5ttb0/DtelEbpF J4pUApG7VOsLncPJUiJVk06SLu8av5b0ajfsgBRfQQyqM8+CLTdD7RIvouZMimsUorka fH6tfszrYrG524umyaEiVF70Hw8UeRXfsL9ke+hAYlGIqSLTzF/3pPvpIBmJfww9ox6D kdCKHC3A260371p0BTXq/Ae98jJ2wGmQKqYlz2mLR7xGIxZSGltsgHPpvWeJMv2ptPV1 46jA== 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 :message-id:date:subject:cc:to:from; bh=EfOv8NpIE2mJ6DRLwpocZiK8uXQQpugpkLQ07VTlKMU=; b=WGPvEu/Efv29N68fC0k1GR4X4sduxbHmjQ5konNz4WQt4Ii9RSDaqkV5j7PiAOcQSf a8s09ISJ+MgVKdY48L67CooRUVWE2wloKVH/Gap7X3yCykrD//8MW/xeMWafT13t1gfl fcR4lpQCftisdUzsHY4wK+e/Y5UZCI/pO8M34zfdOt98LnUZbS0S86UXMIi9Exj6DWPS rxET+FaeBL/U3RGlIEVtZUldNZcmqhRpMljGkL6ibnTZDTSibefPTpbnFAbQ7dTS8/+o nTr+GAiwZboXVNQIdMEGcfyfOSu7RbyZyOz/1QYWUBVDec8uTkYO5dENGOntjH527POO bjYA== 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 e3si17022226pfe.203.2019.02.19.13.51.54; Tue, 19 Feb 2019 13:52:10 -0800 (PST) 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 S1729391AbfBSVt6 (ORCPT + 99 others); Tue, 19 Feb 2019 16:49:58 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:50197 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbfBSVt6 (ORCPT ); Tue, 19 Feb 2019 16:49:58 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1M7KKA-1gxI8A0kgu-007mo4; Tue, 19 Feb 2019 22:49:42 +0100 From: Arnd Bergmann To: Andrey Ryabinin , Masahiro Yamada , Michal Marek , Andrew Morton Cc: Arnd Bergmann , Dmitry Vyukov , Nick Desaulniers , Mark Brown , Qian Cai , Alexander Potapenko , Martin Schwidefsky , Christoph Lameter , Andrey Konovalov , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH] kasan: turn off asan-stack for clang-8 and earlier Date: Tue, 19 Feb 2019 22:49:06 +0100 Message-Id: <20190219214940.391081-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 M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h73o8sVGWUykkmjSs5yRtGP2wlNa824DvygA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building an arm64 allmodconfig kernel with clang results in over 140 warnings about overly large stack frames, the worst ones being: drivers/gpu/drm/panel/panel-sitronix-st7789v.c:196:12: error: stack frame size of 20224 bytes in function 'st7789v_prepare' drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c:196:12: error: stack frame size of 13120 bytes in function 'td028ttec1_panel_enable' drivers/usb/host/max3421-hcd.c:1395:1: error: stack frame size of 10048 bytes in function 'max3421_spi_thread' drivers/net/wan/slic_ds26522.c:209:12: error: stack frame size of 9664 bytes in function 'slic_ds26522_probe' drivers/crypto/ccp/ccp-ops.c:2434:5: error: stack frame size of 8832 bytes in function 'ccp_run_cmd' drivers/media/dvb-frontends/stv0367.c:1005:12: error: stack frame size of 7840 bytes in function 'stv0367ter_algo' None of these happen with gcc today, and almost all of these are the result of a single known bug in llvm. Hopefully it will eventually get fixed with the clang-9 release. In the meantime, the best idea I have is to turn off asan-stack for clang-8 and earlier, so we can produce a kernel that is safe to run. I have posted three patches that address the frame overflow warnings that are not addressed by turning off asan-stack, so in combination with this change, we get much closer to a clean allmodconfig build, which in turn is necessary to do meaningful build regression testing. Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Nick Desaulniers Cc: Mark Brown Cc: Qian Cai Link: https://bugs.llvm.org/show_bug.cgi?id=38809 Signed-off-by: Arnd Bergmann --- lib/Kconfig.kasan | 13 +++++++++++++ scripts/Makefile.kasan | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 67d7d1309c52..219cddc913ac 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -103,6 +103,19 @@ config KASAN_INLINE endchoice +config KASAN_STACK + int + default 0 if CC_IS_CLANG && (CLANG_VERSION < 90000) + default 1 + help + The LLVM stack address sanitizer has a know bug that + causes excessive stack usage in a lot of functions, see + https://bugs.llvm.org/show_bug.cgi?id=38809 + Disabling asan-stack makes it safe to run kernels build + with clang-8 with KASAN enabled, though it loses some of + the functionality. We assume that clang-9 will have a fix, + so the feature can be used. + config KASAN_S390_4_LEVEL_PAGING bool "KASan: use 4-level paging" depends on KASAN && S390 diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index f1fb8e502657..6410bd22fe38 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -26,7 +26,7 @@ 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=1) \ + $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ $(call cc-param,asan-instrument-allocas=1) endif -- 2.20.0