From patchwork Thu Feb 27 19:35:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11409559 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 A1CAF159A for ; Thu, 27 Feb 2020 19:35:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6EA762468E for ; Thu, 27 Feb 2020 19:35:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YBkqK4RC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EA762468E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6AC606B000C; Thu, 27 Feb 2020 14:35:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 635036B000D; Thu, 27 Feb 2020 14:35:30 -0500 (EST) 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 4FD626B000E; Thu, 27 Feb 2020 14:35:30 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 38BAB6B000C for ; Thu, 27 Feb 2020 14:35:30 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2DCA0180AD802 for ; Thu, 27 Feb 2020 19:35:30 +0000 (UTC) X-FDA: 76536911220.07.dress88_12e031262d015 X-Spam-Summary: 13,1.2,0,3f4db963fc90d8a7,d41d8cd98f00b204,keescook@chromium.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:5007:6261:6653:6742:7903:10008:11026:11473:11658:11914:12043:12291:12297:12438:12517:12519:12555:12683:12895:13069:13311:13357:13894:14181:14384:14394:14721:21080:21212:21444:21451:21627:21939:21983:30054:30090,0,RBL:209.85.214.193:@chromium.org:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: dress88_12e031262d015 X-Filterd-Recvd-Size: 4321 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 27 Feb 2020 19:35:29 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id y1so202316plp.7 for ; Thu, 27 Feb 2020 11:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sVbVapbdvm9D9bZT8RLizJdch6+5SIEY/KYRYQVG8Tk=; b=YBkqK4RCOblb4V5cg2JjztQtg3wh+brHnQ/Xnw/4IBUFJRhh4GeFiQP9nVouaSw+sY Iq7R/urAShHZ7CPMQvKGeXyT+FOvmE0vy0gms+GZvnF1oUTIeAIqmZaTytVTOmRvhGYp 9u4+wigHHHW5WR6VelBYcFCmp7ofnwGN7wT7U= 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:mime-version:content-transfer-encoding; bh=sVbVapbdvm9D9bZT8RLizJdch6+5SIEY/KYRYQVG8Tk=; b=c0rsxwPA1Eg0GyFhMcon7f3Pl88J3rDD2VkBGqPHHWJ2iL5EzSrirAX/VrdbnE8lLq htdXtV09gSczrJflv+b2FjR/id8iWm9V1F5CKCQ7P3jqXLphhIkJNHQiUvlCrlfZ7/MD cifGjyUVpoT8wUZvMre1Rx+yXgSiuZ0hs6AfsaCUflSomnH2hbsgddXC+SGqZP2Og00k gfiYO3buRZ/ebepl+FAYMjQNdLr8DrfUiiTFfEnW2G3ID77oJN7PyJeBQ+WQSuMjGDgj vANawJ03lpxt4FYp39bj8mfLXcOYEAWPyVmz6BEFqh8ZDAxQoVNh8eMQuUTpDo9+YR3T 4R3Q== X-Gm-Message-State: APjAAAWxNwf+DI0EQ6Oz98xx5XFDHS8M8fXdtyDFsQtXGdxg5Dl7Oriu Ka8ipA6E344OmKclOFtlhWE6VOQqn58= X-Google-Smtp-Source: APXvYqwJAU0YQCF3NBelWYbAkfjhxYyfXVhFnc+XRJm1wrTo2TVo3yr52ImKKRO716VR/awYEpFPlg== X-Received: by 2002:a17:90a:3266:: with SMTP id k93mr527984pjb.23.1582832128663; Thu, 27 Feb 2020 11:35:28 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c26sm7957064pfi.46.2020.02.27.11.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 11:35:27 -0800 (PST) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Dmitry Vyukov , Andrey Ryabinin , Elena Petrova , Andrey Konovalov , Alexander Potapenko , Dan Carpenter , "Gustavo A. R. Silva" , Arnd Bergmann , Ard Biesheuvel , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, syzkaller@googlegroups.com Subject: [PATCH v5 5/6] kasan: Unset panic_on_warn before calling panic() Date: Thu, 27 Feb 2020 11:35:15 -0800 Message-Id: <20200227193516.32566-6-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227193516.32566-1-keescook@chromium.org> References: <20200227193516.32566-1-keescook@chromium.org> MIME-Version: 1.0 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: As done in the full WARN() handler, panic_on_warn needs to be cleared before calling panic() to avoid recursive panics. Signed-off-by: Kees Cook Acked-by: Dmitry Vyukov --- mm/kasan/report.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 5ef9f24f566b..54bd98a1fc7b 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -92,8 +92,16 @@ static void end_report(unsigned long *flags) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn) + if (panic_on_warn) { + /* + * This thread may hit another WARN() in the panic path. + * Resetting this prevents additional WARN() from panicking the + * system on this thread. Other threads are blocked by the + * panic_mutex in panic(). + */ + panic_on_warn = 0; panic("panic_on_warn set ...\n"); + } kasan_enable_current(); }