Skip to content

Commit bd19999

Browse files
lordrasmust8m
authored andcommitted
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 <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#19289)
1 parent 6ca4bd2 commit bd19999

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

engines/e_afalg.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,36 @@ static int afalg_fin_cipher_aio(afalg_aio *aio, int sfd, unsigned char *buf,
355355
}
356356
continue;
357357
} else {
358+
char strbuf[32];
359+
/*
360+
* sometimes __s64 is defined as long long int
361+
* but on some archs ( like mips64 or powerpc64 ) it's just long int
362+
*
363+
* to be able to use BIO_snprintf() with %lld without warnings
364+
* copy events[0].res to an long long int variable
365+
*
366+
* because long long int should always be at least 64 bit this should work
367+
*/
368+
long long int op_ret = events[0].res;
369+
358370
/*
359371
* Retries exceed for -EBUSY or unrecoverable error
360372
* condition for this instance of operation.
361373
*/
362374
ALG_WARN
363375
("%s(%d): Crypto Operation failed with code %lld\n",
364376
__FILE__, __LINE__, events[0].res);
377+
BIO_snprintf(strbuf, sizeof(strbuf), "%lld", op_ret);
378+
switch (events[0].res) {
379+
case -ENOMEM:
380+
AFALGerr(0, AFALG_R_KERNEL_OP_FAILED);
381+
ERR_add_error_data(3, "-ENOMEM ( code ", strbuf, " )");
382+
break;
383+
default:
384+
AFALGerr(0, AFALG_R_KERNEL_OP_FAILED);
385+
ERR_add_error_data(2, "code ", strbuf);
386+
break;
387+
}
365388
return 0;
366389
}
367390
}

engines/e_afalg.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
1+
# Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
22
#
33
# Licensed under the Apache License 2.0 (the "License"). You may not use
44
# 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
1313
AFALG_R_KERNEL_DOES_NOT_SUPPORT_AFALG:101:kernel does not support afalg
1414
AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG:107:\
1515
kernel does not support async afalg
16+
AFALG_R_KERNEL_OP_FAILED:112:kernel op failed
1617
AFALG_R_MEM_ALLOC_FAILED:102:mem alloc failed
1718
AFALG_R_SOCKET_ACCEPT_FAILED:110:socket accept failed
1819
AFALG_R_SOCKET_BIND_FAILED:103:socket bind failed

engines/e_afalg_err.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Generated by util/mkerr.pl DO NOT EDIT
3-
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3+
* Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
44
*
55
* Licensed under the Apache License 2.0 (the "License"). You may not use
66
* this file except in compliance with the License. You can obtain a copy
@@ -23,6 +23,7 @@ static ERR_STRING_DATA AFALG_str_reasons[] = {
2323
"kernel does not support afalg"},
2424
{ERR_PACK(0, 0, AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG),
2525
"kernel does not support async afalg"},
26+
{ERR_PACK(0, 0, AFALG_R_KERNEL_OP_FAILED), "kernel op failed"},
2627
{ERR_PACK(0, 0, AFALG_R_MEM_ALLOC_FAILED), "mem alloc failed"},
2728
{ERR_PACK(0, 0, AFALG_R_SOCKET_ACCEPT_FAILED), "socket accept failed"},
2829
{ERR_PACK(0, 0, AFALG_R_SOCKET_BIND_FAILED), "socket bind failed"},

engines/e_afalg_err.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Generated by util/mkerr.pl DO NOT EDIT
3-
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3+
* Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
44
*
55
* Licensed under the Apache License 2.0 (the "License"). You may not use
66
* this file except in compliance with the License. You can obtain a copy
@@ -28,6 +28,7 @@
2828
# define AFALG_R_IO_SETUP_FAILED 105
2929
# define AFALG_R_KERNEL_DOES_NOT_SUPPORT_AFALG 101
3030
# define AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG 107
31+
# define AFALG_R_KERNEL_OP_FAILED 112
3132
# define AFALG_R_MEM_ALLOC_FAILED 102
3233
# define AFALG_R_SOCKET_ACCEPT_FAILED 110
3334
# define AFALG_R_SOCKET_BIND_FAILED 103

0 commit comments

Comments
 (0)