Skip to content

Commit edf3c31

Browse files
authored
Merge pull request #9181 from douzzer/20250910-linuxkm-more-OBJECT_FILES_NON_STANDARD
20250910-linuxkm-more-OBJECT_FILES_NON_STANDARD
2 parents 484f352 + 0483468 commit edf3c31

6 files changed

Lines changed: 10 additions & 93 deletions

File tree

linuxkm/Kbuild

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
127127
endif
128128
$(WOLFCRYPT_PIE_FILES): ccflags-y += $(PIE_SUPPORT_FLAGS) $(PIE_FLAGS)
129129
$(WOLFCRYPT_PIE_FILES): ccflags-remove-y += -pg
130+
$(obj)/linuxkm/module_hooks.o: ccflags-y += $(PIE_SUPPORT_FLAGS)
130131
# using inline retpolines leads to "unannotated intra-function call"
131132
# warnings from objtool without this:
133+
undefine CONFIG_OBJTOOL
132134
$(WOLFCRYPT_PIE_FILES): OBJECT_FILES_NON_STANDARD := y
133-
$(obj)/linuxkm/module_hooks.o: ccflags-y += $(PIE_SUPPORT_FLAGS)
134135
endif
135136

136137
ifdef KERNEL_EXTRA_CFLAGS_REMOVE

linuxkm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ifeq "$(ENABLED_LINUXKM_BENCHMARKS)" "yes"
5454
endif
5555

5656
ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
57-
WOLFCRYPT_PIE_FILES := linuxkm/pie_first.o $(filter wolfcrypt/src/%,$(WOLFSSL_OBJ_FILES)) linuxkm/pie_redirect_table.o linuxkm/pie_last.o
57+
WOLFCRYPT_PIE_FILES := $(filter wolfcrypt/src/%,$(WOLFSSL_OBJ_FILES)) linuxkm/pie_redirect_table.o
5858
WOLFSSL_OBJ_FILES := $(WOLFCRYPT_PIE_FILES) $(filter-out $(WOLFCRYPT_PIE_FILES),$(WOLFSSL_OBJ_FILES))
5959
endif
6060

linuxkm/include.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ EXTRA_DIST += m4/ax_linuxkm.m4 \
88
linuxkm/get_thread_size.c \
99
linuxkm/module_hooks.c \
1010
linuxkm/module_exports.c.template \
11-
linuxkm/pie_first.c \
1211
linuxkm/pie_redirect_table.c \
13-
linuxkm/pie_last.c \
1412
linuxkm/linuxkm_memory.c \
1513
linuxkm/linuxkm_wc_port.h \
1614
linuxkm/x86_vector_register_glue.c \

linuxkm/module_hooks.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extern const unsigned int wolfCrypt_PIE_rodata_end[];
9797
/* cheap portable ad-hoc hash function to confirm bitwise stability of the PIE
9898
* binary image.
9999
*/
100-
static unsigned int hash_span(char *start, char *end) {
100+
static unsigned int hash_span(const u8 *start, const u8 *end) {
101101
unsigned int sum = 1;
102102
while (start < end) {
103103
unsigned int rotate_by;
@@ -419,24 +419,18 @@ static int wolfssl_init(void)
419419
#endif
420420

421421
{
422-
char *pie_text_start = (char *)wolfCrypt_PIE_first_function;
423-
char *pie_text_end = (char *)wolfCrypt_PIE_last_function;
424-
char *pie_rodata_start = (char *)wolfCrypt_PIE_rodata_start;
425-
char *pie_rodata_end = (char *)wolfCrypt_PIE_rodata_end;
426-
unsigned int text_hash, rodata_hash;
427-
428-
text_hash = hash_span(pie_text_start, pie_text_end);
429-
rodata_hash = hash_span(pie_rodata_start, pie_rodata_end);
422+
unsigned int text_hash = hash_span(__wc_text_start, __wc_text_end);
423+
unsigned int rodata_hash = hash_span(__wc_rodata_start, __wc_rodata_end);
430424

431425
/* note, "%pK" conceals the actual layout information. "%px" exposes
432426
* the true module start address, which is potentially useful to an
433427
* attacker.
434428
*/
435429
pr_info("wolfCrypt section hashes (spans): text 0x%x (%lu), rodata 0x%x (%lu), offset %c0x%lx\n",
436-
text_hash, pie_text_end-pie_text_start,
437-
rodata_hash, pie_rodata_end-pie_rodata_start,
438-
pie_text_start < pie_rodata_start ? '+' : '-',
439-
pie_text_start < pie_rodata_start ? pie_rodata_start - pie_text_start : pie_text_start - pie_rodata_start);
430+
text_hash, __wc_text_end - __wc_text_start,
431+
rodata_hash, __wc_rodata_end - __wc_rodata_start,
432+
&__wc_text_start[0] < &__wc_rodata_start[0] ? '+' : '-',
433+
&__wc_text_start[0] < &__wc_rodata_start[0] ? &__wc_rodata_start[0] - &__wc_text_start[0] : &__wc_text_start[0] - &__wc_rodata_start[0]);
440434
pr_info("wolfCrypt segments: text=%x-%x, rodata=%x-%x, "
441435
"rwdata=%x-%x, bss=%x-%x\n",
442436
(unsigned)(uintptr_t)__wc_text_start,

linuxkm/pie_first.c

Lines changed: 0 additions & 38 deletions
This file was deleted.

linuxkm/pie_last.c

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)