Skip to content

Commit e52a4ab

Browse files
robertbindarvuvova
authored andcommitted
MDEV-15907 ASAN heap-use-after-free
This patch fixes an invalid read in fill_effective_table_privileges triggered by a grant_version increase between a PREPARE for a statement creating a view from I_S and EXECUTE. A tmp table was created and free'd while preparing the statement, TABLE_LIST::table_name was set to point to the tmp table TABLE_SHARE::table_name which no longer existed after preparing was done. The grant version increase made fill_effective_table_privileges called during EXECUTE to try fetch the updated grant info and this is where the dangling table name was used.
1 parent 5d510fd commit e52a4ab

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

mysql-test/r/mdev15907.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PREPARE stmt2 FROM "CREATE VIEW v AS SELECT * FROM INFORMATION_SCHEMA.TABLES";
2+
FLUSH PRIVILEGES;
3+
EXECUTE stmt2;
4+
DROP VIEW v;

mysql-test/t/mdev15907.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PREPARE stmt2 FROM "CREATE VIEW v AS SELECT * FROM INFORMATION_SCHEMA.TABLES";
2+
FLUSH PRIVILEGES;
3+
EXECUTE stmt2;
4+
DROP VIEW v;

sql/sql_show.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7620,8 +7620,6 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
76207620
table->alias_name_used= my_strcasecmp(table_alias_charset,
76217621
table_list->schema_table_name,
76227622
table_list->alias);
7623-
table_list->table_name= table->s->table_name.str;
7624-
table_list->table_name_length= table->s->table_name.length;
76257623
table_list->table= table;
76267624
table->next= thd->derived_tables;
76277625
thd->derived_tables= table;

sql/table.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5373,7 +5373,8 @@ const char *Field_iterator_table_ref::get_table_name()
53735373
return natural_join_it.column_ref()->table_name();
53745374

53755375
DBUG_ASSERT(!strcmp(table_ref->table_name,
5376-
table_ref->table->s->table_name.str));
5376+
table_ref->table->s->table_name.str) ||
5377+
table_ref->schema_table);
53775378
return table_ref->table_name;
53785379
}
53795380

0 commit comments

Comments
 (0)