-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-40085 TRUNCATE of temporary table with ENCRYPTED=NO crashes under innodb_encrypt_tables=FORCE #5308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Thirunarayanan
wants to merge
1
commit into
10.11
Choose a base branch
from
MDEV-40085
base: 10.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−1
Open
MDEV-40085 TRUNCATE of temporary table with ENCRYPTED=NO crashes under innodb_encrypt_tables=FORCE #5308
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11292,7 +11292,7 @@ create_table_info_t::check_table_options() | |
| " ENCRYPTION_KEY_ID=1"); | ||
| compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1); | ||
| } | ||
| if (srv_encrypt_tables != 2) { | ||
| if (m_trx || srv_encrypt_tables != 2) { | ||
| break; | ||
| } | ||
| push_warning( | ||
|
|
@@ -13887,6 +13887,26 @@ int ha_innobase::truncate() | |
| if (ib_table->is_temporary()) | ||
| { | ||
| info.options|= HA_LEX_CREATE_TMP_TABLE; | ||
|
|
||
| /* Validate the create options before dropping the existing | ||
| table, so that a validation failure leaves the original table | ||
| intact instead of dropping it and then failing in create(), | ||
| which would leave the handler without a table. */ | ||
| { | ||
| char norm_name[FN_REFLEN], remote_path[FN_REFLEN]; | ||
| create_table_info_t validate(m_user_thd, table, &info, norm_name, | ||
| remote_path, true, trx); | ||
| int err= validate.initialize(); | ||
| if (!err) | ||
| err= validate.prepare_create_table(ib_table->name.m_name, false); | ||
| if (err) | ||
| { | ||
| trx_rollback_for_mysql(trx); | ||
| trx->free(); | ||
| DBUG_RETURN(err); | ||
| } | ||
| } | ||
|
Comment on lines
+13895
to
+13908
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To prevent potential null pointer dereferences, we should add a {
char norm_name[FN_REFLEN], remote_path[FN_REFLEN];
create_table_info_t validate(m_user_thd, table, &info, norm_name,
remote_path, true, trx);
int err = validate.initialize();
if (!err)
err = validate.prepare_create_table(ib_table->name.m_name, false);
if (err)
{
if (trx)
{
trx_rollback_for_mysql(trx);
trx->free();
}
DBUG_RETURN(err);
}
}References
|
||
|
|
||
| btr_drop_temporary_table(*ib_table); | ||
| m_prebuilt->table= nullptr; | ||
| row_prebuilt_free(m_prebuilt); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
m_trxas a proxy to detect the internal recreate/truncate path is fragile and poses a maintainability risk. If a future refactoring passes the active transaction pointer (trx) tocreate_table_info_tduring a normalCREATE TABLE(which is a very reasonable change since the constructor accepts it), theinnodb_encrypt_tables=FORCEcheck will be silently bypassed for all new tables, creating a security vulnerability.Instead, consider adding an explicit boolean flag (e.g.,
m_is_recreateor similar) tocreate_table_info_tto clearly indicate when the validation is performed as part of an internal recreate/truncate operation.