Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33848

ASAN global-buffer-overflow at sec_since_epoch

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 11.4.1
    • N/A
    • N/A
    • None
    • Ubuntu 20.04 64bit, AddressSanitizer Enabled

    Description

      PoC:

      SELECT CONVERT_TZ(MAX(GREATEST(DATE('2021-00-00'), DATE('2021-00-00'))), '+00:00', '+7:5');
      

      ASAN report:

      ==14549==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000002660a1c at pc 0x000000f137f2 bp 0x7f8d49ad6fd0 sp 0x7f8d49ad6fc8                                                                                                                                                                                   
      READ of size 4 at 0x000002660a1c thread T11                                                                                                                                                                                                                                                                                   
          #0 0xf137f1 in sec_since_epoch(int, int, int, int, int, int) /root/mariadb/sql/tztime.cc:781:10                                                                                                                                                                                                                           
          #1 0xf137f1 in Time_zone_offset::TIME_to_gmt_sec(st_mysql_time const*, unsigned int*) const /root/mariadb/sql/tztime.cc:1398:12                                                                                                                                                                                           
          #2 0x16d5466 in Item_func_convert_tz::get_date(THD*, st_mysql_time*, date_mode_t) /root/mariadb/sql/item_timefunc.cc:2820:27                                                                                                                                                                                              
          #3 0x1184284 in Type_handler::Item_send_datetime(Item*, Protocol*, st_value*) const /root/mariadb/sql/sql_type.cc:7580:9                                                                                                                                                                                                  
          #4 0x90ea0a in Protocol::send_result_set_row(List<Item>*) /root/mariadb/sql/protocol.cc:1333:15                                                                                                                                                                                                                           
          #5 0xa7584c in select_send::send_data(List<Item>&) /root/mariadb/sql/sql_class.cc:3187:17                                                                                                                                                                                                                                 
          #6 0xd0bb1e in select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long) /root/mariadb/sql/sql_class.h:5995:12                                                                                                                                                                       
          #7 0xd0bb1e in end_send_group(JOIN*, st_join_table*, bool) /root/mariadb/sql/sql_select.cc:25079:29                                                                                                                                                                                                                       
          #8 0xcb4198 in do_select(JOIN*, Procedure*) /root/mariadb/sql/sql_select.cc:23046:16                                                                                                                                                                                                                                      
          #9 0xcb4198 in JOIN::exec_inner() /root/mariadb/sql/sql_select.cc:4988:50                                                                                                                                                                                                                                                 
          #10 0xcb1198 in JOIN::exec() /root/mariadb/sql/sql_select.cc:4774:8                                                                                                                                                                                                                                                       
          #11 0xc527c7 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /root/mariadb/sql/sql_select.cc:5304:21                                                                                
          #12 0xc51c68 in handle_select(THD*, LEX*, select_result*, unsigned long long) /root/mariadb/sql/sql_select.cc:630:10                                                                                                                                                                                                      
          #13 0xba71f1 in execute_sqlcom_select(THD*, TABLE_LIST*) /root/mariadb/sql/sql_parse.cc:6094:12                                                                                                                                                                                                                           
          #14 0xb95e8b in mysql_execute_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:3943:12                                                                                                                                                                                                                                  
          #15 0xb88f48 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /root/mariadb/sql/sql_parse.cc:7815:18                                                                                                                                                                                                              
          #16 0xb81d01 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /root/mariadb/sql/sql_parse.cc:1893:7                                                                                                                                                                                              
          #17 0xb89c41 in do_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:1406:17                                                                                                                                                                                                                                             
          #18 0xf82df8 in do_handle_one_connection(CONNECT*, bool) /root/mariadb/sql/sql_connect.cc:1437:11                                                                                                                                                                                                                         
          #19 0xf82848 in handle_one_connection /root/mariadb/sql/sql_connect.cc:1339:5                                                                                                                                                                                                                                             
          #20 0x1b267da in pfs_spawn_thread /root/mariadb/storage/perfschema/pfs.cc:2201:3
          #21 0x7f8d6e58f608 in start_thread /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477:8
          #22 0x7f8d6e2a7352 in clone /build/glibc-wuryBv/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
       
      0x000002660a1c is located 4 bytes to the left of global variable 'mon_starts' defined in '/root/mariadb/sql/tztime.cc:496:19' (0x2660a20) of size 96
      0x000002660a1c is located 41 bytes to the right of global variable 'typeinfo name for Time_zone_offset' defined in '/root/mariadb/sql/tztime.cc' (0x26609e0) of size 19
        'typeinfo name for Time_zone_offset' is ascii string '16Time_zone_offset'
      SUMMARY: AddressSanitizer: global-buffer-overflow /root/mariadb/sql/tztime.cc:781:10 in sec_since_epoch(int, int, int, int, int, int)
      Shadow bytes around the buggy address:
        0x0000804c40f0: f9 f9 f9 f9 00 00 00 00 00 00 00 00 03 f9 f9 f9
        0x0000804c4100: f9 f9 f9 f9 00 00 00 00 00 00 07 f9 f9 f9 f9 f9
        0x0000804c4110: 00 00 00 04 f9 f9 f9 f9 00 00 00 00 00 00 07 f9
        0x0000804c4120: f9 f9 f9 f9 00 00 03 f9 f9 f9 f9 f9 00 00 f9 f9
        0x0000804c4130: f9 f9 f9 f9 00 07 f9 f9 f9 f9 f9 f9 00 00 03 f9
      =>0x0000804c4140: f9 f9 f9[f9]00 00 00 00 00 00 00 00 00 00 00 00
        0x0000804c4150: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
        0x0000804c4160: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 04 f9 f9 f9
        0x0000804c4170: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 03 f9 f9
        0x0000804c4180: f9 f9 f9 f9 00 00 00 02 f9 f9 f9 f9 00 07 f9 f9
        0x0000804c4190: f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9 00 00 00 02
      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 T11 created by T0 here:
          #0 0x8161fc in pthread_create (/root/bin_original/usr/local/mysql/bin/mariadbd+0x8161fc)
          #1 0x1b26a9d in my_thread_create(unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /root/mariadb/storage/perfschema/my_thread.h:52:10
          #2 0x1b26a9d in pfs_spawn_thread_v1 /root/mariadb/storage/perfschema/pfs.cc:2252:15
          #3 0x871689 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 0x871689 in create_thread_to_handle_connection(CONNECT*) /root/mariadb/sql/mysqld.cc:6074:19
          #5 0x872518 in create_new_thread(CONNECT*) /root/mariadb/sql/mysqld.cc:6136:3
          #6 0x872518 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /root/mariadb/sql/mysqld.cc:6198:5
          #7 0x86f988 in handle_connections_sockets() /root/mariadb/sql/mysqld.cc:6311:9
          #8 0x86714a in mysqld_main(int, char**) /root/mariadb/sql/mysqld.cc:5969:3
          #9 0x7f8d6e1ac082 in __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:308:16
       
      ==14549==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              fuboat Jingzhou Fu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.