From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E58F8C33CB1 for ; Sat, 18 Jan 2020 09:19:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6895B2468C for ; Sat, 18 Jan 2020 09:19:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r5Osyi+5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6895B2468C 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 B371A6B0526; Sat, 18 Jan 2020 04:19:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A9ABC6B0527; Sat, 18 Jan 2020 04:19:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93A9A6B0528; Sat, 18 Jan 2020 04:19:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 784BE6B0526 for ; Sat, 18 Jan 2020 04:19:25 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 33C1D4DA9 for ; Sat, 18 Jan 2020 09:19:25 +0000 (UTC) X-FDA: 76390206690.25.crime98_17feb32845517 X-HE-Tag: crime98_17feb32845517 X-Filterd-Recvd-Size: 6684 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sat, 18 Jan 2020 09:19:24 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id d18so23760830qtj.10 for ; Sat, 18 Jan 2020 01:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z7V6E0TDaKraOo9dTt7jhc6TLdoMlUlp/uyIAC+ZTcI=; b=r5Osyi+5S7I7ieJbRoinobkAaTllvHQz6AIaLQiYADUQlxAhGTpSFct10Rbv/qtQPE XeQcvA/TRKGpFLwD5gVeUdVLPE5SFwnaYYXJ09z9LSlZ97mXMTSlaIdv3kesQ6zD7o+C Iqilhd9nvoenPTM0cdlDK9qXTOP7vvglydomTJkikqduytMLU706Obi4jiFowybtbViF 93GtIc0xCZ7BAhaBAOlOKgSo77ZOJ/h/4ntx0g05wHFtFKwmmVfV8Rw7DmZrwumRApv6 2JN3gsKiuVf1UXzL0PyPH/jOaFC4nlRGCFG5rOk/4sjfNUfOFYWVYrG8VrH/xB4a1Yc6 0VkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7V6E0TDaKraOo9dTt7jhc6TLdoMlUlp/uyIAC+ZTcI=; b=t5Il6EtEAam+j0QKuPXy+onLg2kbHw7IwvE7PUTOvuuy2YyuyDsdZovC8HT3ohVXLx KVoGeImTffJ4d2Q2aqMDfzhUa8VHVBVtt5gAaTl95u6A5NzCAOegCEbIRRX6cmeyqvh+ h9/Mbg9T7U/CyiySUV/N2knh2ZEpUMQW052CZurAbJMQq/0LARwcXxZTRdFj7UGaPGXF lu4kCsnfBPYkkwnPonuBZjv6oaRIGtsnN5eH17qUXYdvnRSTu6Ui/ZMmtgnGi1PfDhEL lZbyQH3EARve2+aim6jSFjFGwYiofB6YbIkj6bWNCJsuWnk/QXlyNDmofJITAYQf2KWD L3Wg== X-Gm-Message-State: APjAAAW7+xm4UaWIrxpDnSkI5NDgk0FsrG3r3YqSfp0deLr2pYuFoeWk QbpWU3tlIciC1RCM7OsIKOQUJwqRkQzcPHXgWBvb2A== X-Google-Smtp-Source: APXvYqySu7QSqXqUmm7G/+6P0CGxNfV2qDMzuVTo/0NaUw5yglIxMT0d3on5SEunQ2/Vpk1yqcdlYTa4b1UTbvflla4= X-Received: by 2002:aed:3b6e:: with SMTP id q43mr11061878qte.57.1579339163936; Sat, 18 Jan 2020 01:19:23 -0800 (PST) MIME-Version: 1.0 References: <20200116012321.26254-1-keescook@chromium.org> <20200116012321.26254-6-keescook@chromium.org> <202001161548.9E126B774F@keescook> <202001171317.5E3C106F@keescook> In-Reply-To: <202001171317.5E3C106F@keescook> From: Dmitry Vyukov Date: Sat, 18 Jan 2020 10:19:12 +0100 Message-ID: Subject: Re: [PATCH v3 5/6] kasan: Unset panic_on_warn before calling panic() To: Kees Cook Cc: Andrew Morton , Andrey Ryabinin , Elena Petrova , Alexander Potapenko , Dan Carpenter , "Gustavo A. R. Silva" , Arnd Bergmann , Ard Biesheuvel , kasan-dev , Linux-MM , LKML , kernel-hardening@lists.openwall.com, syzkaller Content-Type: text/plain; charset="UTF-8" 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: On Fri, Jan 17, 2020 at 10:20 PM Kees Cook wrote: > > On Fri, Jan 17, 2020 at 10:54:36AM +0100, Dmitry Vyukov wrote: > > On Fri, Jan 17, 2020 at 12:49 AM Kees Cook wrote: > > > > > > On Thu, Jan 16, 2020 at 06:23:01AM +0100, Dmitry Vyukov wrote: > > > > On Thu, Jan 16, 2020 at 2:24 AM Kees Cook wrote: > > > > > > > > > > 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 > > > > > --- > > > > > 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(). > > > > > > > > I don't understand part about other threads. > > > > Other threads are not necessary inside of panic(). And in fact since > > > > we reset panic_on_warn, they will not get there even if they should. > > > > If I am reading this correctly, once one thread prints a warning and > > > > is going to panic, other threads may now print infinite amounts of > > > > warning and proceed past them freely. Why is this the behavior we > > > > want? > > > > > > AIUI, the issue is the current thread hitting another WARN and blocking > > > on trying to call panic again. WARNs encountered during the execution of > > > panic() need to not attempt to call panic() again. > > > > Yes, but the variable is global and affects other threads and the > > comment talks about other threads, and that's the part I am confused > > about (for both comment wording and the actual behavior). For the > > "same thread hitting another warning" case we need a per-task flag or > > something. > > This is duplicating the common panic-on-warn logic (see the generic bug > code), so I'd like to just have the same behavior between the three > implementations of panic-on-warn (generic bug, kasan, ubsan), and then > work to merge them into a common handler, and then perhaps fix the > details of the behavior. I think it's more correct to allow the panicing > thread to complete than to care about what the other threads are doing. > Right now, a WARN within the panic code will either a) hang the machine, > or b) not panic, allowing the rest of the threads to continue, maybe > then hitting other WARNs and hanging. The generic bug code does not > suffer from this. I see. Then: Acked-by: Dmitry Vyukov