Skip to content

Commit ed6d189

Browse files
authored
Merge pull request wolfSSL#8980 from douzzer/20250706-linuxkm-fixes
20250706-linuxkm-fixes
2 parents ae48ee4 + f49e583 commit ed6d189

File tree

12 files changed

+430
-261
lines changed

12 files changed

+430
-261
lines changed

.wolfssl_known_macro_extras

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ CONFIG_CRYPTO_GCM
6565
CONFIG_CRYPTO_HMAC
6666
CONFIG_CRYPTO_MANAGER
6767
CONFIG_CRYPTO_RSA
68+
CONFIG_CRYPTO_SELFTESTS_FULL
6869
CONFIG_CRYPTO_SHA1
6970
CONFIG_CRYPTO_SHA256
7071
CONFIG_CRYPTO_SHA3
@@ -774,7 +775,6 @@ WOLFSSL_NO_KCAPI_SHA224
774775
WOLFSSL_NO_OCSP_DATE_CHECK
775776
WOLFSSL_NO_OCSP_ISSUER_CHAIN_CHECK
776777
WOLFSSL_NO_OCSP_OPTIONAL_CERTS
777-
WOLFSSL_NO_PUBLIC_FFDHE
778778
WOLFSSL_NO_RSA_KEY_CHECK
779779
WOLFSSL_NO_SERVER_GROUPS_EXT
780780
WOLFSSL_NO_SESSION_STATS

linuxkm/Kbuild

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ endif
151151

152152
ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
153153

154+
LDFLAGS_libwolfssl.o += -T $(src)/wolfcrypt.lds
155+
154156
rename-pie-text-and-data-sections: $(WOLFSSL_OBJ_TARGETS)
155157

156158
ifndef NM
@@ -186,8 +188,40 @@ ifneq "$(quiet)" "silent_"
186188
endif
187189
cd "$(obj)" || exit $$?
188190
for file in $(WOLFCRYPT_PIE_FILES); do
189-
$(OBJCOPY) --rename-section .text=.text.wolfcrypt --rename-section .data=.data.wolfcrypt --rename-section .rodata=.rodata.wolfcrypt "$$file" || exit $$?
191+
$(OBJCOPY) --rename-section .text=.text.wolfcrypt \
192+
--rename-section .text.unlikely=.text.wolfcrypt \
193+
--rename-section .rodata=.rodata.wolfcrypt \
194+
--rename-section .rodata.str1.1=.rodata.wolfcrypt \
195+
--rename-section .rodata.str1.8=.rodata.wolfcrypt \
196+
--rename-section .data=.data.wolfcrypt \
197+
--rename-section .data.rel.local=.data.wolfcrypt \
198+
--rename-section .bss=.bss.wolfcrypt "$$file" || exit $$?
190199
done
200+
[ "$(KERNEL_ARCH_X86)" != "yes" ] || \
201+
{ $(READELF) --syms $(WOLFCRYPT_PIE_FILES) | \
202+
$(AWK) -v obj="$(obj)" ' \
203+
/File:/ { \
204+
if (substr($$2, 1, length(obj)) == obj) { \
205+
curfile = substr($$2, length(obj) + 2); \
206+
} else { \
207+
curfile=$$2; \
208+
} \
209+
next; \
210+
} \
211+
{ \
212+
if (($$4 == "SECTION") && ($$8 !~ "wolfcrypt")) {\
213+
if (! ((curfile ";" $$8) in warned_on)) { \
214+
print curfile ": " $$8 >"/dev/stderr"; \
215+
warned_on[curfile ": " $$8] = 1; \
216+
++warnings; \
217+
}}} \
218+
END { \
219+
if (warnings) { \
220+
exit(1); \
221+
} else { \
222+
exit(0); \
223+
}}'; } || \
224+
{ echo 'Error: section(s) missed by containerization.' >&2; exit 1; }
191225
ifneq "$(quiet)" "silent_"
192226
echo ' wolfCrypt .{text,data,rodata} sections containerized to .{text,data,rodata}.wolfcrypt'
193227
endif

linuxkm/linuxkm_memory.c

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,6 @@
2121

2222
/* included by wolfcrypt/src/memory.c */
2323

24-
#ifdef HAVE_KVMALLOC
25-
/* adapted from kvrealloc() draft by Changli Gao, 2010-05-13 */
26-
void *lkm_realloc(void *ptr, size_t newsize) {
27-
void *nptr;
28-
size_t oldsize;
29-
30-
if (unlikely(newsize == 0)) {
31-
kvfree(ptr);
32-
return ZERO_SIZE_PTR;
33-
}
34-
35-
if (unlikely(ptr == NULL))
36-
return kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE);
37-
38-
if (is_vmalloc_addr(ptr)) {
39-
/* no way to discern the size of the old allocation,
40-
* because the kernel doesn't export find_vm_area(). if
41-
* it did, we could then call get_vm_area_size() on the
42-
* returned struct vm_struct.
43-
*/
44-
return NULL;
45-
} else {
46-
#ifndef __PIE__
47-
struct page *page;
48-
49-
page = virt_to_head_page(ptr);
50-
if (PageSlab(page) || PageCompound(page)) {
51-
if (newsize < PAGE_SIZE)
52-
#endif /* ! __PIE__ */
53-
return krealloc(ptr, newsize, GFP_KERNEL);
54-
#ifndef __PIE__
55-
oldsize = ksize(ptr);
56-
} else {
57-
oldsize = page->private;
58-
if (newsize <= oldsize)
59-
return ptr;
60-
}
61-
#endif /* ! __PIE__ */
62-
}
63-
64-
nptr = kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE);
65-
if (nptr != NULL) {
66-
memcpy(nptr, ptr, oldsize);
67-
kvfree(ptr);
68-
}
69-
70-
return nptr;
71-
}
72-
#endif /* HAVE_KVMALLOC */
73-
7424
#if defined(__PIE__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
7525
/* needed in 6.1+ because show_free_areas() static definition in mm.h calls
7626
* __show_free_areas(), which isn't exported (neither was show_free_areas()).

0 commit comments

Comments
 (0)