From 217ec4ebd3fa2eee57a7b62f9110ae734c6e0688 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 21 Aug 2020 12:10:17 -0500 Subject: [PATCH] lkm: tweaks to self-test dynamics/messages. --- linuxkm/lkm_testcrypto.c | 6 +++++- linuxkm/module_hooks.c | 4 +++- wolfssl/wolfcrypt/wc_port.h | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/linuxkm/lkm_testcrypto.c b/linuxkm/lkm_testcrypto.c index e08360769..4972e4154 100644 --- a/linuxkm/lkm_testcrypto.c +++ b/linuxkm/lkm_testcrypto.c @@ -113,7 +113,7 @@ _Pragma("GCC diagnostic ignored \"-Wunused-function\""); #include #endif - #ifdef WOLFSSL_LINUXKM + #if defined(WOLFSSL_LINUXKM) && !defined(DEBUG_WOLFSSL_VERBOSE) #undef printf #define printf(...) ({}) #endif @@ -452,7 +452,11 @@ static int err_sys(const char* msg, int es) (void)msg; (void)es; +#ifdef WOLFSSL_LINUXKM + lkm_printf("%s error = %d\n", msg, es); +#else printf("%s error = %d\n", msg, es); +#endif EXIT_TEST(-1); } diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index 520bbb619..13935e2b3 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -11,6 +11,7 @@ #include #ifndef NO_CRYPT_TEST #include +#include #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) @@ -28,7 +29,8 @@ static int wolfssl_init(void) #ifndef NO_CRYPT_TEST ret = wolfcrypt_test(NULL); if (ret < 0) { - pr_err("wolfcrypt_test() failed with code %d", ret); + pr_err("wolfcrypt self-test failed."); + msleep(10); return -ENOTRECOVERABLE; } pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " self-test passed. See https://www.wolfssl.com/ for information.\n"); diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index d503be0a9..641664618 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -111,7 +111,8 @@ /* work around namespace conflict between wolfssl/internal.h (enum HandShakeType) and linux/key.h (extern int()). */ #define key_update wc_key_update - #define printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args) + #define lkm_printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args) + #define printf(...) lkm_printf(__VA_ARGS__) #define XSNPRINTF snprintf /* needed to suppress inclusion of stdio.h in wolfssl/wolfcrypt/types.h */ /* the rigmarole around kstrtol() here is to accommodate its warn-unused-result attribute. */ #define XATOI(s) ({ long _xatoi_res = 0; int _xatoi_ret = kstrtol(s, 10, &_xatoi_res); if (_xatoi_ret != 0) { _xatoi_res = 0; } (int)_xatoi_res; })