Received: by 10.223.164.202 with SMTP id h10csp4897008wrb; Wed, 29 Nov 2017 13:52:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMZGCkei67bpMLtOSFuAp4rxQ9VWzbd+z81kNpcGS+9F42Yj4n6Yg7Ba+bjiw2H/qw3K00zu X-Received: by 10.159.198.148 with SMTP id g20mr292522plo.89.1511992350676; Wed, 29 Nov 2017 13:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511992350; cv=none; d=google.com; s=arc-20160816; b=DS9Qer5pY+snCTRkniZCrq69OEnqNXk2ZivQibw39kg1WpXWJSMarXPN6KTPEaoUtK hbgdIw9E/BBzDnefXqlhFLWWJsaaG3igGyLrbNcmckEHjyaIj1M5nJ3ogRcRFXNvc2Yy /7Aea/p90UYViZ1lZ/MdqhDHPvU9tbEiI4DYs0+nWfa/StLZQIVLbL9s2MTnmggWWj0M Zr2c/60HpLNjT0e9Hsx7wMfwB0P3bsJ/KTWsN5jHR1z1OYtqywOfdPi0V3YK2ZUR7iKI IoOezkOxUTs8+MUErL0vff5eTP17z38aRaRgpMKc5MV+Lq/ISWyB/vitHT9SJs/F3FFx tmIw== 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:dkim-signature:arc-authentication-results; bh=Pomumw/ITELzZjTsnI7OgZ7n+UugdyeOzD5aC4u6vvQ=; b=isU83oq//fXPQJHxzqBlFbd/HQMqMMI8XtBYmjh5e/I0jw+YGEqwshIibnUEWxNBNV 082b5jOmx/aFG333OgRIrVH+fTnfnoaFqE6ozwRKNFDQgnNxQLNgnz+AqMOnEjlew7mP bu5NoMXMAg+Zr3xIzqX6jfHYpxkT7Rt+3Z1oWPKwQY7kMFJdTyubn8y/KeVrF6gneXQX mThMK2p8PTCB0A90Kk757o4f1zZZ1a2w4vzocaFutGDKgcfiyf+pwP1+1x/KR2dt48Yi CAMGsbk4j5Rfxc9oj5CgOSoHSak/1qjQupaH23IGyVLU1IUBjf6w3BPq+wZ8fPxXhdir E8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A6R7Ohpo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si1944700pll.96.2017.11.29.13.52.16; Wed, 29 Nov 2017 13:52:30 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=A6R7Ohpo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbdK2Vvv (ORCPT + 99 others); Wed, 29 Nov 2017 16:51:51 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:32990 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbdK2VvV (ORCPT ); Wed, 29 Nov 2017 16:51:21 -0500 Received: by mail-it0-f65.google.com with SMTP id o130so27588928itg.0 for ; Wed, 29 Nov 2017 13:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pomumw/ITELzZjTsnI7OgZ7n+UugdyeOzD5aC4u6vvQ=; b=A6R7OhpoFp5yl9JWLdaOA7zmHiL6TQNW6+LtmJh+djHnNJbfqaxCxrJ2x60ANzYroq 7ppXIrfzgO8OdC4Nk4qDv8+RzPZ7XuB50xCfgTxeAL6IaKJ4rZLmVirK8Y4IJz0p3TXW jUEv4bJP5AEW+ylft1ua/cXxKZxS/I+eL9SnC8YpK+z5/Qtg4j9H1p1MYjWnLApI8RfV nVy7HtmIBLa70xEjzuUQ+/rNhqNGmB+mdKUeDqZHZ8jcOhhteQXaG8GHVkiWJW4d6g8E ZzfRsv5J7XnSPN/yO0PVhF2kAUjKoNAWf82c0sMl2dOAQKeyiV3IRFUaicNiG1i4AU3Q RPLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pomumw/ITELzZjTsnI7OgZ7n+UugdyeOzD5aC4u6vvQ=; b=KgoGCunFaSOTBSCMbI0MdKFOaJlLznKiKyejbSTkxemPg0V1Gl0GQNZjbsWn3Xovx5 Q4aAaIneDUUEDRAqZHUBxmz4K8mgn7WyPBOnaiMUCVYVwmVZLEw+h95ZmpN7SCoPoVGq zcqf2YhL0B5DMnXY8Fbq4zKtaIlZA4SvCrgIX4/f3TowPnz41L79RD+mkRPm7qpYnEFg nkgUxF9fTBJCV07JvMriX1YZpDIkjS3pbcQ7F70+TWycbi8mRcZNaIzDhDGGCoEetWkv HSywxM7GBMZP8Y0wC+00eT3fs2dkfXTFDPt9Y0LF7YQliLTtGqc6TZafclhIGDm4gIbM Tgrg== X-Gm-Message-State: AJaThX7qnpiO4UJTfOGghV+FNhM3u8kVcZgbvaFkLL4CQqjxdb3Ckb8v 3YYdIf93E2SdiDE76ruBFSikiQ== X-Received: by 10.36.6.5 with SMTP id 5mr395434itv.50.1511992280730; Wed, 29 Nov 2017 13:51:20 -0800 (PST) Received: from paullawrence.mtv.corp.google.com ([172.22.120.84]) by smtp.gmail.com with ESMTPSA id x72sm1438438ite.43.2017.11.29.13.51.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 13:51:20 -0800 (PST) From: Paul Lawrence To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kbuild@vger.kernel.org, Matthias Kaehlcke , Michael Davidson , Greg Hackmann , Paul Lawrence Subject: [PATCH v2 4/5] kasan: support LLVM-style asan parameters Date: Wed, 29 Nov 2017 13:50:49 -0800 Message-Id: <20171129215050.158653-5-paullawrence@google.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171129215050.158653-1-paullawrence@google.com> References: <20171129215050.158653-1-paullawrence@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use cc-option to figure out whether the compiler's sanitizer uses LLVM-style parameters ("-mllvm -asan-foo=bar") or GCC-style parameters ("--param asan-foo=bar"). Signed-off-by: Greg Hackmann Signed-off-by: Paul Lawrence --- scripts/Makefile.kasan | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 1ce7115aa499..89c5b166adec 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -10,24 +10,39 @@ KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET) CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address -CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \ - -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET) \ - --param asan-stack=1 --param asan-globals=1 \ - --param asan-instrumentation-with-call-threshold=$(call_threshold)) - ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) ifneq ($(CONFIG_COMPILE_TEST),y) $(warning Cannot use CONFIG_KASAN: \ -fsanitize=kernel-address is not supported by compiler) endif else - ifeq ($(CFLAGS_KASAN),) - ifneq ($(CONFIG_COMPILE_TEST),y) - $(warning CONFIG_KASAN: compiler does not support all options.\ - Trying minimal configuration) - endif - CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) - endif + # -fasan-shadow-offset fails without -fsanitize + CFLAGS_KASAN_SHADOW := \ + $(call cc-option, -fsanitize=kernel-address \ + -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET)) + ifeq ($(CFLAGS_KASAN_SHADOW),) + CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) + else + CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) + endif + + # Now add all the compiler specific options that are valid standalone + CFLAGS_KASAN := $(CFLAGS_KASAN) \ + $(call cc-option, --param asan-globals=1) \ + $(call cc-option, --param asan-instrument-allocas=1) \ + $(call cc-option, --param asan-instrumentation-with-call-threshold=$(call_threshold)) \ + $(call cc-option, -mllvm -asan-mapping-offset=$(KASAN_SHADOW_OFFSET)) \ + $(call cc-option, -mllvm -asan-stack=1) \ + $(call cc-option, -mllvm -asan-globals=1) \ + $(call cc-option, -mllvm -asan-use-after-scope=1) \ + $(call cc-option, -mllvm -asan-instrumentation-with-call-threshold=$(call_threshold)) + + + # This option crashes on gcc 4.9, and is not available on clang + ifeq ($(call cc-ifversion, -ge, 0500, y), y) + CFLAGS_KASAN := $(CFLAGS_KASAN) $(call cc-option, --param asan-stack=1) + endif + endif CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope) -- 2.15.0.531.g2ccb3012c9-goog From 1585530481787524116@xxx Thu Nov 30 22:08:18 +0000 2017 X-GM-THRID: 1585528752661718394 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread