From patchwork Wed Dec 9 10:01:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Vyukov X-Patchwork-Id: 11961041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3565EC4361B for ; Wed, 9 Dec 2020 10:01:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C6ED323B6B for ; Wed, 9 Dec 2020 10:01:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6ED323B6B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F002D6B00D6; Wed, 9 Dec 2020 05:01:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB0FA6B00D7; Wed, 9 Dec 2020 05:01:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC5F76B00D8; Wed, 9 Dec 2020 05:01:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id C63FF6B00D6 for ; Wed, 9 Dec 2020 05:01:57 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 964BA12D2 for ; Wed, 9 Dec 2020 10:01:57 +0000 (UTC) X-FDA: 77573302674.16.swing96_610a69b273ee Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 87044100E691F for ; Wed, 9 Dec 2020 10:01:57 +0000 (UTC) X-HE-Tag: swing96_610a69b273ee X-Filterd-Recvd-Size: 4255 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 10:01:57 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id c25so648161qko.19 for ; Wed, 09 Dec 2020 02:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=tU0bH/ZopN0B+Ye8Q+EH0DzWrhlff2/lJmGr/Ir10cg=; b=jbjrQ7nKnTCEa9Q/zsYxYG1cRke4B6Nx3Kj8ebj1UTdl+dpvUQOXTDtZQ4g5Rt5lxF F1MEfFGvmfBY9nWVV9+kQqW1hfvZTLaVfrLi86O5MjUzEFQqFCi3SJ4CDN8VcE8M6ZFC oHN/xghGYIv4xgC+ZMCS98O2IF16MXznMrlI49mPJ+CoJ535BnDRRf1MfJjo0IIx2YoF 9Ec5G0CfRG6MuNu8x7WW9hTeGt/xpH7PH36J/Mv35Jlmyj4geDvi44v3yJwgoDnJr2Zn YEaY12kVpBFLJflIBcKbF1Us1T4EUdkVo6YJVRTLK6WRhajTs3d2aUnPI+eJsHxY/hW/ 5wmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=tU0bH/ZopN0B+Ye8Q+EH0DzWrhlff2/lJmGr/Ir10cg=; b=qQ3NkzIGVgiAlh8zsZxQZ4b/N950ljdUkZiEupsFfSwqQPZM8TkrbOQQh5kpSTEQfy C+ng39Yf1ix61g+z+4nGBZzaUyBETY2J83St2zoQ1mJlTTz96XTZDC895xKz1DHWFHBV Fa1xPgAdOSkQJY1KkNr+Ug0TvNdaMkdLsf/yl7Jo3y4/hoU5simCoe+16jNBq3FNk+qX 8R+wQ2bw2mIjsvS8CkTTeuiCCmm3hCTs0rD+WvmRZd34nNL80MntCmvJj9huU/Zo3fAs 3NWoc9ld7mPcgYMDQGbT85Nrw2EK1fA8yMwOcM4wU53Tw4nXbauA4KPCnoJAqgA+Fcxw noIQ== X-Gm-Message-State: AOAM5339pGox9Ez8FxkQQzVKYlWYBJbMzYLm8uk0spvLX6CXi0kMrUrc yfS6Ej6n+XDpXRGR5US1wOu1KuNNYN9x X-Google-Smtp-Source: ABdhPJz1ztB2YS7DZ6K0X7ovGKfEW5/GocUTsWl5sXT9phgWkOUSXmjUvJkOXtzSvjImYEGO22JvrhVTpalN X-Received: from dvyukov-desk.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:a2ec]) (user=dvyukov job=sendgmr) by 2002:ad4:4ee3:: with SMTP id dv3mr2224365qvb.58.1607508116142; Wed, 09 Dec 2020 02:01:56 -0800 (PST) Date: Wed, 9 Dec 2020 11:01:52 +0100 Message-Id: <20201209100152.2492072-1-dvyukov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH] kcov: don't instrument with UBSAN From: Dmitry Vyukov To: akpm@linux-foundation.org Cc: andreyknvl@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Dmitry Vyukov , Stephen Rothwell , Marco Elver X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Both KCOV and UBSAN use compiler instrumentation. If UBSAN detects a bug in KCOV, it may cause infinite recursion via printk and other common functions. We already don't instrument KCOV with KASAN/KCSAN for this reason, don't instrument it with UBSAN as well. As a side effect this also resolves the following gcc warning: conflicting types for built-in function '__sanitizer_cov_trace_switch'; expected 'void(long unsigned int, void *)' [-Wbuiltin-declaration-mismatch] It's only reported when kcov.c is compiled with any of the sanitizers enabled. Size of the arguments is correct, it's just that gcc uses 'long' on 64-bit arches and 'long long' on 32-bit arches, while kernel type is always 'long long'. Reported-by: Stephen Rothwell Suggested-by: Marco Elver Signed-off-by: Dmitry Vyukov Acked-by: Marco Elver Reviewed-by: Andrey Konovalov Reviewed-by: Kees Cook --- kernel/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/Makefile b/kernel/Makefile index aac15aeb9d69..efa42857532b 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -34,8 +34,11 @@ KCOV_INSTRUMENT_extable.o := n KCOV_INSTRUMENT_stacktrace.o := n # Don't self-instrument. KCOV_INSTRUMENT_kcov.o := n +# If sanitizers detect any issues in kcov, it may lead to recursion +# via printk, etc. KASAN_SANITIZE_kcov.o := n KCSAN_SANITIZE_kcov.o := n +UBSAN_SANITIZE_kcov.o := n CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector obj-y += sched/