Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1332421ybt; Sat, 20 Jun 2020 07:30:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/XnNmWNw5zzUvQZWbZacCP+RCNWcgPiymkIK1Bepc01CU6QSDRaJy51Ioku03+qqYiP/h X-Received: by 2002:a50:e881:: with SMTP id f1mr8042805edn.98.1592663428039; Sat, 20 Jun 2020 07:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592663428; cv=none; d=google.com; s=arc-20160816; b=SAWdPRfiQ0iNAK9JhPqroz2g4QgAWczViXYXtTBf0gnvcIINJan3aSp+MLmqR+JXKf ASsdQ52kuhCmaxyMSuRgjZ4VHDO5NdT8yo4HMyBAzvz+/OkErJ1X//gxBFJECGn/veSi HTiyIqkaG7Atvy+Zm3kdA14EkHHP4gYGgEdH852FqPaP9gwAfhXlVfronphmwQcxcs5v PuF5SdnxkNQTdIaCGhhkha9uBORqnxrZPxnNGkFsDrMIeL1WcIwrXxnZgVBo9SZbbkDI 3xttgl7/0+ibIgKKQGGFUWSXT8OIrSjiWqdVqfoqSs43awUB4EU254j7oncInS4X6/f7 PqmQ== 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:user-agent :in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:dkim-signature; bh=Ilrye3CpwT29/62BCQ6Z4Ui+MemwR6Ho6+d76yeeTcA=; b=KyRnsvBld7P0M1FWrgjBIHbpFFY23MFAa0ptawn2ceqmlHgPV8POltJaftvnFWGx7F uqG3NwcHI8u8eSrUdIkr9f9/ByA+M2tBlXa22Lu4H9YuWqtQCWd1g8S5yJCvWwSnLIOW putW0XD/u/WAzJlPe4rcjibwQ+oz5DBAyx2PK6pPHcAJe3m0dd4Pej8nRubA/ajB9Ik4 x1Og+rUCCkpNo4m942LSQjDGIUsrb9v6dCsm99w0WYahUMgmcVpEiAUyu0zDRBWujjQs Ij1bK0T5ATFOp0fiK6yYTOHIVBVmk7niVfLPbh7hI0sF00FyBG2PdGC4tuUuoyFDAAAZ EsXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=Wl7MVMYt; 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 cy8si5745138edb.595.2020.06.20.07.29.29; Sat, 20 Jun 2020 07:30: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; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=Wl7MVMYt; 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 S1728194AbgFTOY6 (ORCPT + 99 others); Sat, 20 Jun 2020 10:24:58 -0400 Received: from mout.gmx.net ([212.227.17.22]:42063 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728181AbgFTOY5 (ORCPT ); Sat, 20 Jun 2020 10:24:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1592663054; bh=JuvY6E9cI7JcStIjYECxAe3yf3AL8r2MmuHmABemuRk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=Wl7MVMYtzLAaF3mXHah5MBWUajWsCIyJc3PdZMhTaQ+7bg/Re7VjkaQr6L2xRB8nh 4H63sAsWf35UNNgg7mOUsj/BE8HngpPbfZoVjy9NtVKwgk/YFB5tZkluN8XZMBwyY/ 8sLh0CFbTcR7DqipOk/eZb5F2iXrNb/hEQf9e4mE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ubuntu ([79.150.73.70]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1McpJq-1jD2kO0026-00a0tf; Sat, 20 Jun 2020 16:24:14 +0200 Date: Sat, 20 Jun 2020 16:23:40 +0200 From: Oscar Carter To: Steven Rostedt Cc: Oscar Carter , 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: <20200620142340.GA4330@ubuntu> References: <20200614070154.6039-1-oscar.carter@gmx.com> <20200615161738.18d07ce6@oasis.local.home> <20200615162245.13d3feff@oasis.local.home> <20200617162800.05a12502@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617162800.05a12502@oasis.local.home> User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID: V03:K1:XcZK8ql4Us3Vf6wLPkia735yxuYpLydI0oVASt5iEcVQKSJyH3N 6KMQN5zSfXGZ+DYVch+XELmF4CZdjJ7UshiZUtQwOpBf6l5AKKFrxFZlaUN2+R03l0FFkIn XM1/PFePcM0gOe9UVa9VU+Lti2fRaj0Pwusf4DtBMVO+lPm0cj4YXL4JvqNoV7LPj/I+UOr MqM/ada2N8QFt0HP7u2Aw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:8Nh3S9aszRs=:RhNgaCX2F/qtj0Tay5aVGJ OVFp+whK+iPB5KB3Sm6dz4eILf6skw44DbExwxbEEBGDPlvT/buIdprooCdHhk9kBOfv+k7ua lHz5tT/nnBx/0rZKczdGF5Uabx/uTf4pBiga0tLZ/DWAfN0Uj8iafR2yGBXqu447Rl24sfwh5 LvYqJTDAlSBJgV6p5UlO5q+xB5RnTkTHtRxphM15qNHuhmOH+TbXQ1OrRAO22sn0bVcjHySqJ oXv+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owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 04:28:00PM -0400, Steven Rostedt wrote: > On Mon, 15 Jun 2020 16:22:45 -0400 > Steven Rostedt wrote: > > > 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"= ) > > Would something like this work for you? > > -- Steve > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vml= inux.lds.h > index db600ef218d7..120babd9ba44 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -145,13 +145,18 @@ > * Need to also make ftrace_stub_graph point to ftrace_stub > * so that the same stub location may have different protocols > * and not mess up with C verifiers. > + * > + * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func > + * as some archs will have a different prototype for that function > + * but ftrace_ops_list_func() will have a single prototype. > */ > #define MCOUNT_REC() . =3D ALIGN(8); \ > __start_mcount_loc =3D .; \ > KEEP(*(__mcount_loc)) \ > KEEP(*(__patchable_function_entries)) \ > __stop_mcount_loc =3D .; \ > - ftrace_stub_graph =3D ftrace_stub; > + ftrace_stub_graph =3D ftrace_stub; \ > + ftrace_ops_list_func =3D arch_ftrace_ops_list_func; > #else > # ifdef CONFIG_FUNCTION_TRACER > # define MCOUNT_REC() ftrace_stub_graph =3D ftrace_stub; > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index f060838e9cbb..b775d399026e 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -119,14 +119,9 @@ struct ftrace_ops __rcu *ftrace_ops_list __read_mos= tly =3D &ftrace_list_end; > ftrace_func_t ftrace_trace_function __read_mostly =3D 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 > -/* 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) > -#endif > +/* Defined by vmlinux.lds.h see the commment above arch_ftrace_ops_list= _func for details */ > +void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct pt_regs *regs); > > static inline void ftrace_ops_init(struct ftrace_ops *ops) > { > @@ -6859,21 +6854,23 @@ __ftrace_ops_list_func(unsigned long ip, unsigne= d long parent_ip, > * Note, CONFIG_DYNAMIC_FTRACE_WITH_REGS expects a full regs to be save= d. > * An architecture can pass partial regs with ftrace_ops and still > * set the ARCH_SUPPORTS_FTRACE_OPS. > + * > + * In vmlinux.lds.h, ftrace_ops_list_func() is defined to be > + * arch_ftrace_ops_list_func. > */ > #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) > +void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_i= p, > + struct ftrace_ops *op, struct pt_regs *regs) > { > __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= ) > +void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_i= p) > { > __ftrace_ops_list_func(ip, parent_ip, NULL, NULL); > } > -NOKPROBE_SYMBOL(ftrace_ops_no_ops); > #endif > +NOKPROBE_SYMBOL(arch_ftrace_ops_list_func); > > /* > * If there's only one function registered but it does not support Thanks for your work and the proper patch sent [1]. I will follow the thread to see if I can help. [1] https://lore.kernel.org/lkml/20200617165616.52241bde@oasis.local.home/ Regards, Oscar Carter