Bug #99496 m_admin_interface_listen_socket and port not correspond in m_socket_map

Submitted: 9 May 2020 9:42 Modified: 14 May 2020 12:30
Reporter: bo pang Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[9 May 2020 9:42] bo pang
Description:
Can not connect to mysqld through socket when write admin port Small probability.
server hangs.

How to repeat:
write '
admin_address = 127.0.0.1
admin_port = 33062
'
into my.cnf

startup mysqld 

/*connect mysqld through mysql.sock(non admin port)*/
mysql -uroot --skip-password --socket=mysql.sock

Suggested fix:
in Mysqld_socket_listener::setup_listener(), the m_admin_interface_listen_socket will insert into m_socket_map as m_socket_map[0],but m_socket_map will sort as socket fd Ascending order when new socket insert.

if the admin_socket fd is 78, port is 33062, later, the non_admin_sock fd is 76,port is 3306, insert into the map, now, the map will be 
<76, 3306>
<78, 33062>

in  Mysqld_socket_listener::get_ready_socket, when we connect through socket, the fd 76 will get a revents, the fd 76 is the frist member in map, in code, return  m_admin_interface_listen_socket, so, listen and handle a wrong socket.

as how to fix i think can get a non-order map to save m_socket_map .
[11 May 2020 13:34] MySQL Verification Team
Hi Mr. pang,

Thank you for your bug report.

However, I am not able to repeat your bug with 8.0.20.

This is the excerpt from my.cnf:

---------------
admin_address = 127.0.0.1
admin_port = 33062
_______________

I had no problem of connecting through the socket with ordinary user:

-------------------

mysql -uXXXXXX -pXXXXXX --socket=/private/tmp/mysql.sock test
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20-debug Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

------------------

And I had no problem of executing any command in mysql.CLI:

------------------
mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| ADMINISTRABLE_ROLE_AUTHORIZATIONS     |
| APPLICABLE_ROLES                      |
| CHARACTER_SETS                        |
| CHECK_CONSTRAINTS                     |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLLATIONS                            |
| COLUMN_PRIVILEGES                     |
| COLUMN_STATISTICS                     |
| COLUMNS                               |
| ENABLED_ROLES                         |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| INNODB_BUFFER_PAGE                    |
| INNODB_BUFFER_PAGE_LRU                |
| INNODB_BUFFER_POOL_STATS              |
| INNODB_CACHED_INDEXES                 |
| INNODB_CMP                            |
| INNODB_CMP_PER_INDEX                  |
| INNODB_CMP_PER_INDEX_RESET            |
| INNODB_CMP_RESET                      |
| INNODB_CMPMEM                         |
| INNODB_CMPMEM_RESET                   |
| INNODB_COLUMNS                        |
| INNODB_DATAFILES                      |
| INNODB_FIELDS                         |
| INNODB_FOREIGN                        |
| INNODB_FOREIGN_COLS                   |
| INNODB_FT_BEING_DELETED               |
| INNODB_FT_CONFIG                      |
| INNODB_FT_DEFAULT_STOPWORD            |
| INNODB_FT_DELETED                     |
| INNODB_FT_INDEX_CACHE                 |
| INNODB_FT_INDEX_TABLE                 |
| INNODB_INDEXES                        |
| INNODB_METRICS                        |
| INNODB_SESSION_TEMP_TABLESPACES       |
| INNODB_TABLES                         |
| INNODB_TABLESPACES                    |
| INNODB_TABLESPACES_BRIEF              |
| INNODB_TABLESTATS                     |
| INNODB_TEMP_TABLE_INFO                |
| INNODB_TRX                            |
| INNODB_VIRTUAL                        |
| KEY_COLUMN_USAGE                      |
| KEYWORDS                              |
| OPTIMIZER_TRACE                       |
| PARAMETERS                            |
| PARTITIONS                            |
| PLUGINS                               |
| PROCESSLIST                           |
| PROFILING                             |
| REFERENTIAL_CONSTRAINTS               |
| RESOURCE_GROUPS                       |
| ROLE_COLUMN_GRANTS                    |
| ROLE_ROUTINE_GRANTS                   |
| ROLE_TABLE_GRANTS                     |
| ROUTINES                              |
| SCHEMA_PRIVILEGES                     |
| SCHEMATA                              |
| ST_GEOMETRY_COLUMNS                   |
| ST_SPATIAL_REFERENCE_SYSTEMS          |
| ST_UNITS_OF_MEASURE                   |
| STATISTICS                            |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TABLES                                |
| TABLESPACES                           |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEW_ROUTINE_USAGE                    |
| VIEW_TABLE_USAGE                      |
| VIEWS                                 |
+---------------------------------------+
73 rows in set (0.01 sec)
__________________

And I had no problem in shutting down MySQL server 8.0.20.

Hence, I do not see how can this be a bug .......
[14 May 2020 1:44] bo pang
hi, mr Milivojevic,
Thank for your reply.
I also hardlly Reproduce the problem local.
I have some result screenshot show you, in files.
[14 May 2020 1:45] bo pang
admin socket bind error

Attachment: 未命名图片.png (image/png, text), 64.90 KiB.

[14 May 2020 1:46] bo pang
admin fd bind the second m_fds

Attachment: CEBF9C82-71BF-4E89-9A2C-5BE96EA47E5F.png (image/png, text), 8.89 KiB.

[14 May 2020 1:48] bo pang
admin fd first insert, non admin fd is less than admin fd, so the non admin fd be the first one

Attachment: 未命名图片1.png (image/png, text), 73.31 KiB.

[14 May 2020 12:30] MySQL Verification Team
Hi Mr. pang,

Thank you for your feedback. However, what we require is a fully reproducible test case, not pictures.

Next, if you are connecting through the socket file, you can do it only locally.

Last, but not least, I tried connecting remotely, through the non-admin port and I did not have any problems.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.