[MDEV-28088] MariaDB Global Buffer Overflow issue Created: 2022-03-16  Updated: 2022-03-18  Resolved: 2022-03-18

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 10.9.0
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Jingzhou Fu Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Linux jie-2 5.4.143-1-pve #1 SMP PVE 5.4.143-1 (Tue, 28 Sep 2021 09:10:37 +0200) x86_64 x86_64 x86_64 GNU/Linux


Issue Links:
Duplicate
duplicates MDEV-26407 Server crashes in Item_func_in::clean... Closed

 Description   

PoC:

CREATE TABLE v0 ( v2 BIGINT , v1 INT DEFAULT ( v2 + -1 ) ) ;
OPTIMIZE TABLE v0 ; SELECT '' , '' , NULL ;
ALTER TABLE v0 ADD v0 CHAR ( 13 ) ;
UPDATE IGNORE v0 SET v2 = 0 ;
ALTER TABLE v0 ADD ( SOCKET TIME DEFAULT ( LEFT ( v1 * -128 + TRUE , 19018902.000000 ^ ( CASE WEEK ( 'x' ) / 'x' WHEN CONVERT ( 5 , DOUBLE ) THEN 66 END ) ) ) PRIMARY KEY ) ;
DELETE FROM v0 WHERE NOT WEEK ( 'x' ) / 96 ;
DELETE FROM v0 WHERE COALESCE ( NULL , LAST_INSERT_ID ( + ( 'x' AND REPLACE ( 'x' , 'x' , 'x' ) ) ) ) ;

report (compiled with ASAN):

=================================================================
==8358==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000003b9d609 at pc 0x0000017261d3 bp 0x7fc4d62677c0 sp 0x7fc4d62677b8
READ of size 8 at 0x000003b9d609 thread T16
    #0 0x17261d2 in Predicant_to_list_comparator::Predicant_to_value_comparator::cleanup() /root/mariadb/sql/item_cmpfunc.h:2105:9
    #1 0x17261d2 in Predicant_to_list_comparator::cleanup() /root/mariadb/sql/item_cmpfunc.h:2214:24
    #2 0x17261d2 in Item_func_case_simple::cleanup() /root/mariadb/sql/item_cmpfunc.h:2397:35
    #3 0x1603ff1 in Item::cleanup_processor(void*) /root/mariadb/sql/item.cc:572:5
    #4 0x8eaecb in Item_args::walk_args(bool (Item::*)(void*), bool, void*) /root/mariadb/sql/item.h:2741:20
    #5 0x8eaecb in Item_func_or_sum::walk(bool (Item::*)(void*), bool, void*) /root/mariadb/sql/item.h:5437:9
    #6 0x8eaecb in Item_args::walk_args(bool (Item::*)(void*), bool, void*) /root/mariadb/sql/item.h:2741:20
    #7 0x8eaecb in Item_func_or_sum::walk(bool (Item::*)(void*), bool, void*) /root/mariadb/sql/item.h:5437:9
    #8 0x104a071 in fix_session_vcol_expr(THD*, Virtual_column_info*) /root/mariadb/sql/table.cc:3622:15
    #9 0xa9fb5d in TABLE::fix_vcol_exprs(THD*) /root/mariadb/sql/sql_base.cc:5447:9
    #10 0xa9fb5d in fix_all_session_vcol_exprs(THD*, TABLE_LIST*) /root/mariadb/sql/sql_base.cc:5478:17
    #11 0xa9fb5d in lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int) /root/mariadb/sql/sql_base.cc:5662:13
    #12 0xaa205e in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /root/mariadb/sql/sql_base.cc:5274:7
    #13 0xb3925d in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /root/mariadb/sql/sql_base.h:509:10
    #14 0xb3925d in mysql_delete(THD*, TABLE_LIST*, Item*, SQL_I_List<st_order>*, unsigned long long, unsigned long long, select_result*) /root/mariadb/sql/sql_delete.cc:341:7
    #15 0xc69ee7 in mysql_execute_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:4804:11
    #16 0xc4a67e in mysql_parse(THD*, char*, unsigned int, Parser_state*) /root/mariadb/sql/sql_parse.cc:8027:18
    #17 0xc41ba9 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /root/mariadb/sql/sql_parse.cc:1894:7
    #18 0xc4b74b in do_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:1402:17
    #19 0x111f9f2 in do_handle_one_connection(CONNECT*, bool) /root/mariadb/sql/sql_connect.cc:1418:11
    #20 0x111f248 in handle_one_connection /root/mariadb/sql/sql_connect.cc:1312:5
    #21 0x1f3f9dd in pfs_spawn_thread /root/mariadb/storage/perfschema/pfs.cc:2201:3
    #22 0x7fc4fc246608 in start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477:8
    #23 0x7fc4fbf5c162 in clone /build/glibc-sMfBJT/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
 
0x000003b9d609 is located 23 bytes to the left of global variable 'vtable for cmp_item_real' defined in '/root/mariadb/sql/item_cmpfunc.cc' (0x3b9d620) of size 80
0x000003b9d609 is located 17 bytes to the right of global variable 'typeinfo for cmp_item_timestamp' defined in '/root/mariadb/sql/item_cmpfunc.cc' (0x3b9d5e0) of size 24
SUMMARY: AddressSanitizer: global-buffer-overflow /root/mariadb/sql/item_cmpfunc.h:2105:9 in Predicant_to_list_comparator::Predicant_to_value_comparator::cleanup()
Shadow bytes around the buggy address:
  0x00008076ba70: f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 00 00 00 00
  0x00008076ba80: 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 00 00 00 f9
  0x00008076ba90: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 f9 f9
  0x00008076baa0: f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 00 00 00 00
  0x00008076bab0: 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 00 00 00 f9
=>0x00008076bac0: f9[f9]f9 f9 00 00 00 00 00 00 00 00 00 00 f9 f9
  0x00008076bad0: f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 00 00 00 00
  0x00008076bae0: 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 00 00 00 f9
  0x00008076baf0: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008076bb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008076bb10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
Thread T16 created by T0 here:
    #0 0x7f9cfc in pthread_create (/usr/local/mysql/bin/mariadbd+0x7f9cfc)
    #1 0x1f3fd39 in my_thread_create(unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /root/mariadb/storage/perfschema/my_thread.h:52:10
    #2 0x1f3fd39 in pfs_spawn_thread_v1 /root/mariadb/storage/perfschema/pfs.cc:2252:15
    #3 0x85cef4 in inline_mysql_thread_create(unsigned int, unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /root/mariadb/include/mysql/psi/mysql_thread.h:1139:11
    #4 0x85cef4 in create_thread_to_handle_connection(CONNECT*) /root/mariadb/sql/mysqld.cc:5975:19
    #5 0x85e72a in create_new_thread(CONNECT*) /root/mariadb/sql/mysqld.cc:6034:3
    #6 0x85e72a in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /root/mariadb/sql/mysqld.cc:6096:5
    #7 0x85a34c in handle_connections_sockets() /root/mariadb/sql/mysqld.cc:6220:9
    #8 0x84e9ef in mysqld_main(int, char**) /root/mariadb/sql/mysqld.cc:5870:3
    #9 0x7fc4fbe610b2 in __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:308:16



 Comments   
Comment by Alice Sherepa [ 2022-03-18 ]

The same problem as MDEV-26407

Generated at Thu Feb 08 09:57:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.