From patchwork Thu Jan 16 01:23:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11335787 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 D074213B4 for ; Thu, 16 Jan 2020 01:24:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 939352467E for ; Thu, 16 Jan 2020 01:24:33 +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="SJwnin5n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 939352467E 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 59DFC8E0019; Wed, 15 Jan 2020 20:24:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5506F8E0003; Wed, 15 Jan 2020 20:24:25 -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 294208E0019; Wed, 15 Jan 2020 20:24:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 0B03A8E0003 for ; Wed, 15 Jan 2020 20:24:25 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id AB75E40FB for ; Thu, 16 Jan 2020 01:24:24 +0000 (UTC) X-FDA: 76381752048.29.rub88_7dca2295f5752 X-Spam-Summary: 2,0,0,0fe10bee4529a0a7,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:967:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2525:2553:2559:2563:2682:2685:2689:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:6261:6653:6742:7903:8957:9025:10004:11026:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12895:13069:13311:13357:13894:14181:14384:14394:14721:14777:21080:21444:21627:21740:21939:21983:30054:30070:30090,0,RBL:209.85.210.196:@chromium.org:.l bl8.mail X-HE-Tag: rub88_7dca2295f5752 X-Filterd-Recvd-Size: 4207 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 01:24:24 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id x185so9379648pfc.5 for ; Wed, 15 Jan 2020 17:24:24 -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=46Z0N6nNFPIgM2OuwNgkHRjYe659IsqNoWw8FG0hdrY=; b=SJwnin5nMwZBKrhpnWtYLNNA2XESjaBA5OMZZUiC+dLBovxajhmbEreGNQuSCGlJwg rzwLtTnueeZeF9mo1NZWc/UG++85l/gf4xMNaTD7Mi65olwyiNctPjj7SEzVTf8lz6JY y2wkfmtBIGevOe/HcrOjcNSuIe8PF7VSzsSEI= 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=46Z0N6nNFPIgM2OuwNgkHRjYe659IsqNoWw8FG0hdrY=; b=PxyPZvw+AoZjxVwtrqw4qGsmCIVYQX5IN5Uko4X59QyrwszjlO7H44qfCqBNsy+kJI Pc+OiFGgDHhHknAG2xLHXeX3HUrFzO+ql/vVaRa9MvK/GHKV2XPjY6FgntV3yrQT+Opr 0ftgiyJAtrLHaUhYZjN9AsIYYWZEz9HcdK+2pjK5tj9Uu/h9wYURWhRE/BDc6UsDsAzw DZjSdCIs/RAMmExMiM1eiY29EuxhlRrI9UEV5S+MvaBJvX23EavhNjpYz14ChMXpq9ir kCfoieC9JwHyrFEKFOxViV9UKQ7kh+FjBw3wOJ6KnwKzSYJQjRtloOR9YtBnh71ylRXo 05cA== X-Gm-Message-State: APjAAAWMiWPsXiPE5PKDvY8mMLiBUH4k421N1TcSEWuSWVU2YcPLoePz ShP88WxQ1MxJo50p2pKzr6p2WQ== X-Google-Smtp-Source: APXvYqxsGknX6bnO/GaSkj5DHw5Et7M+pO9sTANSMwjDnHU91axQ6Z/1Fsl4MvtQ189Vh73/ukEWVg== X-Received: by 2002:aa7:9816:: with SMTP id e22mr35105862pfl.229.1579137863425; Wed, 15 Jan 2020 17:24:23 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d20sm1058272pjs.2.2020.01.15.17.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 17:24:18 -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 4/6] ubsan: Check panic_on_warn Date: Wed, 15 Jan 2020 17:23:19 -0800 Message-Id: <20200116012321.26254-5-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: Syzkaller expects kernel warnings to panic when the panic_on_warn sysctl is set. More work is needed here to have UBSan reuse the WARN infrastructure, but for now, just check the flag manually. Link: https://lore.kernel.org/lkml/CACT4Y+bsLJ-wFx_TaXqax3JByUOWB3uk787LsyMVcfW6JzzGvg@mail.gmail.com Signed-off-by: Kees Cook --- lib/ubsan.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ubsan.c b/lib/ubsan.c index 7b9b58aee72c..429663eef6a7 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -156,6 +156,17 @@ static void ubsan_epilogue(void) "========================================\n"); current->in_ubsan--; + + 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"); + } } static void handle_overflow(struct overflow_data *data, void *lhs,