Skip to content

Commit

Permalink
linuxkm: work around aarch64 dependency on alt_cb_patch_nops for enab…
Browse files Browse the repository at this point in the history
…le-linuxkm-pie (FIPS support).
  • Loading branch information
douzzer committed Nov 26, 2024
1 parent ea8c7c8 commit 7dcec3e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions linuxkm/linuxkm_wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\""); /* needed for kernel 4.14.336 */

#include <linux/kconfig.h>

#if defined(__PIE__) && defined(CONFIG_ARM64)
#define alt_cb_patch_nops my__alt_cb_patch_nops
#endif

#include <linux/kernel.h>
#include <linux/ctype.h>

Expand Down Expand Up @@ -668,6 +673,18 @@
typeof(dump_stack) *dump_stack;
#endif

#ifdef CONFIG_ARM64
#ifdef __PIE__
/* alt_cb_patch_nops defined early to allow shimming in system
* headers, but now we need the native one.
*/
#undef alt_cb_patch_nops
typeof(my__alt_cb_patch_nops) *alt_cb_patch_nops;
#else
typeof(alt_cb_patch_nops) *alt_cb_patch_nops;
#endif
#endif

const void *_last_slot;
};

Expand Down
4 changes: 4 additions & 0 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) {
wolfssl_linuxkm_pie_redirect_table.dump_stack = dump_stack;
#endif

#ifdef CONFIG_ARM64
wolfssl_linuxkm_pie_redirect_table.alt_cb_patch_nops = alt_cb_patch_nops;
#endif

/* runtime assert that the table has no null slots after initialization. */
{
unsigned long *i;
Expand Down
10 changes: 10 additions & 0 deletions wolfcrypt/src/wc_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -4238,3 +4238,13 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
#endif /* Environment check */

#endif /* not SINGLE_THREADED */

#if defined(WOLFSSL_LINUXKM) && defined(CONFIG_ARM64) && \
defined(USE_WOLFSSL_LINUXKM_PIE_REDIRECT_TABLE)
noinstr void my__alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,
__le32 *updptr, int nr_inst)
{
return (wolfssl_linuxkm_get_pie_redirect_table()->
alt_cb_patch_nops)(alt, origptr, updptr, nr_inst);
}
#endif

0 comments on commit 7dcec3e

Please sign in to comment.