LKML Archive on
 help / color / Atom feed
* [PATCH v2] parisc/kernel/ftrace: Remove function callback casts
@ 2020-07-04 15:50 Oscar Carter
  0 siblings, 0 replies; only message in thread
From: Oscar Carter @ 2020-07-04 15:50 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Ingo Molnar, James E . J . Bottomley,
	Helge Deller
  Cc: kernel-hardening, linux-parisc, linux-kernel, Oscar Carter

In an effort to enable -Wcast-function-type in the top-level Makefile to
support Control Flow Integrity builds, remove all the function callback

To do this add an inline function helper to get the address of a
function. This helper uses the "dereference_function_descriptor" as the
parisc64 architecture uses function descriptors instead of direct
addresses for functions.

Then, remove the cast to a function pointer type in the comparison
statement and use the function helper to get the address of every
function in the right and left operand. This can be done since the
comparison is against function address (these operands are not function

Co-developed-by: Helge Deller <>
Signed-off-by: Helge Deller <>
Signed-off-by: Oscar Carter <>

I have added the Co-develop-by tag and Signed-off-by tag to give credit to
Helge Deller if there are no objections.


Changelog v1->v2
- Use the function "dereference_function_descriptor" to get the function
  address instead of a direct cast to unsigned long type.
- Modify the commit changelog accordingly.
- Add the Co-developed-by tag and Signed-off-by tag to give credit to Helge

 arch/parisc/kernel/ftrace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 1df0f67ed667..c53576890881 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -24,6 +24,11 @@
 #define __hot __attribute__ ((__section__ ("")))

+static inline unsigned long ftrace_get_function_address(void *function)
+	return (unsigned long)dereference_function_descriptor(function);
  * Hook the return address and push it in the stack of return addrs
  * in current thread info.
@@ -64,7 +69,8 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent,
 				function_trace_op, regs);

-	if (ftrace_graph_return != (trace_func_graph_ret_t) ftrace_stub ||
+	if (ftrace_get_function_address(ftrace_graph_return) !=
+	    ftrace_get_function_address(ftrace_stub) ||
 	    ftrace_graph_entry != ftrace_graph_entry_stub) {
 		unsigned long *parent_rp;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-04 15:50 [PATCH v2] parisc/kernel/ftrace: Remove function callback casts Oscar Carter

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone