From patchwork Tue May 19 18:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11558485 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 A2A2860D for ; Tue, 19 May 2020 18:25:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7027F207D3 for ; Tue, 19 May 2020 18:25:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="S8dNvEpv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7027F207D3 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 8B1498000C; Tue, 19 May 2020 14:25:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 861D5900002; Tue, 19 May 2020 14:25:08 -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 778D98000C; Tue, 19 May 2020 14:25:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 60C27900002 for ; Tue, 19 May 2020 14:25:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 28CB8824556B for ; Tue, 19 May 2020 18:25:08 +0000 (UTC) X-FDA: 76834295496.30.scale32_66ff2054e9b1b X-Spam-Summary: 10,1,0,d1cb00bbb9338ada,d41d8cd98f00b204,3gitexgukcnc7eo7k9hh9e7.5hfebgnq-ffdo35d.hk9@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:3353:3865:3867:3868:3870:3871:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959: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.73:@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,Custom_ru les:0:0: X-HE-Tag: scale32_66ff2054e9b1b X-Filterd-Recvd-Size: 5676 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 May 2020 18:25:07 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id o7so614617qvm.15 for ; Tue, 19 May 2020 11:25:07 -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=/YztpDs6K8vdorsBByvnDRj+nEKIuoGb/xCbk1LxXf8=; b=S8dNvEpvhE+IfpPm75giwVCaRp7o63rsUkXLxrj7ImLgHdi2CIWaV2uRWaWULAp2hb BdHfYBPV3qB1TwxRVPVHr3NEjOJNkTFj/3DHOifWLY5AvwISft0kCLQe7amSF4DDzham TngA37tIZZN0J1lnHTIaF4s0bKvAZzJR0Fwr2gV3phXscBjJxO31CR9TkxU1YajXB/I+ N7/1vqQX+QKWF0J5ogpoosa3s99vmKO6BwAljPiJI7wtzqYDSM9/YZ/sjWrGV6IX+83h 5QfBWwhuT/IksEOCobJwVwxSS8OAGkzeaQVFoIL4khU76tyzhc95TyDjxNCXiSx1a1Si gqyw== 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=/YztpDs6K8vdorsBByvnDRj+nEKIuoGb/xCbk1LxXf8=; b=F/M2vHPXv6FGaHZq6r9RSY1RMHwbc1bzI7QTLnLJqt4SsvurxDnKAUIPJYnef8fnsZ cruwL8i2el/ehn6bBs37PQGTQBMzQ4StkroAoWLBHQDVqDXII0mancFDD07pOl+dtv9c b5Z+1XgrN3viBS/bVqyjdPlB2a673PzJI+BwJ1oLMzGjg90DCSX4MqcNN5mpMNt0Dg0Y 11Kb/0SfNGQiDdt5ZpQCpXwtY/0hBsV5BGT0r4NiP40pfOuq+wp9ijtk+8v9GVbqavgx MEf7ykm4O+YZxiELEX8EobKHBRdmTvkJ6sUYrB0agfhuPAoIk/uUwtSL/Fo5ynJXPF5h Edug== X-Gm-Message-State: AOAM532+lMHaIz+spBSZdkx4hekxNV7Xdnc3N+DTZ4Df3tuQfOkxvaXn JHsyeyU/YpXL+tpkKy2lF94iC6hQsQ== X-Google-Smtp-Source: ABdhPJyqBjGg13VhNhrrjBOPZY6akdM/gNnnfWvsAighzQLtbRMd1TtH6DpRkH6RXRujb4mwRLYmtIE4+Q== X-Received: by 2002:a05:6214:3f0:: with SMTP id cf16mr1034113qvb.4.1589912706953; Tue, 19 May 2020 11:25:06 -0700 (PDT) Date: Tue, 19 May 2020 20:24:59 +0200 Message-Id: <20200519182459.87166-1-elver@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH] 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, 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 Reviewed-by: Andrey Konovalov --- mm/kasan/Makefile | 16 ++++++++-------- mm/kasan/generic.c | 1 - 2 files changed, 8 insertions(+), 9 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