From cd7a454c23f247c87f519cfd4c0199f3bc0cd731 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 25 Mar 2025 11:11:01 +0100 Subject: [PATCH] MDEV-36351 MariaDB crashes when trying to access information_schema.users under --skip-grant-tables --- mysql-test/main/skip_grants.result | 16 +++++----------- mysql-test/main/skip_grants.test | 17 ++++++----------- sql/sql_acl.cc | 5 +++++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/mysql-test/main/skip_grants.result b/mysql-test/main/skip_grants.result index 46e93cc79f3..b22f1545e81 100644 --- a/mysql-test/main/skip_grants.result +++ b/mysql-test/main/skip_grants.result @@ -68,19 +68,15 @@ count(*) select count(*) from information_schema.USER_PRIVILEGES; count(*) 0 -# # End of 5.0 tests # -# # Bug#29817 Queries with UDF fail with non-descriptive error # if mysql.proc is missing # select no_such_function(1); ERROR 42000: FUNCTION test.no_such_function does not exist -# # End of 5.1 tests # -# # MDEV-8280 crash in 'show global status' with --skip-grant-tables # show global status like 'Acl%'; @@ -96,17 +92,13 @@ Acl_role_grants 0 Acl_roles 0 Acl_table_grants 0 Acl_users 0 -# # End of 10.1 tests # -# # MDEV-22966 Server crashes or hangs with SET ROLE when started with skip-grant-tables # set role x; ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement -# # End of 10.2 tests -# show create user root@localhost; ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement insert mysql.global_priv values ('foo', 'bar', '{}'); @@ -134,10 +126,8 @@ CREATE USER `baz`@`baz` IDENTIFIED BY PASSWORD '*E52096EF8EB0240275A7FE9E069101C drop user bar@foo; drop user baz@baz; # restart -# # End of 10.3 tests # -# # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables # CREATE DEFINER=a PROCEDURE p() SELECT 1; @@ -156,6 +146,10 @@ SELECT @@skip_grant_tables AS EXPECT_0; EXPECT_0 0 # restart: --skip-grant-tables -# # End of 10.10 tests # +# MDEV-36351 MariaDB crashes when trying to access information_schema.users under --skip-grant-tables +# +select * from information_schema.users; +USER PASSWORD_ERRORS PASSWORD_EXPIRATION_TIME +# End of 11.8 tests diff --git a/mysql-test/main/skip_grants.test b/mysql-test/main/skip_grants.test index 228fa6459d8..a21e5c74d3e 100644 --- a/mysql-test/main/skip_grants.test +++ b/mysql-test/main/skip_grants.test @@ -104,9 +104,7 @@ select count(*) from information_schema.SCHEMA_PRIVILEGES; select count(*) from information_schema.TABLE_PRIVILEGES; select count(*) from information_schema.USER_PRIVILEGES; ---echo # --echo # End of 5.0 tests ---echo # --echo # --echo # Bug#29817 Queries with UDF fail with non-descriptive error @@ -115,18 +113,14 @@ select count(*) from information_schema.USER_PRIVILEGES; --error ER_SP_DOES_NOT_EXIST select no_such_function(1); ---echo # --echo # End of 5.1 tests ---echo # --echo # --echo # MDEV-8280 crash in 'show global status' with --skip-grant-tables --echo # show global status like 'Acl%'; ---echo # --echo # End of 10.1 tests ---echo # --echo # --echo # MDEV-22966 Server crashes or hangs with SET ROLE when started with skip-grant-tables @@ -135,9 +129,7 @@ show global status like 'Acl%'; --error ER_OPTION_PREVENTS_STATEMENT set role x; ---echo # --echo # End of 10.2 tests ---echo # # # MDEV-18297 @@ -164,9 +156,7 @@ drop user baz@baz; --enable_ps_protocol ---echo # --echo # End of 10.3 tests ---echo # --echo # --echo # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables @@ -194,6 +184,11 @@ SELECT @@skip_grant_tables AS EXPECT_0; --let $restart_parameters = --skip-grant-tables --source include/restart_mysqld.inc ---echo # --echo # End of 10.10 tests + --echo # +--echo # MDEV-36351 MariaDB crashes when trying to access information_schema.users under --skip-grant-tables +--echo # +select * from information_schema.users; + +--echo # End of 11.8 tests diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1eba626cd4b..6f202317375 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -13127,7 +13127,12 @@ static int fill_users_schema_record(THD *thd, TABLE * table, ACL_USER *user) int fill_users_schema_table(THD *thd, TABLE_LIST *tables, COND *cond) { int res= 0; + #ifndef NO_EMBEDDED_ACCESS_CHECKS + /* --skip-grants */ + if (!initialized) + return res; + bool see_whole_table= check_access(thd, SELECT_ACL, "mysql", NULL, NULL, true, true) == 0; TABLE *table= tables->table;