Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2829682pxb; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyl32szuSXgKvrbacr5QQ56+Wb8+OV+gXYvcJ4QPM246SwbIbPJq12b+zWAhyTTLniRKKf X-Received: by 2002:a17:907:10d8:: with SMTP id rv24mr23932990ejb.542.1618870911294; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618870911; cv=none; d=google.com; s=arc-20160816; b=BpCEL6i0roLbsJjoMuGJw9D6GBrB1s+EL+coWEoaVtApSoYL7etAm8gF/Kg3WioCGL E9NqT2MyECwELa6+bIJKk9Yee7dLm4XQ/WFCppeGwo8Z9Ib+dQzCN5aUF9DXhOWMPJbS P4PiDw78pZhj70rrz5wH5JTy79hNr5+xEMKPmo/V98XH5I+Nmh6REdjtwvE4FzlaWhWz rNOZ/54BawYN8n4H1P4OudCqGjaLuBjvkQm52b15jYSU3mv8Vy3IHg3oAMPm0xJ7YWqF tlkc/cUxEWxwkAAWEENnpVq/rj3LAOs4tJLNHypHGfwrnpb5FusnZSOO+nQm4C2ZdA9M H06w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TvQSC5X9vTcZkOP66NgOg7owX0RHKHn1QOU7Yzx0kPQ=; b=Qr+01NSViyjbV8GHAe0bWeMZSDpXA01ED8YUVeN+EOwuyAqhjsI9euzp5CawAXcVh3 GxPPyTyXohjbmpCJzD3c+YDdBLjuu29cuQD0X3MGUDLbJTE6JT5mjsfx032AKzdi4fha Z9s++ZYfzram26FNpnQayujY3WV2/4OtHWRdg4JIadw53CQ1JyIZR6TG7+ht9bYsEbKx KbpwWEu2Rg8Leg6NtcHA7H6RxRr1xLGF/OUrMqcbexPBY3y/stJe8oB67csackOV7f6K teaE03dunUqkXVWkVmW+IfdpFdxN15q9OUZL9HiOqEiqIqV11TaZLzQFjcQuSRl+wiCt /qFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sm/u6upV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x24si13344324ejj.149.2021.04.19.15.21.28; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sm/u6upV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242757AbhDSUpc (ORCPT + 99 others); Mon, 19 Apr 2021 16:45:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242460AbhDSUol (ORCPT ); Mon, 19 Apr 2021 16:44:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61DE161369; Mon, 19 Apr 2021 20:44:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618865051; bh=jqlxbD4jWz55BNOzhYL6VinJOSoZoV0z2NCOXkKdtbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sm/u6upV7HRUoTywn5TR61478q5WtmBO79io+hUwpQUE0kdaFymSRYn0o1+bUUr1U XsdkbEagLTkKKmdUyCnJ3LteBT3stJOgbVoc28vVTavUYd1ZcHnQ9E/fQ23/7m61g1 diuPe/T3M2r4NdvqtpppGoUCEKS2tZEqdZfCbiTcQHjwLO06b0Vm1hyUk8tTFCVkZ3 gdHb6f+Kz1pXstlg/lqVD34PSwH+k7Q7XdTdPLrRD766915ACHAS494lv7MB6b14i0 V5pvp4Zz8xyPa3vfZpTPqADLefRLYEm/0sJ5zzDA7COUAjirJWuIiWNXSXcgZCotVu eaSAjOcw3WqQA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Marco Elver , Andrey Konovalov , Masahiro Yamada , Michal Marek , Andrey Ryabinin , Nathan Chancellor , Nick Desaulniers , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Linus Torvalds , Sasha Levin , linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.11 18/23] kasan: fix hwasan build for gcc Date: Mon, 19 Apr 2021 16:43:37 -0400 Message-Id: <20210419204343.6134-18-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419204343.6134-1-sashal@kernel.org> References: <20210419204343.6134-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit 5c595ac4c776c44b5c59de22ab43b3fe256d9fbb ] gcc-11 adds support for -fsanitize=kernel-hwaddress, so it becomes possible to enable CONFIG_KASAN_SW_TAGS. Unfortunately this fails to build at the moment, because the corresponding command line arguments use llvm specific syntax. Change it to use the cc-param macro instead, which works on both clang and gcc. [elver@google.com: fixup for "kasan: fix hwasan build for gcc"] Link: https://lkml.kernel.org/r/YHQZVfVVLE/LDK2v@elver.google.com Link: https://lkml.kernel.org/r/20210323124112.1229772-1-arnd@kernel.org Signed-off-by: Arnd Bergmann Signed-off-by: Marco Elver Reviewed-by: Marco Elver Acked-by: Andrey Konovalov Cc: Masahiro Yamada Cc: Michal Marek Cc: Andrey Ryabinin Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Alexander Potapenko Cc: Dmitry Vyukov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- scripts/Makefile.kasan | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 1e000cc2e7b4..127012f45166 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -2,6 +2,8 @@ CFLAGS_KASAN_NOSANITIZE := -fno-builtin KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET) +cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1))) + ifdef CONFIG_KASAN_GENERIC ifdef CONFIG_KASAN_INLINE @@ -12,8 +14,6 @@ endif CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address -cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1))) - # -fasan-shadow-offset fails without -fsanitize CFLAGS_KASAN_SHADOW := $(call cc-option, -fsanitize=kernel-address \ -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET), \ @@ -36,14 +36,14 @@ endif # CONFIG_KASAN_GENERIC ifdef CONFIG_KASAN_SW_TAGS ifdef CONFIG_KASAN_INLINE - instrumentation_flags := -mllvm -hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET) + instrumentation_flags := $(call cc-param,hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET)) else - instrumentation_flags := -mllvm -hwasan-instrument-with-calls=1 + instrumentation_flags := $(call cc-param,hwasan-instrument-with-calls=1) endif CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ - -mllvm -hwasan-instrument-stack=$(CONFIG_KASAN_STACK) \ - -mllvm -hwasan-use-short-granules=0 \ + $(call cc-param,hwasan-instrument-stack=$(CONFIG_KASAN_STACK)) \ + $(call cc-param,hwasan-use-short-granules=0) \ $(instrumentation_flags) endif # CONFIG_KASAN_SW_TAGS -- 2.30.2