linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Carter <oscar.carter@gmx.com>
To: Kees Cook <keescook@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
	Helge Deller <deller@gmx.de>
Cc: kernel-hardening@lists.openwall.com,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Oscar Carter <oscar.carter@gmx.com>
Subject: [PATCH v2] parisc/kernel/ftrace: Remove function callback casts
Date: Sat,  4 Jul 2020 17:50:57 +0200	[thread overview]
Message-ID: <20200704155057.3959-1-oscar.carter@gmx.com> (raw)

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 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
calls).

Co-developed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
Hi,

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

Thanks.

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
  Deller.

 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__ (".text.hot")))

 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+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);

 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-	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;

--
2.20.1


                 reply	other threads:[~2020-07-04 15:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200704155057.3959-1-oscar.carter@gmx.com \
    --to=oscar.carter@gmx.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=deller@gmx.de \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).