Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4314441imu; Mon, 7 Jan 2019 20:47:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7T6VEj4UOaau2J24uB9ovdbRXSd9tTb7Lu8Wad4/B3V2pzyPTAodCFjN20GEoems83/07C X-Received: by 2002:a62:fb07:: with SMTP id x7mr275659pfm.71.1546922845119; Mon, 07 Jan 2019 20:47:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546922845; cv=none; d=google.com; s=arc-20160816; b=CdBQ8r9WJi04VsY/FMG4IOSwiby4/RZWg1SoQTIoDybWLmbWfOcejrj9Mf7Omb62R3 LFJ49XW1t4cI+f1zU3Vi1+A37tfQmDswclJKQlhN7MdbI9+NhVQq6jcjSjswbHwQC1Xs XJCq8A5ljCqheF19TOqU5WNKAC7PXB3+r8jlZTKWq1IdL2so9NYbT6ja+an0hHosii4D iYqPXIBRlQAfigYLburLajITw5pEdHkjnMLyclRDCdS+jCQn9TShgnIgxokNlpwtLPru sftqx7fcE3DGvt9b+AwTacgPf+qGmv0kN+hrrRnhv3FdB8ctTjGkl6USwxU0Q5iGM+tA 2GZg== 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=659oA23Y5ab4MouJQcTeyGmOC9J7k+xpnnbmmK6mydg=; b=a0BKQJ0hNjDbk6+OFGMnXFexGSGerB4yoK8iS5Fja5REjvm8JxFdKxjPPbgEFncnKB i+bC0PrleuQGDJwMK6+Xc01+k74HgzvM4u8R4YltYwOYxlyLZ9pjyWSQOsC1xAHuEBhS JNtF64NSSaM/E5NegA4OhqlVr5JYkpSzxB8vuOVhT5nEOyrImccF2phFWhZydlVAjp9a wdo4TBqQnsxZtzgU2Wi1T7/Dap1BIEtdRvcvMgHlIVqumj7V0QmLzp/k0DjtL2v+hEBz TMHeVnZys+FDdEYbfS/8x02g+K3uSsObTL9BdFWWfVy3iRG18Oydm5jdx4yqxJsBvpoc kZtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qqydPi1+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si2894809pld.282.2019.01.07.20.47.00; Mon, 07 Jan 2019 20:47:25 -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=qqydPi1+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbfAHEpR (ORCPT + 99 others); Mon, 7 Jan 2019 23:45:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:52646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbfAHEpR (ORCPT ); Mon, 7 Jan 2019 23:45:17 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 BF5242087F; Tue, 8 Jan 2019 04:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546922716; bh=xQc/P7vx7xya8t6opXe7Oq8Ck8XsunNZuzE3auLwQUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqydPi1++5LoKCup+fATgNurvcabf9qr0D//ozxy2aTYMTJSD3a90Qj60AoP5mWu7 N4yMEv3pcL712utM7pnk+MZyC5CFEcx0IsVWAM9mMyEN8AdmQwOy+2WS04IT5KRCsK y7dJFqRtigb5VBngpV0mcJO8G62wUBsJR67d9h10= From: Masami Hiramatsu To: Ingo Molnar Cc: Masami Hiramatsu , peterz@infradead.org, Mathieu Desnoyers , linux-kernel , Andrea Righi , Steven Rostedt , stable@vger.kernel.org Subject: [PATCH v2 2/3] kprobes: Mark ftrace mcount handler functions nokprobe Date: Tue, 8 Jan 2019 13:44:54 +0900 Message-Id: <154692269381.1133.17151202401532686704.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <154692263564.1133.17363562046971295490.stgit@devbox> References: <154692263564.1133.17363562046971295490.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mark ftrace mcount handler functions nokprobe since probing on these functions with kretprobe pushes return address incorrectly on kretprobe shadow stack. Signed-off-by: Masami Hiramatsu Reported-by: Francis Deslauriers Tested-by: Andrea Righi Cc: stable@vger.kernel.org --- - Changes in v2: Fix to include kprobes.h (Thanks Andrea!) --- kernel/trace/ftrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index f0ff24173a0b..b0774388d52b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -6250,7 +6251,7 @@ void ftrace_reset_array_ops(struct trace_array *tr) tr->ops->func = ftrace_stub; } -static inline void +static nokprobe_inline void __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *ignored, struct pt_regs *regs) { @@ -6310,11 +6311,13 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, { __ftrace_ops_list_func(ip, parent_ip, NULL, regs); } +NOKPROBE_SYMBOL(ftrace_ops_list_func); #else static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip) { __ftrace_ops_list_func(ip, parent_ip, NULL, NULL); } +NOKPROBE_SYMBOL(ftrace_ops_no_ops); #endif /* @@ -6341,6 +6344,7 @@ static void ftrace_ops_assist_func(unsigned long ip, unsigned long parent_ip, preempt_enable_notrace(); trace_clear_recursion(bit); } +NOKPROBE_SYMBOL(ftrace_ops_assist_func); /** * ftrace_ops_get_func - get the function a trampoline should call