Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1937214ybt; Mon, 15 Jun 2020 13:25:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjWRLzpkzZSnNKW+tY5bt79kQtsfjqv8VUaZcccXEeIhCxv/X/Et20wUUG7+L9Wfmyt2N/ X-Received: by 2002:a17:906:2cd5:: with SMTP id r21mr26530939ejr.20.1592252728202; Mon, 15 Jun 2020 13:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592252728; cv=none; d=google.com; s=arc-20160816; b=I8tRCsCgYe2QyXnqRFNP3sqKGrdXnaSkE7WP5l9T1dPfrYBHlV/g1jqCdshu4ly1Ej FHwUC0D8BbK/2YCHeLrYiIR1bpoF+TJPZfYg4Dd8yVhOkFNSUa1GI9KVwXUuIpkgrG6c CAltCBB6ZlydIVZoqXoevGml2JTNV40+L3SJHuOOzum+Jd3+APcF/ZOROqhgl81Bju6p j/qB5LY08LsTF2dQ9HACpdWMecNJsXReU4ZdHoePqXExg3HXC1e3mWMTrWFqRGCtowuO rrpZ2I02mL4vvm47u/QsCskwRrDPmlozUGPbn8V/CEEYceLxvPaLBnhrMd6ENbxXjCIt EsLQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=6uFhd2H1J7t9uwe8fX6p0fVLxlj/ypjklCSMSJJssTo=; b=X8Q6IlU/sq3j4BSsIwSRkcHhlIYt8+5Y7DkoULX8BsStMWfhz0nfE2KKGhzThG9/zi SSIL5xUBVLOw6hgTbiGUbQw0yeCXbl+H6tUfW+SGTmD95UksS3uMp1w+h2m1OLJOu8aa 260g+l2jVLd9R6FBuLuBggdaL4RV0nIUKQRWICdEEO7ZXXzC+ehUOKdbOj5vQW0pAtq6 9C8M6unotZZ3stRj4OxmKax36kCu0Ybsh4wdisM1yCWdWvtlvQ3djrztvoPOrdOG3m2H 68la9TAbPLp/ox8WfVwMIBDyIwjUCMtQe6bbs3hw09SLcWTy7DvnU/O3SnO684VqvIOF LR7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca19si9773878edb.341.2020.06.15.13.25.05; Mon, 15 Jun 2020 13:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731500AbgFOUWs (ORCPT + 99 others); Mon, 15 Jun 2020 16:22:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731172AbgFOUWs (ORCPT ); Mon, 15 Jun 2020 16:22:48 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 6E22A2074D; Mon, 15 Jun 2020 20:22:47 +0000 (UTC) Date: Mon, 15 Jun 2020 16:22:45 -0400 From: Steven Rostedt To: Oscar Carter Cc: Kees Cook , Ingo Molnar , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/trace: Remove function callback casts Message-ID: <20200615162245.13d3feff@oasis.local.home> In-Reply-To: <20200615161738.18d07ce6@oasis.local.home> References: <20200614070154.6039-1-oscar.carter@gmx.com> <20200615161738.18d07ce6@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Jun 2020 16:17:38 -0400 Steven Rostedt wrote: > On Sun, 14 Jun 2020 09:01:54 +0200 > Oscar Carter wrote: > > > In an effort to enable -Wcast-function-type in the top-level Makefile to > > support Control Flow Integrity builds, remove all the function callback > > casts. > > > > To do this, use the ftrace_ops_list_func function as a wrapper when the > > arch not supports ftrace ops instead of the use of a function cast. > > > > We need more tricker than this. > > > Signed-off-by: Oscar Carter > > --- > > kernel/trace/ftrace.c | 11 ++++++++--- > > 1 file changed, 8 insertions(+), 3 deletions(-) > > > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > > index c163c3531faf..ed1efc0e3a25 100644 > > --- a/kernel/trace/ftrace.c > > +++ b/kernel/trace/ftrace.c > > @@ -119,13 +119,12 @@ struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end; > > ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; > > struct ftrace_ops global_ops; > > > > -#if ARCH_SUPPORTS_FTRACE_OPS > > static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, > > struct ftrace_ops *op, struct pt_regs *regs); > > -#else > > + > > +#if !ARCH_SUPPORTS_FTRACE_OPS > > /* See comment below, where ftrace_ops_list_func is defined */ > > static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip); > > -#define ftrace_ops_list_func ((ftrace_func_t)ftrace_ops_no_ops) > > The reason for the typecast is because this gets called from asm with only two parameters. [ Some how hit a short cut key that sent this before I was finished! :-p ] As I was saying. This typecast is being paranoid, as archs will call the ftrace_ops_list_func directly, and only pass in two parameters. Now one way around this is to instead of having the typecast, I could use linker magic to create another function that I can define without the typecast to get the same effect. Similar to what I did in commit: 46f9469247c6f ("ftrace: Rename ftrace_graph_stub to ftrace_stub_graph") -- Steve > > > #endif > > > > static inline void ftrace_ops_init(struct ftrace_ops *ops) > > @@ -6860,6 +6859,12 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, > > } > > NOKPROBE_SYMBOL(ftrace_ops_list_func); > > #else > > +static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, > > + struct ftrace_ops *op, struct pt_regs *regs) > > +{ > > + ftrace_ops_no_ops(ip, parent_ip); > > +} > > + > > static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip) > > { > > __ftrace_ops_list_func(ip, parent_ip, NULL, NULL); > > -- > > 2.20.1 >