diff options
| author | tb <> | 2026-07-25 07:33:43 +0000 |
|---|---|---|
| committer | tb <> | 2026-07-25 07:33:43 +0000 |
| commit | 2adf2c6198679c7e8376bb7c891af6d3c9b399d5 (patch) | |
| tree | 2dcd2e82c09a02b0ea8654894170e51e9fb3f690 /src/lib | |
| parent | ffcf6234bccf652a6a35ea18d71997d46f147d4f (diff) | |
| download | openbsd-2adf2c6198679c7e8376bb7c891af6d3c9b399d5.tar.gz openbsd-2adf2c6198679c7e8376bb7c891af6d3c9b399d5.tar.bz2 openbsd-2adf2c6198679c7e8376bb7c891af6d3c9b399d5.zip | |
Unlock CRYPTO_LOCK_UI on ui_open_session() failure
Both ui_open_session() implementations, open_console() in ui_openssl.c
in base, and the one in ui_openssl_win.c in portable, grab the lock of
type CRYPTO_LOCK_UI before doing anything else.
The only internal (and, as far as I can tell, the only existing) caller,
UI_process(), returns immediately on failure. The calling thread thus
keeps holding the lock and the next call to UI_process() will block
indefinitely. Fix this by using the common exit path, which calls
ui_close_session() aka close_console(), both implementations of which
release the lock.
Thanks to Kartik (@sage-mode-hunter) who proposed an alternative fix for
ui_openssl_win.c, which we would have to apply to ui_openssl.c as well.
Matches OpenSSL behavior since PR #2037
Closes https://github.com/libressl/portable/pull/1334
ok kenjiro
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/libcrypto/ui/ui_lib.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c index 3cfb3d371a..4562464cc7 100644 --- a/src/lib/libcrypto/ui/ui_lib.c +++ b/src/lib/libcrypto/ui/ui_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ui_lib.c,v 1.54 2026/05/19 09:23:36 tb Exp $ */ | 1 | /* $OpenBSD: ui_lib.c,v 1.55 2026/07/25 07:33:43 tb Exp $ */ |
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
| 3 | * project 2001. | 3 | * project 2001. |
| 4 | */ | 4 | */ |
| @@ -461,8 +461,10 @@ UI_process(UI *ui) | |||
| 461 | { | 461 | { |
| 462 | int i, ok = 0; | 462 | int i, ok = 0; |
| 463 | 463 | ||
| 464 | if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) | 464 | if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) { |
| 465 | return -1; | 465 | ok = -1; |
| 466 | goto err; | ||
| 467 | } | ||
| 466 | 468 | ||
| 467 | if (ui->flags & UI_FLAG_PRINT_ERRORS) | 469 | if (ui->flags & UI_FLAG_PRINT_ERRORS) |
| 468 | ERR_print_errors_cb(print_error, ui); | 470 | ERR_print_errors_cb(print_error, ui); |
