Skip to content

Commit 5e3c948

Browse files
committed
MDEV-29852 SIGSEGV in mysql_create_routine or is_acl_user on 2nd execution, ASAN use-after-poison in get_current_user (sql_acl.cc)
if lex->definer is replaced, take care to restore it at the end of PS EXECUTE
1 parent 4493642 commit 5e3c948

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

mysql-test/main/sp-security.result

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,9 @@ USE test;
659659
DROP USER 'tester';
660660
DROP USER 'Tester';
661661
DROP DATABASE B48872;
662-
End of 5.0 tests.
662+
#
663+
# End of 5.0 tests.
664+
#
663665
#
664666
# Test for bug#57061 "User without privilege on routine can discover
665667
# its existence."
@@ -804,7 +806,7 @@ DROP DATABASE u1;
804806
DROP USER u1@localhost;
805807
set @@global.character_set_server=@save_character_set_server;
806808
#
807-
# Start of 10.5 tests
809+
# End of 10.2 tests
808810
#
809811
#
810812
# MDEV-20366 Server crashes in get_current_user upon SET PASSWORD via SP
@@ -821,3 +823,17 @@ DROP USER foo@localhost;
821823
#
822824
# End of 10.5 tests
823825
#
826+
#
827+
# MDEV-29852 SIGSEGV in mysql_create_routine or is_acl_user on 2nd execution, ASAN use-after-poison in get_current_user (sql_acl.cc)
828+
#
829+
set @cmd:="create definer=u function f(i int) returns char binary reads sql data return concat (1,i)";
830+
prepare s from @cmd;
831+
execute s;
832+
Warnings:
833+
Note 1449 The user specified as a definer ('u'@'%') does not exist
834+
execute s;
835+
ERROR 42000: FUNCTION f already exists
836+
drop function f;
837+
#
838+
# End of 10.6 tests
839+
#

mysql-test/main/sp-security.test

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,9 @@ DROP USER 'tester';
911911
DROP USER 'Tester';
912912
DROP DATABASE B48872;
913913

914-
--echo End of 5.0 tests.
915-
914+
--echo #
915+
--echo # End of 5.0 tests.
916+
--echo #
916917

917918
--echo #
918919
--echo # Test for bug#57061 "User without privilege on routine can discover
@@ -1080,9 +1081,8 @@ DROP USER u1@localhost;
10801081

10811082
set @@global.character_set_server=@save_character_set_server;
10821083

1083-
10841084
--echo #
1085-
--echo # Start of 10.5 tests
1085+
--echo # End of 10.2 tests
10861086
--echo #
10871087

10881088
--echo #
@@ -1102,7 +1102,20 @@ CALL p1();
11021102
DROP PROCEDURE p1;
11031103
DROP USER foo@localhost;
11041104

1105-
11061105
--echo #
11071106
--echo # End of 10.5 tests
11081107
--echo #
1108+
1109+
--echo #
1110+
--echo # MDEV-29852 SIGSEGV in mysql_create_routine or is_acl_user on 2nd execution, ASAN use-after-poison in get_current_user (sql_acl.cc)
1111+
--echo #
1112+
set @cmd:="create definer=u function f(i int) returns char binary reads sql data return concat (1,i)";
1113+
prepare s from @cmd;
1114+
execute s;
1115+
--error ER_SP_ALREADY_EXISTS
1116+
execute s;
1117+
drop function f;
1118+
1119+
--echo #
1120+
--echo # End of 10.6 tests
1121+
--echo #

sql/sql_parse.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,9 +2800,10 @@ bool sp_process_definer(THD *thd)
28002800
}
28012801
else
28022802
{
2803-
LEX_USER *d= lex->definer= get_current_user(thd, lex->definer);
2803+
LEX_USER *d= get_current_user(thd, lex->definer);
28042804
if (!d)
28052805
DBUG_RETURN(TRUE);
2806+
thd->change_item_tree((Item**)&lex->definer, (Item*)d);
28062807

28072808
/*
28082809
If the specified definer differs from the current user or role, we

0 commit comments

Comments
 (0)