#At file:///work/bzr_trees/37908-5.1-opt/
2583 Evgeny Potemkin 2008-08-15
Bug#37908: Skipped access right check caused server crash.
The check_table_access function initializes per-table grant info and performs
access rights check. It wasn't called for SHOW STATUS statement thus left
grants info uninitialized. In some cases this led to server crash. In other
cases it allowed a user to check for presence/absence of arbitrary values in
any tables.
Now the check_table_access function is called when the SHOW STATUS statement
uses any table except information.STATUS.
modified:
mysql-test/r/status.result
mysql-test/t/disabled.def
mysql-test/t/status.test
sql/sql_parse.cc
per-file messages:
mysql-test/r/status.result
Added a test case for the bug#37908.
mysql-test/t/disabled.def
The bug#32966 is fixed, enabling test case.
mysql-test/t/status.test
Added a test case for the bug#37908.
sql/sql_parse.cc
Bug#37908: Skipped access right check caused server crash.
Now the check_table_access function is called when the SHOW STATUS statement
uses any table except information.STATUS.
=== modified file 'mysql-test/r/status.result'
--- a/mysql-test/r/status.result 2007-12-19 00:27:15 +0000
+++ b/mysql-test/r/status.result 2008-08-15 13:55:42 +0000
@@ -183,3 +183,16 @@ Com_create_function 1
Com_drop_function 1
Com_show_function_code 0
Com_show_function_status 0
+create database db37908;
+create table db37908.t1(f1 int);
+insert into db37908.t1 values(1);
+grant select on test.* to mysqltest_1@localhost;
+select * from db37908.t1;
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+show status where variable_name ='uptime' and 1 in (select f1 from db37908.t1);
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+show status where variable_name ='uptime' and 2 in (select f1 from db37908.t1);
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+show status where variable_name ='uptime' and 2 in (select * from db37908.t1);
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+drop database db37908;
=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def 2008-03-29 12:19:53 +0000
+++ b/mysql-test/t/disabled.def 2008-08-15 13:55:42 +0000
@@ -16,6 +16,5 @@ federated_transactions : Bug#29523 Tra
lowercase_table3 : Bug#32667 lowercase_table3.test reports to error log
innodb_mysql : Bug#32724: innodb_mysql.test fails randomly
ctype_create : Bug#32965 main.ctype_create fails
-status : Bug#32966 main.status fails
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
csv_alter_table : Bug#33696 2008-01-21 pcrews no .result file - bug allows NULL columns in CSV tables
=== modified file 'mysql-test/t/status.test'
--- a/mysql-test/t/status.test 2007-12-14 23:27:40 +0000
+++ b/mysql-test/t/status.test 2008-08-15 13:55:42 +0000
@@ -260,5 +260,31 @@ drop function f1;
show global status like 'Com%function%';
+#
+# Bug#37908: Skipped access right check caused server crash.
+#
+connect (root, localhost, root,,test);
+connection root;
+--disable_warnings
+create database db37908;
+--enable_warnings
+create table db37908.t1(f1 int);
+insert into db37908.t1 values(1);
+grant select on test.* to mysqltest_1@localhost;
+
+connect (user1,localhost,mysqltest_1,,test);
+connection user1;
+
+--error 1142
+select * from db37908.t1;
+--error 1142
+show status where variable_name ='uptime' and 1 in (select f1 from db37908.t1);
+--error 1142
+show status where variable_name ='uptime' and 2 in (select f1 from db37908.t1);
+--error 1142
+show status where variable_name ='uptime' and 2 in (select * from db37908.t1);
+
+connection root;
+drop database db37908;
# End of 5.1 tests
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2008-04-07 13:43:45 +0000
+++ b/sql/sql_parse.cc 2008-08-15 13:55:42 +0000
@@ -2007,7 +2007,11 @@ mysql_execute_command(THD *thd)
{
system_status_var old_status_var= thd->status_var;
thd->initial_status_var= &old_status_var;
- res= execute_sqlcom_select(thd, all_tables);
+ /* Check access if any table beside information_schema.STATUS is used. */
+ if (all_tables->next_global)
+ res= check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE);
+ if (!res)
+ res= execute_sqlcom_select(thd, all_tables);
/* Don't log SHOW STATUS commands to slow query log */
thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED |
SERVER_QUERY_NO_GOOD_INDEX_USED);
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (epotemkin:2583) Bug#32966, Bug#37908 | Evgeny Potemkin | 15 Aug |