Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3667190ima; Mon, 4 Feb 2019 03:07:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN7DgCIEpuTa0aCQi3jvl8NG/+SzsMj5p+ekLLaMdmDWy8R7R27xZWA25aQ/3bH/3+pShlGL X-Received: by 2002:a62:8e19:: with SMTP id k25mr50626529pfe.185.1549278434130; Mon, 04 Feb 2019 03:07:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549278434; cv=none; d=google.com; s=arc-20160816; b=FGBQkSz2KLgOYmXezjEAVdrHYRC+JG+CsRquojKjkChke1xWJvmMGZKThjKeLavr80 Pi7NdDPRctolzQ2pRE41JBFM9UL7ZXSE7yXECB/xJHzppzLjk7s9h1+OCDQnQv6q7P+l 0Fe/QpttQFxoFXr1dEXZ0mb3njhyMU/XUIUCvBSmCXMnudxWGfFExnhEVml4VAp95UAo Bgv7cnx6isxojKel6ddnnr8acHbIrOlswigJ+N0E5jbGMJ2BcvGcW/mnLKV/eQNvEwju 5+mJ4gP+A5JhY4OXt7DFKDVRXM4CsZ5bvsTmV2EyhgYt1Nyjof0U0dfGxJxbsjR+OT1K PIkw== 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=j1QY/3BMRqq8c3J8ARN0vjU5SFBUEsvWLdEmLWffBKQ=; b=DZo/E7ph3JKO+g8kXnY8AZBn/XUkvlX3cgFz59yhLQkmgywE2AmgZfgpjXjcZocWWf YUp/BE5BHNykUw/clwWtWUGSJDLf7a5tF8msEdO6CEA0bDDRlbtTHk+zlt9Q4DrRrlkC vBE0ObDMDQ8mRtdZWHPNN//ONUc8r0XuwYYZ+DcHLrKSwqBfcDh9cjgQYbo7o5K2q+e0 QtfPCfPq4MJq1UbLzMIcFKjUC6GdfOtXxTfv0dSQW++C85KFxSIhNZ4p1HBwuiV07iYx 8FuJk29PiEdS6XUVNSSfMJih3KyuU3NbqOt8eHyPHtXYnu799zwet1FF3LVp+IcPVh0i QV2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QXBYziDa; 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 n15si14835535pgk.27.2019.02.04.03.06.58; Mon, 04 Feb 2019 03:07:14 -0800 (PST) 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=QXBYziDa; 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 S1730930AbfBDLGG (ORCPT + 99 others); Mon, 4 Feb 2019 06:06:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:41790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730848AbfBDKoB (ORCPT ); Mon, 4 Feb 2019 05:44:01 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 BA1E42070C; Mon, 4 Feb 2019 10:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277040; bh=JTHLdlqJvTqGR4pF+fed10XzztucltY7/0kBhDxYKSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QXBYziDaWmlEhXquuF8goD770TO/O0Bkg4/wYBGdepQU6n6IlRa7i+s1PL0bnveX+ glaHB/uWmn/gVgGjoXK44yIVeG7eNTSGgEs7iVXeE6pEVgjaSvHbcntfuttsoqnIIz Bg3NFbrK+FqavuQvSA8KEf3F7arqy/XYNATyzzsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naoya Horiguchi , Jane Chu , Dan Williams , William Kucharski , Oleg Nesterov , Andrew Morton , Linus Torvalds Subject: [PATCH 4.9 25/30] mm: hwpoison: use do_send_sig_info() instead of force_sig() Date: Mon, 4 Feb 2019 11:37:03 +0100 Message-Id: <20190204103609.932566838@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103605.271746870@linuxfoundation.org> References: <20190204103605.271746870@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Naoya Horiguchi commit 6376360ecbe525a9c17b3d081dfd88ba3e4ed65b upstream. Currently memory_failure() is racy against process's exiting, which results in kernel crash by null pointer dereference. The root cause is that memory_failure() uses force_sig() to forcibly kill asynchronous (meaning not in the current context) processes. As discussed in thread https://lkml.org/lkml/2010/6/8/236 years ago for OOM fixes, this is not a right thing to do. OOM solves this issue by using do_send_sig_info() as done in commit d2d393099de2 ("signal: oom_kill_task: use SEND_SIG_FORCED instead of force_sig()"), so this patch is suggesting to do the same for hwpoison. do_send_sig_info() properly accesses to siglock with lock_task_sighand(), so is free from the reported race. I confirmed that the reported bug reproduces with inserting some delay in kill_procs(), and it never reproduces with this patch. Note that memory_failure() can send another type of signal using force_sig_mceerr(), and the reported race shouldn't happen on it because force_sig_mceerr() is called only for synchronous processes (i.e. BUS_MCEERR_AR happens only when some process accesses to the corrupted memory.) Link: http://lkml.kernel.org/r/20190116093046.GA29835@hori1.linux.bs1.fc.nec.co.jp Signed-off-by: Naoya Horiguchi Reported-by: Jane Chu Reviewed-by: Dan Williams Reviewed-by: William Kucharski Cc: Oleg Nesterov Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory-failure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -336,7 +336,8 @@ static void kill_procs(struct list_head if (fail || tk->addr_valid == 0) { pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", pfn, tk->tsk->comm, tk->tsk->pid); - force_sig(SIGKILL, tk->tsk); + do_send_sig_info(SIGKILL, SEND_SIG_PRIV, + tk->tsk, PIDTYPE_PID); } /*