From patchwork Fri May 22 07:52:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11564897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8EAA913 for ; Fri, 22 May 2020 07:52:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96F612072C for ; Fri, 22 May 2020 07:52:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YyyrLMAu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96F612072C 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 C24C080008; Fri, 22 May 2020 03:52:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD50080007; Fri, 22 May 2020 03:52:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B11CE80008; Fri, 22 May 2020 03:52:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 9856A80007 for ; Fri, 22 May 2020 03:52:24 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5744E180AD81D for ; Fri, 22 May 2020 07:52:24 +0000 (UTC) X-FDA: 76843587408.19.beast09_895f924fd195d X-Spam-Summary: 10,1,0,5c27ad6d45d2245e,d41d8cd98f00b204,3t4thxgukcnoahranckkcha.8kihejqt-iigr68g.knc@flex--elver.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:967:968:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2380:2393:2525:2553:2559:2564:2682:2685:2859:2902:2904:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3152:3354:3865:3867:3868:3870:3871:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4250:4321:5007:6119:6261:6653:8660:9025:9969:10004:10400:11026:11473:11658:11914:12043:12296:12297:12438:12555:12679:12694:12698:12737:12895:12986:13148:13149:13221:13229:13230:14096:14097:14157:14181:14394:14659:14721:21080:21444:21451:21627:21811:21939:30054:30064:30090,0,RBL:209.85.219.74:@flex--elver.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Cust om_rules X-HE-Tag: beast09_895f924fd195d X-Filterd-Recvd-Size: 6127 Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 May 2020 07:52:23 +0000 (UTC) Received: by mail-qv1-f74.google.com with SMTP id q10so9907577qvs.16 for ; Fri, 22 May 2020 00:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=V3kv+xBmjrIeYzeByZn2jZ0q0fngGgBM343mBftKcUc=; b=YyyrLMAuNFxnPyLpcPTr6sz5EROrTRmWUbKvuXv+P9s7/RgUmBoTYNOBB6CHRgCzwB 7dCe/3nenT/OHaMlqB+tioLHT7G9nHkN7WZ95TRdnJ+8JcnhZyzUYuxF760OlxfgQOwr S8SSAgObJcLoQfvFkDMAayvzByzwmlkj11yndgkntXL8dt24bc5wA4CjHFfy+4mtMeRY POp3f/ReqWwACAbLP9Xdqk5l9JS9feCpGkPBEvqRuwaXxRV0hfE93gxXj0LF++CcGBxf xMNcUyxM+5j1kq+iwn7n+dvInijxFPfXhRGl1x6hxyibMnq8tBi75/F7P+JKfFxq9olI w5cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=V3kv+xBmjrIeYzeByZn2jZ0q0fngGgBM343mBftKcUc=; b=o3TCDEtMU9gWGyjyvRDtCi483xEgqK7a5CqCKVjk5BG8bMal41UhGikkMfxDB7Nf3I N5SPLeLl13iEKXdmyaiTLORJti7ZwyWH7REPTsdi+4VDVazw+gac4Dbn0vQWb+ZlPk3v i+QUOuW6CgDstlpfYvhlem3eSEvMbyJC6VQ1sPO6UwbAIvUm+GD9LsRJAAGtf0w2tLah q1+j6Uz0CZjO08OjS2xVv/an+cEGgz/9+dE2i8EGusELc8sGTTw1dbGtM6p4VzXrpjpS Hw7xtjCd24Whh0l7lFLqUuS2dew8DRknninvoMOeS0lDt1F5fBQREoNdWtP2MN5OheX2 dXQA== X-Gm-Message-State: AOAM533F0vfelV4xi0VS+mDK7Ub/qV1hMVvoLwhAFF+YmgjXgT011lYd KjdsdVU/y/0CUTAADAxGBHoTlQfBFA== X-Google-Smtp-Source: ABdhPJz7VxJDn9AlnO31BeEfLlm2ECE/+eRq/NBPi9fc3fTjVsc/UN1YsxmsN2WBp9ZDYm2R2cTGMvqPZg== X-Received: by 2002:a0c:eac4:: with SMTP id y4mr2480760qvp.39.1590133943257; Fri, 22 May 2020 00:52:23 -0700 (PDT) Date: Fri, 22 May 2020 09:52:07 +0200 Message-Id: <20200522075207.157349-1-elver@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog Subject: [PATCH v2] kasan: Disable branch tracing for core runtime From: Marco Elver To: elver@google.com Cc: dvyukov@google.com, glider@google.com, andreyknvl@google.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, aryabinin@virtuozzo.com, akpm@linux-foundation.org, linux-mm@kvack.org, cai@lca.pw, kernel test robot 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: During early boot, while KASAN is not yet initialized, it is possible to enter reporting code-path and end up in kasan_report(). While uninitialized, the branch there prevents generating any reports, however, under certain circumstances when branches are being traced (TRACE_BRANCH_PROFILING), we may recurse deep enough to cause kernel reboots without warning. To prevent similar issues in future, we should disable branch tracing for the core runtime. Link: https://lore.kernel.org/lkml/20200517011732.GE24705@shao2-debian/ Reported-by: kernel test robot Signed-off-by: Marco Elver --- v2: * Remove duplicate DISABLE_BRANCH_PROFILING from tags.c as reported by Qian Cai. --- mm/kasan/Makefile | 16 ++++++++-------- mm/kasan/generic.c | 1 - mm/kasan/tags.c | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile index 434d503a6525..de3121848ddf 100644 --- a/mm/kasan/Makefile +++ b/mm/kasan/Makefile @@ -15,14 +15,14 @@ CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS_FTRACE) # Function splitter causes unnecessary splits in __asan_load1/__asan_store1 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533 -CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) +CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING +CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING obj-$(CONFIG_KASAN) := common.o init.o report.o obj-$(CONFIG_KASAN_GENERIC) += generic.o generic_report.o quarantine.o diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index 56ff8885fe2e..098a7dbaced6 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -15,7 +15,6 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#define DISABLE_BRANCH_PROFILING #include #include diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c index 25b7734e7013..8a959fdd30e3 100644 --- a/mm/kasan/tags.c +++ b/mm/kasan/tags.c @@ -12,7 +12,6 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#define DISABLE_BRANCH_PROFILING #include #include