Skip to content

Commit

Permalink
Merge pull request #8227 from douzzer/20241125-linuxkm-aarch64-pie
Browse files Browse the repository at this point in the history
20241125-linuxkm-aarch64-pie
  • Loading branch information
JacobBarthelmeh authored Nov 26, 2024
2 parents 29dc0f5 + 7dcec3e commit 70d5954
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 70d5954

Please sign in to comment.