Skip to content

Commit 70d5954

Browse files
Merge pull request wolfSSL#8227 from douzzer/20241125-linuxkm-aarch64-pie
20241125-linuxkm-aarch64-pie
2 parents 29dc0f5 + 7dcec3e commit 70d5954

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

linuxkm/linuxkm_wc_port.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@
118118
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\""); /* needed for kernel 4.14.336 */
119119

120120
#include <linux/kconfig.h>
121+
122+
#if defined(__PIE__) && defined(CONFIG_ARM64)
123+
#define alt_cb_patch_nops my__alt_cb_patch_nops
124+
#endif
125+
121126
#include <linux/kernel.h>
122127
#include <linux/ctype.h>
123128

@@ -668,6 +673,18 @@
668673
typeof(dump_stack) *dump_stack;
669674
#endif
670675

676+
#ifdef CONFIG_ARM64
677+
#ifdef __PIE__
678+
/* alt_cb_patch_nops defined early to allow shimming in system
679+
* headers, but now we need the native one.
680+
*/
681+
#undef alt_cb_patch_nops
682+
typeof(my__alt_cb_patch_nops) *alt_cb_patch_nops;
683+
#else
684+
typeof(alt_cb_patch_nops) *alt_cb_patch_nops;
685+
#endif
686+
#endif
687+
671688
const void *_last_slot;
672689
};
673690

linuxkm/module_hooks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,10 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) {
595595
wolfssl_linuxkm_pie_redirect_table.dump_stack = dump_stack;
596596
#endif
597597

598+
#ifdef CONFIG_ARM64
599+
wolfssl_linuxkm_pie_redirect_table.alt_cb_patch_nops = alt_cb_patch_nops;
600+
#endif
601+
598602
/* runtime assert that the table has no null slots after initialization. */
599603
{
600604
unsigned long *i;

wolfcrypt/src/wc_port.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,3 +4238,13 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
42384238
#endif /* Environment check */
42394239

42404240
#endif /* not SINGLE_THREADED */
4241+
4242+
#if defined(WOLFSSL_LINUXKM) && defined(CONFIG_ARM64) && \
4243+
defined(USE_WOLFSSL_LINUXKM_PIE_REDIRECT_TABLE)
4244+
noinstr void my__alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,
4245+
__le32 *updptr, int nr_inst)
4246+
{
4247+
return (wolfssl_linuxkm_get_pie_redirect_table()->
4248+
alt_cb_patch_nops)(alt, origptr, updptr, nr_inst);
4249+
}
4250+
#endif

0 commit comments

Comments
 (0)