mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 13:00:52 +02:00
linuxkm/module_hooks.c: in dump_to_file(), accommodate mis-prototyped kernel_write() in kernels 3.9-4.13.
This commit is contained in:
+20
-7
@@ -268,16 +268,19 @@ static ssize_t dump_to_file(const char *path, const u8 *buf, size_t buf_len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
fp = filp_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
fp = filp_open(path, O_WRONLY | O_CREAT, 0644);
|
||||
if (IS_ERR(fp)) {
|
||||
pr_err("libwolfssl: cannot open %s: %ld\n", path, PTR_ERR(fp));
|
||||
return PTR_ERR(fp);
|
||||
}
|
||||
|
||||
WC_SANITIZE_DISABLE();
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
||||
/* kernel_write() exported by 7bb307e894d51 */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
|
||||
/* kernel_write() fixed by e13ec939e9 */
|
||||
ret = kernel_write(fp, buf, buf_len, &pos);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
||||
/* kernel_write() exported by 7bb307e894d51 */
|
||||
ret = kernel_write(fp, (char *)buf, buf_len, pos);
|
||||
#else
|
||||
ret = vfs_write(fp, buf, buf_len, &pos);
|
||||
#endif
|
||||
@@ -575,12 +578,22 @@ static int wolfssl_init(void)
|
||||
|
||||
#ifdef WC_SYM_RELOC_TABLES
|
||||
if (text_dump_path) {
|
||||
if (dump_to_file(text_dump_path, (u8 *)__wc_text_start, (size_t)((uintptr_t)__wc_text_end - (uintptr_t)__wc_text_start)) > 0)
|
||||
pr_info("libwolfssl: dumped .wolfcrypt_text (%zu bytes) to %s.\n", (size_t)((uintptr_t)__wc_text_end - (uintptr_t)__wc_text_start), text_dump_path);
|
||||
if (dump_to_file(text_dump_path,
|
||||
(u8 *)__wc_text_start,
|
||||
(size_t)((uintptr_t)__wc_text_end - (uintptr_t)__wc_text_start)
|
||||
> 0)
|
||||
pr_info("libwolfssl: dumped .wolfcrypt_text (%zu bytes) to %s.\n",
|
||||
(size_t)((uintptr_t)__wc_text_end - (uintptr_t)__wc_text_start),
|
||||
text_dump_path);
|
||||
}
|
||||
if (rodata_dump_path) {
|
||||
if (dump_to_file(rodata_dump_path, (u8 *)__wc_rodata_start, (size_t)((uintptr_t)__wc_rodata_end - (uintptr_t)__wc_rodata_start)) > 0)
|
||||
pr_info("libwolfssl: dumped .wolfcrypt_rodata (%zu bytes) to %s.\n", (size_t)((uintptr_t)__wc_rodata_end - (uintptr_t)__wc_rodata_start), rodata_dump_path);
|
||||
if (dump_to_file(rodata_dump_path,
|
||||
(u8 *)__wc_rodata_start,
|
||||
(size_t)((uintptr_t)__wc_rodata_end - (uintptr_t)__wc_rodata_start))
|
||||
> 0)
|
||||
pr_info("libwolfssl: dumped .wolfcrypt_rodata (%zu bytes) to %s.\n",
|
||||
(size_t)((uintptr_t)__wc_rodata_end - (uintptr_t)__wc_rodata_start),
|
||||
rodata_dump_path);
|
||||
}
|
||||
#else
|
||||
if ((text_dump_path != NULL) ||
|
||||
|
||||
Reference in New Issue
Block a user