Bug #108053 Contribution: if keyring migration failed, its destructor will delete m_arg ...
Submitted: 2 Aug 2022 15:48 Modified: 30 Mar 6:00
Reporter: OCA Admin (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Security: Encryption Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[2 Aug 2022 15:48] OCA Admin
Description:
This bug tracks a contribution by ming gao (Github user: gaoming1998) as described in http://github.com/mysql/mysql-server/pull/414

How to repeat:
See description

Suggested fix:
See contribution code attached
[2 Aug 2022 15:48] OCA Admin
Contribution submitted via Github - if keyring migration failed, its destructor will delete m_argv wasn't… 
(*) Contribution by ming gao (Github gaoming1998, mysql-server/pull/414#issuecomment-1202077532): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it

---Original---
From: ***@***.***>
Date: Fri, Jul 29, 2022 21:53 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [mysql/mysql-server] if keyring migration failed, its destructor will delete m_argv wasn''t… (PR #414)

 
Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle''s Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
 "I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
 Thanks
 
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>

Contribution: git_patch_984461608.txt (text/plain), 825 bytes.

[3 Aug 2022 4:31] MySQL Verification Team
Hello!

Thank you for the report and contribution.

regards,
Umesh
[30 Mar 6:00] Miroslav Rajcic
Posted by developer:
 
Compiled latest mysql-8.0 branch with ASAN, trying both clang and gcc: 

#1. Clang with ASAN configuration:
CC=/opt/llvm-20.1.1/bin/clang CXX=/opt/llvm-20.1.1/bin/clang++ cmake .. -DWITH_DEBUG=1 -DWITH_AUTHENTICATION_LDAP=OFF -DWITH_AUTHENTICATION_WEBAUTHN=OFF -DWITH_ASAN=1 -DWITH_BOOST=/usr/global/share/ -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=/opt/llvm-20.1.1/include/

#2. gcc with ASAN configuration:
cmake .. -DWITH_DEBUG=1 -DWITH_AUTHENTICATION_LDAP=OFF -DWITH_AUTHENTICATION_WEBAUTHN=OFF -DWITH_ASAN=1 -DWITH_BOOST=/usr/global/share/

In both cases, running the proposed command does not crash:
[mrajcic@compile-el8-02 runtime_output_directory]$ ./mysqld -p 4567
Enter password:
mysqld: Can not perform keyring migration : Invalid --keyring-migration-source option.
2026-03-30T05:25:27.715098Z 0 [System] [MY-010116] [Server] /export/home/tmp/mrajcic/mysql/bld/runtime_output_directory/mysqld (mysqld 8.0.47-debug-asan) starting as process 439673
2026-03-30T05:25:27.718484Z 0 [Warning] [MY-010091] [Server] Can't create test file /export/home/tmp/mrajcic/mysql/bld/data/mysqld_tmp_file_case_insensitive_test.lower-test
2026-03-30T05:25:27.718519Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /export/home/tmp/mrajcic/mysql/bld/data/ is case insensitive
2026-03-30T05:25:27.718802Z 0 [ERROR] [MY-011084] [Server] Keyring migration failed.
2026-03-30T05:25:27.718950Z 0 [ERROR] [MY-010119] [Server] Aborting
2026-03-30T05:25:27.719399Z 0 [System] [MY-010910] [Server] /export/home/tmp/mrajcic/mysql/bld/runtime_output_directory/mysqld: Shutdown complete (mysqld 8.0.47-debug-asan)  Source distribution.

Also, looking at the proposed patch it is not clear how it would solve the problem.
In C++, calling delete (or delete []) on NULL pointer is a safe operation, so the proposed fix cannot help in any way.
Also, the pointer being protected is correctly initialized to NULL in Migrate_keyring constructor, so I don't see any opportunity for it to be set to an invalid address that might lead to crash.