@@ -268,16 +268,19 @@ static ssize_t dump_to_file(const char *path, const u8 *buf, size_t buf_len)
268268 return ret ;
269269 }
270270
271- fp = filp_open (path , O_WRONLY | O_CREAT | O_TRUNC , 0644 );
271+ fp = filp_open (path , O_WRONLY | O_CREAT , 0644 );
272272 if (IS_ERR (fp )) {
273273 pr_err ("libwolfssl: cannot open %s: %ld\n" , path , PTR_ERR (fp ));
274274 return PTR_ERR (fp );
275275 }
276276
277277 WC_SANITIZE_DISABLE ();
278- #if LINUX_VERSION_CODE >= KERNEL_VERSION (3 , 9 , 0 )
279- /* kernel_write() exported by 7bb307e894d51 */
278+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (4 , 14 , 0 )
279+ /* kernel_write() fixed by e13ec939e9 */
280280 ret = kernel_write (fp , buf , buf_len , & pos );
281+ #elif LINUX_VERSION_CODE >= KERNEL_VERSION (3 , 9 , 0 )
282+ /* kernel_write() exported by 7bb307e894d51 */
283+ ret = kernel_write (fp , (char * )buf , buf_len , pos );
281284#else
282285 ret = vfs_write (fp , buf , buf_len , & pos );
283286#endif
@@ -575,12 +578,22 @@ static int wolfssl_init(void)
575578
576579#ifdef WC_SYM_RELOC_TABLES
577580 if (text_dump_path ) {
578- if (dump_to_file (text_dump_path , (u8 * )__wc_text_start , (size_t )((uintptr_t )__wc_text_end - (uintptr_t )__wc_text_start )) > 0 )
579- 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 );
581+ if (dump_to_file (text_dump_path ,
582+ (u8 * )__wc_text_start ,
583+ (size_t )((uintptr_t )__wc_text_end - (uintptr_t )__wc_text_start )
584+ > 0 )
585+ pr_info ("libwolfssl: dumped .wolfcrypt_text (%zu bytes) to %s.\n" ,
586+ (size_t )((uintptr_t )__wc_text_end - (uintptr_t )__wc_text_start ),
587+ text_dump_path );
580588 }
581589 if (rodata_dump_path ) {
582- if (dump_to_file (rodata_dump_path , (u8 * )__wc_rodata_start , (size_t )((uintptr_t )__wc_rodata_end - (uintptr_t )__wc_rodata_start )) > 0 )
583- 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 );
590+ if (dump_to_file (rodata_dump_path ,
591+ (u8 * )__wc_rodata_start ,
592+ (size_t )((uintptr_t )__wc_rodata_end - (uintptr_t )__wc_rodata_start ))
593+ > 0 )
594+ pr_info ("libwolfssl: dumped .wolfcrypt_rodata (%zu bytes) to %s.\n" ,
595+ (size_t )((uintptr_t )__wc_rodata_end - (uintptr_t )__wc_rodata_start ),
596+ rodata_dump_path );
584597 }
585598#else
586599 if ((text_dump_path != NULL ) ||
0 commit comments