kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] kernel/trace: Remove function callback casts
@ 2020-07-19 15:50 Oscar Carter
  2020-07-19 15:50 ` [PATCH v2 1/2] kernel/trace: Prepare to remove " Oscar Carter
  2020-07-19 15:50 ` [PATCH v2 2/2] kernel/trace: Remove " Oscar Carter
  0 siblings, 2 replies; 18+ messages in thread
From: Oscar Carter @ 2020-07-19 15:50 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, Kees Cook
  Cc: Oscar Carter, linux-kernel, kernel-hardening, Jann Horn

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

ftrace_ops_list_func() can no longer be defined as ftrace_ops_no_ops().
The reason for ftrace_ops_no_ops() is to use that when an architecture
calls ftrace_ops_list_func() with only two parameters (called from
assembly). And to make sure there's no C side-effects, those archs call
ftrace_ops_no_ops() which only has two parameters, as the function
ftrace_ops_list_func() has four parameters.

This patch series is a new proposal for the work start by me [1] and
followed by the Steven Rostedt patch [2] and Jann Horn comments [3].

This new proposal removes all the function callback casts without the
use of linker magic and so is more CFI friendly.

The first patch prepares the needed infrastructure to remove all the
function callback casts. This infrastructure is based in a new union
type to manage two different function pointers (2 parameters and 4
parameters) using the same variable. Also create two static inline
helpers to set and compare against the fields of the new union type.
The helpers are duplicated for the archs that support ftrace ops and
for the archs that don't support ftrace ops as both cases use different
function prototypes.

The second patch removes all the function callback casts using the
infrastructure defined previously in the first patch.

[1] https://lore.kernel.org/kernel-hardening/20200614070154.6039-1-oscar.carter@gmx.com/
[2] https://lore.kernel.org/kernel-hardening/20200617165616.52241bde@oasis.local.home/
[3] https://lore.kernel.org/kernel-hardening/CAG48ez04Fj=1p61KAxAQWZ3f_z073fVUr8LsQgtKA9c-kcHmDQ@mail.gmail.com/

Changelog v1->v2
-Discard the idea behind the v1 patch.
-Use a new union type to manage two different function pointers.
-Create the infrastructure to remove the casts.
-Remove the casts using the new infrastructure.

Oscar Carter (2):
  kernel/trace: Prepare to remove function callback casts
  kernel/trace: Remove function callback casts

 kernel/trace/ftrace.c | 80 +++++++++++++++++++++++++++++++++----------
 1 file changed, 61 insertions(+), 19 deletions(-)

--
2.20.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-07-31 14:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-19 15:50 [PATCH v2 0/2] kernel/trace: Remove function callback casts Oscar Carter
2020-07-19 15:50 ` [PATCH v2 1/2] kernel/trace: Prepare to remove " Oscar Carter
2020-07-19 15:50 ` [PATCH v2 2/2] kernel/trace: Remove " Oscar Carter
2020-07-21 18:05   ` Steven Rostedt
2020-07-24 16:19     ` Oscar Carter
2020-07-24 16:35       ` Steven Rostedt
2020-07-24 17:14         ` Oscar Carter
2020-07-24 17:24           ` Oscar Carter
2020-07-24 17:36           ` Steven Rostedt
2020-07-24 17:40             ` Steven Rostedt
2020-07-24 17:48               ` Steven Rostedt
2020-07-24 17:55               ` Oscar Carter
2020-07-24 18:34                 ` Steven Rostedt
2020-07-25 15:09                   ` Oscar Carter
2020-07-25 15:19                     ` Oscar Carter
2020-07-26 15:52                     ` Oscar Carter
2020-07-27 13:53                       ` Steven Rostedt
2020-07-31 14:41                         ` Oscar Carter

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