Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13331622ybl; Sun, 29 Dec 2019 09:28:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyr1SWQqsGt12ilSCEm3kTmABYzZrY+FIdXghm7GNhK9Ofd1Mxy4Q/zrCKnSuULdySDOpb4 X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr73645877ota.154.1577640532000; Sun, 29 Dec 2019 09:28:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640531; cv=none; d=google.com; s=arc-20160816; b=fxGtUiQUDqbP3XzcQcyj11lvrVS9d40vdnh2jf4x1UKZc78wCPiqyC/IppLrYHl3qf uqhFFT3hI9s9q1ML3/GJCTeGKAVA3K4xGKsDUI3ZunnrG1vqtXmUh2iJN9fTGmWinvK+ a4sgHbDRsABVvDNVsdBeVkPrLWgNQMhG0ZDbQF3UqLpFDwT+GI2JIx9147y325bioAVu EdMeWB/K59yV5nhlAp5ONGY6gJpV3Wx58JU1y3qgFeD8zb6s+J344ztHAG5w4w9HydMU ImWLD4YXAkDIznw/evS4Ri/hgmjl4iUCXT/u5o/wivv9rNRTyFG57om622389TRZB6eo 37aw== 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=sLckfAPs3V/iUmGq9qxmO9agrpnxtRAcuFLv9QiSuf4=; b=NrQq2pxMx16RsR1yRzcyGEv4dN63NZm0DXyTOmdNpd/SuPEAUzSaYzpW8FjPVmTLXu vYfYEKmixc1oF3NM9lTnLd+1WpldD6ajGSAHCmuu840KDWfEqoLtIz7+cMltPBECvoTk +oWFCcc+/6AXEjDsTcSjJVmf4rauEtU2Y6mYdOItSlnIPdLrz8f0THGsLFEUx3eTZtxn 7+1vvcnIgZZ7bnUlgdC66GJ6HP+Lk6C+tK4Pmejag/ANOLk4Cq79ItMjztnZ6NRN+Ptp HHPxck4BWI044WiIsfSQGPDR5ebeHiJz6w6Em2OJak2+fqlEvw8ztVe2JAD8lC5ihFfI WMSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qP+xK0+4; 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 d2si21661080oth.267.2019.12.29.09.28.40; Sun, 29 Dec 2019 09:28:51 -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=qP+xK0+4; 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 S1728258AbfL2R0j (ORCPT + 99 others); Sun, 29 Dec 2019 12:26:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:47882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727908AbfL2R0h (ORCPT ); Sun, 29 Dec 2019 12:26:37 -0500 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 B183E207FD; Sun, 29 Dec 2019 17:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640397; bh=/2cofFv4jiQcCenMb/O5CQ05iDJ500lxRiBNuVyfjP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qP+xK0+45wHyqMGmAKekRN+xzLOaBgbjXgOQ9y/2WSnp8whIsB/sZXcBVBiAeoFXq NqDYKmTAHTdlETOkrZzCf9iaBzPZe4Wb9twbtC1fCxcyyY3lrDldEi5tBmSZL8Juyt lumGf3Lin0Nb8OXqay/YH5fARKej/QVIzH25QL0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.14 141/161] s390/ftrace: fix endless recursion in function_graph tracer Date: Sun, 29 Dec 2019 18:19:49 +0100 Message-Id: <20191229162441.825230276@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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: Sven Schnelle [ Upstream commit 6feeee8efc53035c3195b02068b58ae947538aa4 ] The following sequence triggers a kernel stack overflow on s390x: mount -t tracefs tracefs /sys/kernel/tracing cd /sys/kernel/tracing echo function_graph > current_tracer [crash] This is because preempt_count_{add,sub} are in the list of traced functions, which can be demonstrated by: echo preempt_count_add >set_ftrace_filter echo function_graph > current_tracer [crash] The stack overflow happens because get_tod_clock_monotonic() gets called by ftrace but itself calls preempt_{disable,enable}(), which leads to a endless recursion. Fix this by using preempt_{disable,enable}_notrace(). Fixes: 011620688a71 ("s390/time: ensure get_clock_monotonic() returns monotonic values") Signed-off-by: Sven Schnelle Reviewed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/include/asm/timex.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h index 0f12a3f91282..2dc9eb4e1acc 100644 --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -195,9 +195,9 @@ static inline unsigned long long get_tod_clock_monotonic(void) { unsigned long long tod; - preempt_disable(); + preempt_disable_notrace(); tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1]; - preempt_enable(); + preempt_enable_notrace(); return tod; } -- 2.20.1