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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 EDD20ECE587 for ; Tue, 1 Oct 2019 16:40:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B73FE21A4C for ; Tue, 1 Oct 2019 16:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569948052; bh=ri0y+tcaOShXS+LvXq26MlFByM5jdC+qr44td80hKS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hQ1rqGG6sA79uCPZ3jahajb2fsi8dkRNq2uuFloae6MCfKD+cfhO/rngXnIF1YoKo GywB5C14Vtwvu/cojjr4f7sln2qAikI0p0/oHGDLrq7a7MyMbN4Ce3/J43RFFhJRN6 38OE3Xpls8ddTba2TEZBq/4WY/Mf72xJFSrpwreo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730374AbfJAQkw (ORCPT ); Tue, 1 Oct 2019 12:40:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:52194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730326AbfJAQkt (ORCPT ); Tue, 1 Oct 2019 12:40:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 81BE021906; Tue, 1 Oct 2019 16:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569948048; bh=ri0y+tcaOShXS+LvXq26MlFByM5jdC+qr44td80hKS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1q4M/6eJ8WSU6kRlti/gsiXyyGMEt8VZ4V2zG9DZ/6d4xMACmdCPU1t4OcQLUT61 SjoJS8v73B3MeISf+NiTufUI8dVAQNRtnRjGaBunlDPwYxAsMNjNNCS8PEtR9UzGB0 e2B8PKzXwZwCnxcJJ7WKRf0DSAkjo6a/1UmF7CXo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tetsuo Handa , syzbot , Eric Biederman , Andrew Morton , Linus Torvalds , Sasha Levin , kexec@lists.infradead.org Subject: [PATCH AUTOSEL 5.3 53/71] kexec: bail out upon SIGKILL when allocating memory. Date: Tue, 1 Oct 2019 12:39:03 -0400 Message-Id: <20191001163922.14735-53-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191001163922.14735-1-sashal@kernel.org> References: <20191001163922.14735-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tetsuo Handa [ Upstream commit 7c3a6aedcd6aae0a32a527e68669f7dd667492d1 ] syzbot found that a thread can stall for minutes inside kexec_load() after that thread was killed by SIGKILL [1]. It turned out that the reproducer was trying to allocate 2408MB of memory using kimage_alloc_page() from kimage_load_normal_segment(). Let's check for SIGKILL before doing memory allocation. [1] https://syzkaller.appspot.com/bug?id=a0e3436829698d5824231251fad9d8e998f94f5e Link: http://lkml.kernel.org/r/993c9185-d324-2640-d061-bed2dd18b1f7@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa Reported-by: syzbot Cc: Eric Biederman Reviewed-by: Andrew Morton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/kexec_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index d5870723b8ada..15d70a90b50dc 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -300,6 +300,8 @@ static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order) { struct page *pages; + if (fatal_signal_pending(current)) + return NULL; pages = alloc_pages(gfp_mask & ~__GFP_ZERO, order); if (pages) { unsigned int count, i; -- 2.20.1