Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3391747ybp; Sun, 6 Oct 2019 10:55:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5h61bZxwlhGYBXfXDRXfIJt//8Kn7B9ovs00DbjtIauV/7LBxIKfTpkvxgmqZzTfX1eoI X-Received: by 2002:a50:87ca:: with SMTP id 10mr25637800edz.77.1570384523732; Sun, 06 Oct 2019 10:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384523; cv=none; d=google.com; s=arc-20160816; b=DuNKS0VWtP74TjwVkNkNtrgXyBwKajAN25pJx4IEERBDL80PPUTVRHqp2CuvQ4LeWT XtJ+XTai2qZtOhjgg/gPsOm9CjIREv0vXRTj21SpP/mk+kmVpvcUfQJuT6Q/b6lYxgEr hJovoy+TlXUmxAwFZiEEle0VJ21Lb8GcRxKMJzjuvDd5oBuxZAlSSu24mokuwP88Mo9E xaCnC4IyNN2lzUopxBVJFN49Rruo13el5oBcFGHCEcguLH2wVBK5fRu6qdktUIR+bH68 rH7BG1NPL4nNBVf4Os1MP3nqOQzeB2NUDThe6peuFCprILVsjusFbJFwF8hcnx2XPVkq OFsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kg+If6Ngg+yKAu4SwXpcqLfZ3pLMSm/0nwOd3WqNQVs=; b=N57k5kBDKqUhdX3tXjMWg40M5nEWMqSBxqOqNmtt04tcn1lyNB7JWkU5nnXmVhCAjp qNxIYud58lIV2sL86WGr4Xv5K+374PjVibr0/nD+QDXY7ea+vzW6nnQNDbh7U6P/7UWl NtVHBxgUJzkAiQFm1p1+oMHfrJw6WBYlCQZyLYNgbmyFmqSUZwz9mrFwWcCbzr7sJrBy 6nRSzSpSJUDrXm+oUgQvfpFE2JFFtMeZVK+zk11UAKlptFsCGtSroxehp+38KTijvu9n LRyOVkZeFVJW3bKI/KEg0yCr8Vs2Clkcm3MwI4RFWm7nLgO1FPdNjMzUfchBcGy/5Qaz MMXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="n/mW7Gw/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy5si5999251ejb.170.2019.10.06.10.54.59; Sun, 06 Oct 2019 10:55:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="n/mW7Gw/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbfJFRjA (ORCPT + 99 others); Sun, 6 Oct 2019 13:39:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:38412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730699AbfJFRi6 (ORCPT ); Sun, 6 Oct 2019 13:38:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 961F720862; Sun, 6 Oct 2019 17:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383538; bh=2xcT+VGmJXBcuipPn6QtCUyE9RS/qI0oh11nGPw+dAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/mW7Gw/doEEH778eZK9J18F0fwcEYJNDchSamq/UjmGemKIU7lwXBEMxsCNgRxO/ 14yr2z2ELTLPN9rQvE1mrf0GQarVau+sUrNe9Bu53lAYu2TYvPpGuMucI5fnvVOkRW HHBY2SKyf4gb8xBZtkRg1mUvmbPvYXeZI2sPR9zQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot , Eric Biederman , Andrew Morton , Linus Torvalds Subject: [PATCH 5.2 134/137] kexec: bail out upon SIGKILL when allocating memory. Date: Sun, 6 Oct 2019 19:21:58 +0200 Message-Id: <20191006171220.547845343@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171209.403038733@linuxfoundation.org> References: <20191006171209.403038733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa commit 7c3a6aedcd6aae0a32a527e68669f7dd667492d1 upstream. 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: Greg Kroah-Hartman --- kernel/kexec_core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -300,6 +300,8 @@ static struct page *kimage_alloc_pages(g { struct page *pages; + if (fatal_signal_pending(current)) + return NULL; pages = alloc_pages(gfp_mask & ~__GFP_ZERO, order); if (pages) { unsigned int count, i;