From patchwork Thu Jan 16 01:23: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: 11335791 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 1B5BF13BD for ; Thu, 16 Jan 2020 01:24:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D939924681 for ; Thu, 16 Jan 2020 01:24:38 +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="YBfsq7Ez" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D939924681 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 044B98E0003; Wed, 15 Jan 2020 20:24:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F38268E001C; Wed, 15 Jan 2020 20:24:26 -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 DFF498E0003; Wed, 15 Jan 2020 20:24:26 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id C6E588E001C for ; Wed, 15 Jan 2020 20:24:26 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 71393180AD815 for ; Thu, 16 Jan 2020 01:24:26 +0000 (UTC) X-FDA: 76381752132.21.spark05_7e0ae06a22b4c X-Spam-Summary: 13,1.2,0,fd5090cf75800968,d41d8cd98f00b204,keescook@chromium.org,:akpm@linux-foundation.org:keescook@chromium.org:aryabinin@virtuozzo.com:lenaptr@google.com:glider@google.com:dan.carpenter@oracle.com:gustavo@embeddedor.com:arnd@arndb.de:ard.biesheuvel@linaro.org:kasan-dev@googlegroups.com::linux-kernel@vger.kernel.org:kernel-hardening@lists.openwall.com:syzkaller@googlegroups.com,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:4321:5007:6261:6653:6742:7903:10008:11026:11473:11658:11914:12043:12291:12297:12438:12517:12519:12555:12683:12895:12986:13069:13311:13357:13894:14181:14384:14394:14721:21080:21212:21444:21627:21983:30054:30090,0,RBL:209.85.210.195:@chromium.org:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,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 X-HE-Tag: spark05_7e0ae06a22b4c X-Filterd-Recvd-Size: 4186 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 01:24:26 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id i6so9378692pfc.1 for ; Wed, 15 Jan 2020 17:24:25 -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=8H0Ju2Tzkc7Hi4GTApYP4I+j3crkZ0C4oDWnN2FFbsw=; b=YBfsq7Ezv9QYWZccbUoWAnosaxltJReREbQgD47d8e4wJ+Ejg4Gn/vs3HhD5eYzXQr oJSYxgIJL4FY50iMU0/0GHsjGfjdVuL9/LFpgrcASS5CbKRGtx4pLqrpDWIs3X6BUzT1 x8tB+7PXLZLkr6MHrizsmnC10IzFOgJdvcjV8= 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=8H0Ju2Tzkc7Hi4GTApYP4I+j3crkZ0C4oDWnN2FFbsw=; b=BT7aw7fa8ftbuh1ui4xcI9SxSrybVDwcGyqha62hBLb/Y1vP3CQsXzrAm77tsNMqH7 vfA2W6c4fTMddjAnx6FSfWCqFyOxeAlf6hIFhKYceRWJw28ONp7fxgKYEVURK9bGT38n VHsmW0rFkrQ7rT1YmD6rn6bEPoZQB/cGvX1V1TiiRVWkkSA4e5Fy0IozAF1HmoBBOtPT BUqXF/QMSbtmaG0mzq2SaDsCLlN0a0Q2qjUhYGd4TFETXXsMd2htlIulpnJV9dgGJN3W eHsF9spz13vCgmrXzgHeDr0WaRWM36yiCb/SImmNHgjg9SxQQfzSGfs6kygcTPybbcAG oyKA== X-Gm-Message-State: APjAAAWOiBDo5fAmZd7jyXFPjLeu/ORuslfHr3tTLBlAaE5wGg+Bo8oU e1/DxgTisDpc3BfUCPWm9tWvlg== X-Google-Smtp-Source: APXvYqyCry89U8JhHB2JmnnGGqfqp6e2/sFNsw+rUzw40rZSQ9y3ohq76mRbxz8eJb3EdmcaMK/hOw== X-Received: by 2002:aa7:98d0:: with SMTP id e16mr33457061pfm.77.1579137865146; Wed, 15 Jan 2020 17:24:25 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d1sm1046181pjx.6.2020.01.15.17.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 17:24:23 -0800 (PST) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Andrey Ryabinin , Elena Petrova , 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 v3 5/6] kasan: Unset panic_on_warn before calling panic() Date: Wed, 15 Jan 2020 17:23:20 -0800 Message-Id: <20200116012321.26254-6-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116012321.26254-1-keescook@chromium.org> References: <20200116012321.26254-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 621782100eaa..844554e78893 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(); }