mirror of https://github.com/wolfSSL/wolfssl.git
tweaks for linuxkm targeting clang-built kernels:
linuxkm/: when logging PTR_ERR(), cast it to int, and use "%d" as the format. Globally, `#define PTR_ERR(x) ((int)PTR_ERR(x))` in linuxkm_wc_port.h to fix clang warnings on kernel headers. linuxkm/lkcapi_aes_glue.c: add casts in linuxkm_test_aesgcm() to mollify clang. linuxkm/linuxkm_wc_port.h, linuxkm/module_hooks.c: * add __clang__ compat code to allow including clang stdatomic.h while masking out kernel-incompatible __CLANG_STDINT_H. * add clang-specific suppressions for kernel headers (-Wshorten-64-to-32, -Wframe-address). linuxkm/lkcapi_sha_glue.c: * in wc__get_random_bytes(), add bounds-checking for len. * in wc_extract_crng_user(), fix type conflicts. wolfssl/wolfcrypt/wc_port.h and wolfssl/wolfcrypt/types.h: * move the old-FIPS compatibility mapping from INLINE to WC_INLINE from types.h to wc_port.h. * activate stdatomic.h for clang kernel module builds. linuxkm/Kbuild: * add clang-specific flags. * add gcc gate around gcc-specific flags. * allow override value for MAX_STACK_FRAME_SIZE. wolfcrypt/src/asn.c: add casts in GetFormattedTime_ex() to mollify clang build of linuxkm.pull/10696/head
parent
3811ec0aa7
commit
262b0ed3b8
|
|
@ -80,11 +80,21 @@ endif
|
|||
|
||||
HOST_EXTRACFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CFLAGS) -static -fno-omit-frame-pointer
|
||||
|
||||
ifdef CONFIG_CC_IS_CLANG
|
||||
HOST_EXTRACFLAGS += -mfunction-return=keep
|
||||
endif
|
||||
|
||||
# "-mindirect-branch=keep -mfunction-return=keep" to avoid "undefined reference
|
||||
# to `__x86_return_thunk'" on CONFIG_RETHUNK kernels (5.19.0-rc7)
|
||||
ifdef CONFIG_CC_IS_GCC
|
||||
ifeq "$(KERNEL_ARCH_X86)" "yes"
|
||||
HOST_EXTRACFLAGS += -mindirect-branch=keep -mfunction-return=keep
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CONFIG_CC_IS_CLANG
|
||||
WOLFSSL_CFLAGS += -Wno-unused-parameter
|
||||
endif
|
||||
|
||||
# this rule is needed to get build to succeed in 4.x (get_thread_size still doesn't get built)
|
||||
$(obj)/linuxkm/get_thread_size: $(src)/linuxkm/get_thread_size.c
|
||||
|
|
@ -93,7 +103,9 @@ ifndef KERNEL_THREAD_STACK_SIZE
|
|||
$(WOLFSSL_OBJ_TARGETS): | $(obj)/linuxkm/get_thread_size
|
||||
KERNEL_THREAD_STACK_SIZE=$(shell test -x $(obj)/linuxkm/get_thread_size && $(obj)/linuxkm/get_thread_size || echo 16384)
|
||||
endif
|
||||
MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4)))
|
||||
ifndef MAX_STACK_FRAME_SIZE
|
||||
MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4)))
|
||||
endif
|
||||
|
||||
$(LIBWOLFSSL_NAME)-y := $(WOLFSSL_OBJ_FILES) linuxkm/module_hooks.o linuxkm/module_exports.o
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,31 @@
|
|||
#define _GCC_STDINT_H
|
||||
#define WC_PTR_TYPE uintptr_t
|
||||
|
||||
#ifdef __clang__
|
||||
/* inhibit inclusion of LLVM stdint.h (included via LLVM stdatomic.h) to
|
||||
* avoid conflicts with linux/types.h.
|
||||
*/
|
||||
#define __CLANG_STDINT_H
|
||||
#define uint_least64_t uint64_t
|
||||
#define int_least64_t int64_t
|
||||
#define uint_least32_t uint32_t
|
||||
#define int_least32_t int32_t
|
||||
#define uint_least16_t uint16_t
|
||||
#define int_least16_t int16_t
|
||||
#define uint_least8_t uint8_t
|
||||
#define int_least8_t int8_t
|
||||
#define uint_fast64_t uint64_t
|
||||
#define int_fast64_t int64_t
|
||||
#define uint_fast32_t uint32_t
|
||||
#define int_fast32_t int32_t
|
||||
#define uint_fast16_t uint16_t
|
||||
#define int_fast16_t int16_t
|
||||
#define uint_fast8_t uint8_t
|
||||
#define int_fast8_t int8_t
|
||||
#define uintmax_t uint64_t
|
||||
#define intmax_t int64_t
|
||||
#endif
|
||||
|
||||
/* needed to suppress inclusion of stdio.h in wolfssl/wolfcrypt/types.h */
|
||||
#define XSNPRINTF snprintf
|
||||
|
||||
|
|
@ -320,6 +345,10 @@
|
|||
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\""); /* needed for kernel 4.14.336 */
|
||||
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\""); /* needed for kernel 4.9.282 */
|
||||
_Pragma("GCC diagnostic ignored \"-Wattributes\"");
|
||||
#ifdef __clang__
|
||||
_Pragma("clang diagnostic ignored \"-Wshorten-64-to-32\"");
|
||||
_Pragma("clang diagnostic ignored \"-Wframe-address\"");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KASAN
|
||||
#ifndef WC_SANITIZE_DISABLE
|
||||
|
|
@ -776,6 +805,8 @@
|
|||
|
||||
_Pragma("GCC diagnostic pop");
|
||||
|
||||
#define PTR_ERR(x) ((int)PTR_ERR(x))
|
||||
|
||||
#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(7,0,0) && !defined(NO_AES)
|
||||
/* with CONFIG_FORTIFY_SOURCE we've seen false positive
|
||||
* maybe-uninitialized on counter in AES_GCM_encrypt_C(). This is easy
|
||||
|
|
@ -792,6 +823,7 @@
|
|||
unsigned int aSz, const unsigned char* c,
|
||||
unsigned int cSz, unsigned char* s, unsigned int sSz);
|
||||
#endif
|
||||
/* Need to suppress the otherwise-warned nullness checks in old FIPS aes.c. */
|
||||
_Pragma("GCC diagnostic ignored \"-Wnonnull-compare\"");
|
||||
#endif
|
||||
|
||||
|
|
@ -1211,8 +1243,8 @@
|
|||
typeof(wolfCrypt_FIPS_ft_ro_sanity) *wolfCrypt_FIPS_ft_ro_sanity;
|
||||
typeof(wolfCrypt_FIPS_f_ro_sanity) *wolfCrypt_FIPS_f_ro_sanity;
|
||||
typeof(wc_RunAllCast_fips) *wc_RunAllCast_fips;
|
||||
#endif
|
||||
#endif
|
||||
#endif /* FIPS_VERSION3_GE(6,0,0) */
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#if !defined(WOLFCRYPT_ONLY) && !defined(NO_CERTS)
|
||||
typeof(GetCA) *GetCA;
|
||||
|
|
|
|||
|
|
@ -1201,9 +1201,9 @@ static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
|
|||
#endif
|
||||
if (unlikely(IS_ERR(assoc))) {
|
||||
err = (int)PTR_ERR(assoc);
|
||||
pr_err("%s: scatterwalk_map failed: %ld\n",
|
||||
pr_err("%s: scatterwalk_map failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
|
||||
PTR_ERR(assoc));
|
||||
(int)PTR_ERR(assoc));
|
||||
assoc = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1415,9 +1415,9 @@ static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
|
|||
#endif
|
||||
if (unlikely(IS_ERR(in_map))) {
|
||||
err = (int)PTR_ERR(in_map);
|
||||
pr_err("%s: scatterwalk_map failed: %ld\n",
|
||||
pr_err("%s: scatterwalk_map failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
|
||||
PTR_ERR(in_map));
|
||||
(int)PTR_ERR(in_map));
|
||||
in_map = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1433,9 +1433,9 @@ static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
|
|||
#endif
|
||||
if (unlikely(IS_ERR(out_map))) {
|
||||
err = (int)PTR_ERR(out_map);
|
||||
pr_err("%s: scatterwalk_map failed: %ld\n",
|
||||
pr_err("%s: scatterwalk_map failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
|
||||
PTR_ERR(out_map));
|
||||
(int)PTR_ERR(out_map));
|
||||
out_map = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1916,9 +1916,9 @@ static int AesCcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4309_p)
|
|||
#endif
|
||||
if (unlikely(IS_ERR(in_map))) {
|
||||
err = (int)PTR_ERR(in_map);
|
||||
pr_err("%s: scatterwalk_map failed: %ld\n",
|
||||
pr_err("%s: scatterwalk_map failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
|
||||
PTR_ERR(in_map));
|
||||
(int)PTR_ERR(in_map));
|
||||
in_map = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1934,9 +1934,9 @@ static int AesCcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4309_p)
|
|||
#endif
|
||||
if (unlikely(IS_ERR(out_map))) {
|
||||
err = (int)PTR_ERR(out_map);
|
||||
pr_err("%s: scatterwalk_map failed: %ld\n",
|
||||
pr_err("%s: scatterwalk_map failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
|
||||
PTR_ERR(out_map));
|
||||
(int)PTR_ERR(out_map));
|
||||
out_map = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3129,8 +3129,8 @@ static int linuxkm_test_aescbc(void)
|
|||
|
||||
tfm = crypto_alloc_skcipher(WOLFKM_AESCBC_NAME, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %ld\n",
|
||||
WOLFKM_AESCBC_DRIVER, PTR_ERR(tfm));
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
|
||||
WOLFKM_AESCBC_DRIVER, (int)PTR_ERR(tfm));
|
||||
tfm = NULL;
|
||||
goto test_cbc_end;
|
||||
}
|
||||
|
|
@ -3342,8 +3342,8 @@ static int linuxkm_test_aescfb(void)
|
|||
|
||||
tfm = crypto_alloc_skcipher(WOLFKM_AESCFB_NAME, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %ld\n",
|
||||
WOLFKM_AESCFB_DRIVER, PTR_ERR(tfm));
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
|
||||
WOLFKM_AESCFB_DRIVER, (int)PTR_ERR(tfm));
|
||||
tfm = NULL;
|
||||
goto test_cfb_end;
|
||||
}
|
||||
|
|
@ -3606,8 +3606,8 @@ static int linuxkm_test_aesgcm(void)
|
|||
|
||||
tfm = crypto_alloc_aead(WOLFKM_AESGCM_NAME, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating AES aead algorithm %s failed: %ld\n",
|
||||
WOLFKM_AESGCM_DRIVER, PTR_ERR(tfm));
|
||||
pr_err("error: allocating AES aead algorithm %s failed: %d\n",
|
||||
WOLFKM_AESGCM_DRIVER, (int)PTR_ERR(tfm));
|
||||
tfm = NULL;
|
||||
goto test_gcm_end;
|
||||
}
|
||||
|
|
@ -3658,7 +3658,7 @@ static int linuxkm_test_aesgcm(void)
|
|||
|
||||
sg_init_table(dst, 2);
|
||||
sg_set_buf(dst, assoc2, sizeof(assoc));
|
||||
sg_set_buf(&dst[1], enc2, decryptLen);
|
||||
sg_set_buf(&dst[1], enc2, (unsigned int)decryptLen);
|
||||
|
||||
aead_request_set_callback(req, 0, NULL, NULL);
|
||||
aead_request_set_ad(req, sizeof(assoc));
|
||||
|
|
@ -3686,7 +3686,7 @@ static int linuxkm_test_aesgcm(void)
|
|||
/* Now decrypt crypto request. Reverse src and dst. */
|
||||
XMEMSET(dec2, 0, decryptLen);
|
||||
aead_request_set_ad(req, sizeof(assoc));
|
||||
aead_request_set_crypt(req, dst, src, decryptLen, iv);
|
||||
aead_request_set_crypt(req, dst, src, (unsigned int)decryptLen, iv);
|
||||
|
||||
ret = crypto_aead_decrypt(req);
|
||||
|
||||
|
|
@ -4209,7 +4209,7 @@ static int aes_xts_128_test(void)
|
|||
|
||||
tfm = crypto_alloc_skcipher(WOLFKM_AESXTS_NAME, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
ret = PTR_ERR(tfm);
|
||||
ret = (int)PTR_ERR(tfm);
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
|
||||
WOLFKM_AESXTS_DRIVER, ret);
|
||||
tfm = NULL;
|
||||
|
|
@ -4706,7 +4706,7 @@ static int aes_xts_256_test(void)
|
|||
|
||||
tfm = crypto_alloc_skcipher(WOLFKM_AESXTS_NAME, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
ret = PTR_ERR(tfm);
|
||||
ret = (int)PTR_ERR(tfm);
|
||||
pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
|
||||
WOLFKM_AESXTS_DRIVER, ret);
|
||||
tfm = NULL;
|
||||
|
|
|
|||
|
|
@ -2901,8 +2901,8 @@ static int linuxkm_test_kpp_driver(const char * driver,
|
|||
* */
|
||||
tfm = crypto_alloc_kpp(driver, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating kpp algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating kpp algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
if (PTR_ERR(tfm) == -ENOMEM)
|
||||
test_rc = MEMORY_E;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -911,15 +911,15 @@ static int linuxkm_test_ecdh_nist_driver(const char * driver,
|
|||
#if defined(HAVE_FIPS) && defined(CONFIG_CRYPTO_MANAGER) && \
|
||||
!defined(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS)
|
||||
if ((PTR_ERR(tfm) == -ENOENT) && fips_enabled) {
|
||||
pr_info("info: skipping unsupported kpp algorithm %s: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_info("info: skipping unsupported kpp algorithm %s: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
test_rc = NOT_COMPILED_IN;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pr_err("error: allocating kpp algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating kpp algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
if (PTR_ERR(tfm) == -ENOMEM)
|
||||
test_rc = MEMORY_E;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -749,15 +749,15 @@ static int linuxkm_test_ecdsa_nist_driver(const char * driver,
|
|||
* in kernel crypto/testmgr.c, and the kernel will block
|
||||
* its allocation if fips_enabled is set. */
|
||||
if ((PTR_ERR(tfm) == -ENOENT) && fips_enabled) {
|
||||
pr_info("info: skipping unsupported akcipher algorithm %s: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_info("info: skipping unsupported akcipher algorithm %s: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
test_rc = NOT_COMPILED_IN;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
if (PTR_ERR(tfm) == -ENOMEM)
|
||||
test_rc = MEMORY_E;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ WC_MAYBE_UNUSED static int check_skcipher_driver_masking(struct crypto_skcipher
|
|||
tfm = crypto_alloc_skcipher(alg_name, 0, 0);
|
||||
}
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating skcipher algorithm %s failed: %ld\n",
|
||||
alg_name, PTR_ERR(tfm));
|
||||
pr_err("error: allocating skcipher algorithm %s failed: %d\n",
|
||||
alg_name, (int)PTR_ERR(tfm));
|
||||
return -EINVAL;
|
||||
}
|
||||
actual_driver_name = crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm));
|
||||
|
|
@ -158,8 +158,8 @@ WC_MAYBE_UNUSED static int check_aead_driver_masking(struct crypto_aead *tfm, co
|
|||
tfm = crypto_alloc_aead(alg_name, 0, 0);
|
||||
}
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating AEAD algorithm %s failed: %ld\n",
|
||||
alg_name, PTR_ERR(tfm));
|
||||
pr_err("error: allocating AEAD algorithm %s failed: %d\n",
|
||||
alg_name, (int)PTR_ERR(tfm));
|
||||
return -EINVAL;
|
||||
}
|
||||
actual_driver_name = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
|
||||
|
|
@ -191,8 +191,8 @@ WC_MAYBE_UNUSED static int check_shash_driver_masking(struct crypto_shash *tfm,
|
|||
tfm = crypto_alloc_shash(alg_name, 0, 0);
|
||||
}
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating shash algorithm %s failed: %ld\n",
|
||||
alg_name, PTR_ERR(tfm));
|
||||
pr_err("error: allocating shash algorithm %s failed: %d\n",
|
||||
alg_name, (int)PTR_ERR(tfm));
|
||||
return -EINVAL;
|
||||
}
|
||||
actual_driver_name = crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
|
||||
|
|
|
|||
|
|
@ -2298,8 +2298,8 @@ static int linuxkm_test_rsa_driver(const char * driver, int nbits)
|
|||
* */
|
||||
tfm = crypto_alloc_akcipher(driver, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
tfm = NULL;
|
||||
goto test_rsa_end;
|
||||
}
|
||||
|
|
@ -2722,8 +2722,8 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits,
|
|||
skipped = 1;
|
||||
}
|
||||
else {
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating akcipher algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
if (PTR_ERR(tfm) == -ENOMEM) {
|
||||
test_rc = MEMORY_E;
|
||||
}
|
||||
|
|
@ -3229,8 +3229,8 @@ static int linuxkm_test_pkcs1_driver(const char * driver, int nbits,
|
|||
skipped = 1;
|
||||
}
|
||||
else {
|
||||
pr_err("error: allocating sig algorithm %s failed: %ld\n",
|
||||
driver, PTR_ERR(tfm));
|
||||
pr_err("error: allocating sig algorithm %s failed: %d\n",
|
||||
driver, (int)PTR_ERR(tfm));
|
||||
if (PTR_ERR(tfm) == -ENOMEM) {
|
||||
test_rc = MEMORY_E;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1352,7 +1352,12 @@ static int wc_linuxkm_drbg_loaded = 0;
|
|||
static int wc__get_random_bytes(void *buf, size_t len)
|
||||
{
|
||||
struct wc_rng_bank *current_default_wc_rng_bank;
|
||||
int ret = wc_rng_bank_default_checkout(¤t_default_wc_rng_bank);
|
||||
int ret;
|
||||
|
||||
if (len > WC_MAX_UINT_OF(unsigned int))
|
||||
return -EINVAL;
|
||||
|
||||
ret = wc_rng_bank_default_checkout(¤t_default_wc_rng_bank);
|
||||
if (ret) {
|
||||
#ifdef WC_VERBOSE_RNG
|
||||
pr_err_ratelimited("ERROR: wc_rng_bank_default_checkout() in wc__get_random_bytes() returned %d.\n", ret);
|
||||
|
|
@ -1361,7 +1366,7 @@ static int wc__get_random_bytes(void *buf, size_t len)
|
|||
}
|
||||
else {
|
||||
ret = wc_linuxkm_drbg_generate(current_default_wc_rng_bank,
|
||||
NULL, 0, buf, len);
|
||||
NULL, 0, buf, (unsigned int)len);
|
||||
(void)wc_rng_bank_default_checkin(¤t_default_wc_rng_bank);
|
||||
if (ret) {
|
||||
pr_warn("BUG: wc__get_random_bytes falling through to native get_random_bytes with wc_linuxkm_drbg_default_instance_registered, ret=%d.\n", ret);
|
||||
|
|
@ -1374,14 +1379,14 @@ static int wc__get_random_bytes(void *buf, size_t len)
|
|||
/* used by kernel >=5.14.0 */
|
||||
static ssize_t wc_get_random_bytes_user(struct iov_iter *iter) {
|
||||
struct wc_rng_bank *current_default_wc_rng_bank;
|
||||
int ret;
|
||||
ssize_t ret;
|
||||
if (unlikely(!iov_iter_count(iter)))
|
||||
return 0;
|
||||
|
||||
ret = wc_rng_bank_default_checkout(¤t_default_wc_rng_bank);
|
||||
if (ret) {
|
||||
#ifdef WC_VERBOSE_RNG
|
||||
pr_err_ratelimited("ERROR: wc_rng_bank_default_checkout() in wc_get_random_bytes_user() returned %d.\n", ret);
|
||||
pr_err_ratelimited("ERROR: wc_rng_bank_default_checkout() in wc_get_random_bytes_user() returned %ld.\n", ret);
|
||||
#endif
|
||||
return -ECANCELED;
|
||||
}
|
||||
|
|
@ -1393,7 +1398,7 @@ static ssize_t wc_get_random_bytes_user(struct iov_iter *iter) {
|
|||
ret = wc_linuxkm_drbg_generate(current_default_wc_rng_bank,
|
||||
NULL, 0, block, sizeof block);
|
||||
if (unlikely(ret != 0)) {
|
||||
pr_err("ERROR: wc_get_random_bytes_user() wc_linuxkm_drbg_generate() returned %d.\n", ret);
|
||||
pr_err("ERROR: wc_get_random_bytes_user() wc_linuxkm_drbg_generate() returned %ld.\n", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1435,7 +1440,7 @@ static ssize_t wc_get_random_bytes_user(struct iov_iter *iter) {
|
|||
|
||||
/* used by kernel 4.9.0-5.13.x */
|
||||
static ssize_t wc_extract_crng_user(void __user *buf, size_t nbytes) {
|
||||
int ret;
|
||||
ssize_t ret;
|
||||
struct wc_rng_bank *current_default_wc_rng_bank;
|
||||
if (unlikely(!nbytes))
|
||||
return 0;
|
||||
|
|
@ -1443,7 +1448,7 @@ static ssize_t wc_extract_crng_user(void __user *buf, size_t nbytes) {
|
|||
ret = wc_rng_bank_default_checkout(¤t_default_wc_rng_bank);
|
||||
if (ret) {
|
||||
#ifdef WC_VERBOSE_RNG
|
||||
pr_err_ratelimited("ERROR: wc_rng_bank_default_checkout() in wc_extract_crng_user() returned %d.\n", ret);
|
||||
pr_err_ratelimited("ERROR: wc_rng_bank_default_checkout() in wc_extract_crng_user() returned %ld.\n", ret);
|
||||
#endif
|
||||
return -ECANCELED;
|
||||
}
|
||||
|
|
@ -1455,11 +1460,13 @@ static ssize_t wc_extract_crng_user(void __user *buf, size_t nbytes) {
|
|||
ret = wc_linuxkm_drbg_generate(current_default_wc_rng_bank,
|
||||
NULL, 0, block, sizeof block);
|
||||
if (unlikely(ret != 0)) {
|
||||
pr_err("ERROR: wc_extract_crng_user() wc_linuxkm_drbg_generate() returned %d.\n", ret);
|
||||
pr_err("ERROR: wc_extract_crng_user() wc_linuxkm_drbg_generate() returned %ld.\n", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
this_copied = min(nbytes - total_copied, sizeof(block));
|
||||
this_copied = nbytes - total_copied;
|
||||
if (this_copied > sizeof(block))
|
||||
this_copied = sizeof(block);
|
||||
if (copy_to_user((byte *)buf + total_copied, block, this_copied)) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
|
|
@ -1808,8 +1815,8 @@ static int wc_linuxkm_drbg_startup(void)
|
|||
{
|
||||
struct crypto_rng *tfm = crypto_alloc_rng(wc_linuxkm_drbg.base.cra_name, 0, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
pr_err("ERROR: allocating rng algorithm %s failed: %ld\n",
|
||||
wc_linuxkm_drbg.base.cra_name, PTR_ERR(tfm));
|
||||
pr_err("ERROR: allocating rng algorithm %s failed: %d\n",
|
||||
wc_linuxkm_drbg.base.cra_name, (int)PTR_ERR(tfm));
|
||||
ret = PTR_ERR(tfm);
|
||||
tfm = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ static ssize_t dump_to_file(const char *path, const u8 *buf, size_t buf_len)
|
|||
|
||||
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));
|
||||
pr_err("libwolfssl: cannot open %s: %d\n", path, (int)PTR_ERR(fp));
|
||||
return PTR_ERR(fp);
|
||||
}
|
||||
|
||||
|
|
@ -1873,7 +1873,7 @@ static int updateFipsHash(void)
|
|||
pr_err("ERROR: crypto_alloc_shash failed: target kernel is missing algorithm implementation for hash type %u\n", FIPS_IN_CORE_HASH_TYPE);
|
||||
ret = NOT_COMPILED_IN;
|
||||
} else {
|
||||
pr_err("ERROR: crypto_alloc_shash failed with ret %ld\n",PTR_ERR(tfm));
|
||||
pr_err("ERROR: crypto_alloc_shash failed with ret %d\n", (int)PTR_ERR(tfm));
|
||||
ret = HASH_TYPE_E;
|
||||
}
|
||||
tfm = NULL;
|
||||
|
|
|
|||
|
|
@ -15340,10 +15340,10 @@ int GetFormattedTime_ex(void* currTime, byte* buf, word32 len, byte format)
|
|||
if (format == ASN_UTC_TIME) {
|
||||
/* UTC Time */
|
||||
if (ts->tm_year >= 50 && ts->tm_year < 100) {
|
||||
year = ts->tm_year;
|
||||
year = (int)ts->tm_year;
|
||||
}
|
||||
else {
|
||||
year = ts->tm_year - 100;
|
||||
year = (int)ts->tm_year - 100;
|
||||
}
|
||||
mon = ts->tm_mon + 1;
|
||||
day = ts->tm_mday;
|
||||
|
|
@ -15360,7 +15360,7 @@ int GetFormattedTime_ex(void* currTime, byte* buf, word32 len, byte format)
|
|||
}
|
||||
else {
|
||||
/* GeneralizedTime */
|
||||
year = ts->tm_year + 1900;
|
||||
year = (int)ts->tm_year + 1900;
|
||||
mon = ts->tm_mon + 1;
|
||||
day = ts->tm_mday;
|
||||
hour = ts->tm_hour;
|
||||
|
|
|
|||
|
|
@ -433,10 +433,6 @@ enum {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FIPS) || defined(HAVE_SELFTEST)
|
||||
#define INLINE WC_INLINE
|
||||
#endif
|
||||
|
||||
/* set up rotate style */
|
||||
#if ((defined(_MSC_VER) && !defined(WOLFSSL_NOT_WINDOWS_API)) || \
|
||||
defined(__BCPLUSPLUS__)) && !defined(WOLFSSL_SGX) && \
|
||||
|
|
|
|||
|
|
@ -106,7 +106,10 @@
|
|||
#endif
|
||||
#endif /* !WC_DEPRECATED */
|
||||
|
||||
/* use inlining if compiler allows */
|
||||
/* Use inlining if compiler allows -- omit the static attribute here, so that
|
||||
* WC_INLINE can be used on functions that are instantiated both inline in the
|
||||
* TU, and callable from outside the TU.
|
||||
*/
|
||||
#ifndef WC_INLINE
|
||||
#ifndef NO_INLINE
|
||||
#ifdef _MSC_VER
|
||||
|
|
@ -143,6 +146,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_FIPS) && FIPS_VERSION3_LT(7,0,0)) || defined(HAVE_SELFTEST)
|
||||
#define INLINE WC_INLINE
|
||||
#endif
|
||||
|
||||
#ifndef WC_NO_INLINE
|
||||
#ifdef noinline
|
||||
#define WC_NO_INLINE noinline
|
||||
|
|
@ -549,8 +556,7 @@
|
|||
* should not be included. Use FreeBSD <machine/atomic.h> instead.
|
||||
* definitions are in bsdkm/bsdkm_wc_port.h */
|
||||
#elif defined(HAVE_C___ATOMIC) && defined(WOLFSSL_HAVE_ATOMIC_H) && \
|
||||
!defined(__cplusplus) && \
|
||||
!(defined(__clang__) && defined(WOLFSSL_KERNEL_MODE))
|
||||
!defined(__cplusplus)
|
||||
/* Default C Implementation */
|
||||
#include <stdatomic.h>
|
||||
typedef atomic_int wolfSSL_Atomic_Int;
|
||||
|
|
|
|||
Loading…
Reference in New Issue