From patchwork Thu Feb 27 18:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11409521 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 559A592A for ; Thu, 27 Feb 2020 18:50:29 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id AA91524721 for ; Thu, 27 Feb 2020 18:50:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="X5i1lW7g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA91524721 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-17982-patchwork-kernel-hardening=patchwork.kernel.org@lists.openwall.com Received: (qmail 4006 invoked by uid 550); 27 Feb 2020 18:49:46 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 3920 invoked from network); 27 Feb 2020 18:49:44 -0000 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=X5i1lW7gtygxaUBwIXKTt8fYX5fEWxVzi2XPmciBRut8OEFBUEudCWo+YccEh6f6ny /0Cptj90ru+QtzO+Jm5B066x0Pd+9dPxjKr3EyADF+7U55O/GYlCWSY7ZOhdLMBJq8sg t4LNOFIll7WZncnYRr9YoMxDx9eWQGNfzgmqw= 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=E7/LpRXXSMUzozXaO7J6tMmTbDoHLQdoCLMyzvQw06v+cEi0ZiQleNiQe6D3CKMSA+ hZ/tUGKKbBr+hxfiv8/wucvBxKMngpqpa+SyJUT3b9GMI+7t5MD5VXEMfyB+gQpAqGAY LwMf1HBtIbRi52F+S2+ddzZiSJ1DCYC1wy+cK2tT2jzRhMmDCS/wYE6wRf5pkZTb5cyt ++S115VdmXAc1N1yC+I2dBGAUolPV3DyU0L2dFPSYLHFBUQFaUYaFxAbqxEh330k0tg3 eG2rwmaHhhrJdYl/6JY6b7imAV5HCMJAj2x9sle84Ls5Rnk8bx4b3cR106LlNasRfYm4 y1WA== X-Gm-Message-State: APjAAAXTouC0xlqfU0cUF4b+BjnadnQXXldzxiaKAoBDanw29U0MO85M k6bxUVlxZGq9txEOkXG6ViUyHQ== X-Google-Smtp-Source: APXvYqzw71xoeQerxYnDZjCdeGbLhe11Auq1JT6Ex87ZaButtE9AiRc/KemYe2G4Nel9rk6gdI8HaQ== X-Received: by 2002:a17:90b:8d1:: with SMTP id ds17mr352661pjb.33.1582829372673; Thu, 27 Feb 2020 10:49:32 -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 v4 5/6] kasan: Unset panic_on_warn before calling panic() Date: Thu, 27 Feb 2020 10:49:20 -0800 Message-Id: <20200227184921.30215-6-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227184921.30215-1-keescook@chromium.org> References: <20200227184921.30215-1-keescook@chromium.org> MIME-Version: 1.0 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(); }