From patchwork Tue May 9 14:42:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 98935 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1857674qge; Tue, 9 May 2017 07:43:47 -0700 (PDT) X-Received: by 10.84.142.133 with SMTP id 5mr718498plx.52.1494341027478; Tue, 09 May 2017 07:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494341027; cv=none; d=google.com; s=arc-20160816; b=KkHe6tBkESQG4K8HXiPNUpuwdzFVbNCl0axr5uuUCuaQKbyYn+QCnPngcNWugRaQ9h xiw6iIxtXZls3DM8oKunMHWzvRkfPPDAv1RJDgf6OTSflX7r02pZvQCX6aJeFVNaI+wQ emY3EwbMEbgTrhNzPLoCmLIiX+nga/slApXqaMc6vu3W+G5XZCd63kx0IJil5MVpP5uf C0mhhCrnmhMMcW0YfiNiEeB/KyWLv8zNmfPQWD3nC0r2h9epwn7LeKfrah1wpQ588gWh eg5Z8HszyuyhFOpROjwURIpzd/xgunisP9GhbzZTvDAzdmrPMHsC5y6xSqEzT++pT+a/ Dedw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=UGlqH6hRKjMmFd/RkNdey6ijWy7ivpUQh7+QkMks1xk=; b=PGGUwwQVyBfHbAwxMvcJBYZDUxT1YSe4C0NjtOr3dp5o8XMo36F/ATS0NQ0+DS8GXV XNQmOqq3Ybesyb3yVk56jrT8SahJ7GqsJCmPlgU86qf4nDaPOP3uC/MEopI+Slz5OlwC wHGltLRYusL1jGAbdItU9ht4QpSExCy18yc5xAD+BSKCV5sb6qfq7ujvFJP41YXjRlL/ KnzHnjyXc89+lR2W0rG0a2646zOoIW74RCbIaSNWwuHi7rkrLkS4ya3nksGsoeVW/F/L o/rK9P/yVCqAyeTN3z0pZYDDmmKmr3lr5ThTdJVdejpSiZUG6P1b+ijVlEMDNm0E0dFI V5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si99892pli.322.2017.05.09.07.43.47; Tue, 09 May 2017 07:43:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754259AbdEIOnq (ORCPT + 6 others); Tue, 9 May 2017 10:43:46 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:35822 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754143AbdEIOnq (ORCPT ); Tue, 9 May 2017 10:43:46 -0400 Received: by mail-pg0-f53.google.com with SMTP id o3so756218pgn.2 for ; Tue, 09 May 2017 07:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UGlqH6hRKjMmFd/RkNdey6ijWy7ivpUQh7+QkMks1xk=; b=NnOwca4p6Kl/12h5CSKdrzb7Z6JGob647pCOSrYiNieG3tR0bsI2lLQhyFxDf+kgNi lX7cYW+YwmThkwzz6aiHNM8lBP4Fe12NOXKg+dplws8K4pPjBbAraBmw45RSbqOuUPu5 FKDvQ2WVKtQFBmXlwiJuZRx7V19jv3sAV173Y= 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; bh=UGlqH6hRKjMmFd/RkNdey6ijWy7ivpUQh7+QkMks1xk=; b=BQHAczz67eS8yGCj+arwNM0/QhIrfUlU9B0v0y3CkKo4dzLqU9/l/hAdWa4rC9dM/a c4pbRdCqL0D99MB3NXI4mIzZsVpGcxvCzsrn6Epyi/m9/8JC3tcGaFSKyUViBDI/6QF/ tI3tpZMOBHir04w0zeMIGiqBIbwLjO4Vu3iQ+0HNn8uUp7D/LQKhLXKQFGCQM8MnQyu3 E46BaI0de+3Ts8e/6yC5rR0wVSsIM5r+s7OAO7jsLbsXhm9draOTN0Cpj4X9kvnXkQ7t 2GqN/JtFH0aeTH0K9ZG7R7s1kTfFU25ndQxuoP9SyZ+5YpQRKCINoY6PLUPIrFpB4P05 Tv+Q== X-Gm-Message-State: AODbwcBLjsDZZKRvltU88phSHi8ajHgB4Nb2MLiUDt8Mk35RvE2OUML6 EqDxRQxmxrTHDNP7 X-Received: by 10.84.231.23 with SMTP id f23mr697006plk.58.1494341025487; Tue, 09 May 2017 07:43:45 -0700 (PDT) Received: from localhost.localdomain ([106.51.135.126]) by smtp.gmail.com with ESMTPSA id 11sm341811pfj.59.2017.05.09.07.43.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 07:43:44 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: stable@vger.kernel.org, Jann Horn , Linus Torvalds Subject: [PATCH for-3.18 22/24] sched: panic on corrupted stack end Date: Tue, 9 May 2017 20:12:46 +0530 Message-Id: <1494340968-17152-23-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494340968-17152-1-git-send-email-amit.pundir@linaro.org> References: <1494340968-17152-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jann Horn commit 29d6455178a09e1dc340380c582b13356227e8df upstream. Until now, hitting this BUG_ON caused a recursive oops (because oops handling involves do_exit(), which calls into the scheduler, which in turn raises an oops), which caused stuff below the stack to be overwritten until a panic happened (e.g. via an oops in interrupt context, caused by the overwritten CPU index in the thread_info). Just panic directly. Signed-off-by: Jann Horn Signed-off-by: Linus Torvalds [AmitP: Minor refactoring of upstream changes for linux-3.18.y] Signed-off-by: Amit Pundir --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5f4c71c5d38e..a760c9e0353e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2709,7 +2709,8 @@ static noinline void __schedule_bug(struct task_struct *prev) static inline void schedule_debug(struct task_struct *prev) { #ifdef CONFIG_SCHED_STACK_END_CHECK - BUG_ON(unlikely(task_stack_end_corrupted(prev))); + if (task_stack_end_corrupted(prev)) + panic("corrupted stack end detected inside scheduler\n"); #endif /* * Test if we are atomic. Since do_exit() needs to call into