summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramin <lordrasmus@gmail.com>2022-09-28 11:41:29 +0200
committerTomas Mraz <tomas@openssl.org>2022-10-21 12:59:14 +0200
commitbd19999b396d03d39eab4a86c6402a970191c9e1 (patch)
treed4ceb6d953868ab1ec9457cb384ab9f7fd7c8a11
parenttest: threads: replace test_thread_noreturn (diff)
downloadopenssl-bd19999b396d03d39eab4a86c6402a970191c9e1.tar.xz
openssl-bd19999b396d03d39eab4a86c6402a970191c9e1.zip
Add af_alg errors to the error queue
If the kernel operation failed the EVP functions just returned without any error message. This commit adds them. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19289)
-rw-r--r--engines/e_afalg.c23
-rw-r--r--engines/e_afalg.txt3
-rw-r--r--engines/e_afalg_err.c3
-rw-r--r--engines/e_afalg_err.h3
4 files changed, 29 insertions, 3 deletions
diff --git a/engines/e_afalg.c b/engines/e_afalg.c
index 193508430a..c0189951e6 100644
--- a/engines/e_afalg.c
+++ b/engines/e_afalg.c
@@ -355,6 +355,18 @@ static int afalg_fin_cipher_aio(afalg_aio *aio, int sfd, unsigned char *buf,
}
continue;
} else {
+ char strbuf[32];
+ /*
+ * sometimes __s64 is defined as long long int
+ * but on some archs ( like mips64 or powerpc64 ) it's just long int
+ *
+ * to be able to use BIO_snprintf() with %lld without warnings
+ * copy events[0].res to an long long int variable
+ *
+ * because long long int should always be at least 64 bit this should work
+ */
+ long long int op_ret = events[0].res;
+
/*
* Retries exceed for -EBUSY or unrecoverable error
* condition for this instance of operation.
@@ -362,6 +374,17 @@ static int afalg_fin_cipher_aio(afalg_aio *aio, int sfd, unsigned char *buf,
ALG_WARN
("%s(%d): Crypto Operation failed with code %lld\n",
__FILE__, __LINE__, events[0].res);
+ BIO_snprintf(strbuf, sizeof(strbuf), "%lld", op_ret);
+ switch (events[0].res) {
+ case -ENOMEM:
+ AFALGerr(0, AFALG_R_KERNEL_OP_FAILED);
+ ERR_add_error_data(3, "-ENOMEM ( code ", strbuf, " )");
+ break;
+ default:
+ AFALGerr(0, AFALG_R_KERNEL_OP_FAILED);
+ ERR_add_error_data(2, "code ", strbuf);
+ break;
+ }
return 0;
}
}
diff --git a/engines/e_afalg.txt b/engines/e_afalg.txt
index 37f023b87e..9b5fee8475 100644
--- a/engines/e_afalg.txt
+++ b/engines/e_afalg.txt
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@@ -13,6 +13,7 @@ AFALG_R_IO_SETUP_FAILED:105:io setup failed
AFALG_R_KERNEL_DOES_NOT_SUPPORT_AFALG:101:kernel does not support afalg
AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG:107:\
kernel does not support async afalg
+AFALG_R_KERNEL_OP_FAILED:112:kernel op failed
AFALG_R_MEM_ALLOC_FAILED:102:mem alloc failed
AFALG_R_SOCKET_ACCEPT_FAILED:110:socket accept failed
AFALG_R_SOCKET_BIND_FAILED:103:socket bind failed
diff --git a/engines/e_afalg_err.c b/engines/e_afalg_err.c
index 47a3d034e5..fa38678e9e 100644
--- a/engines/e_afalg_err.c
+++ b/engines/e_afalg_err.c
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -23,6 +23,7 @@ static ERR_STRING_DATA AFALG_str_reasons[] = {
"kernel does not support afalg"},
{ERR_PACK(0, 0, AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG),
"kernel does not support async afalg"},
+ {ERR_PACK(0, 0, AFALG_R_KERNEL_OP_FAILED), "kernel op failed"},
{ERR_PACK(0, 0, AFALG_R_MEM_ALLOC_FAILED), "mem alloc failed"},
{ERR_PACK(0, 0, AFALG_R_SOCKET_ACCEPT_FAILED), "socket accept failed"},
{ERR_PACK(0, 0, AFALG_R_SOCKET_BIND_FAILED), "socket bind failed"},
diff --git a/engines/e_afalg_err.h b/engines/e_afalg_err.h
index 2070c04a1c..8328b21e8e 100644
--- a/engines/e_afalg_err.h
+++ b/engines/e_afalg_err.h
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -28,6 +28,7 @@
# define AFALG_R_IO_SETUP_FAILED 105
# define AFALG_R_KERNEL_DOES_NOT_SUPPORT_AFALG 101
# define AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG 107
+# define AFALG_R_KERNEL_OP_FAILED 112
# define AFALG_R_MEM_ALLOC_FAILED 102
# define AFALG_R_SOCKET_ACCEPT_FAILED 110
# define AFALG_R_SOCKET_BIND_FAILED 103