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

AddressSanitizer: heap-use-after-free in make_date_time on weird combination of functions

    Details

      Description

      SELECT INET_ATON( FROM_UNIXTIME( @@timestamp, ( TRIM( UNHEX(HEX('%m.%d.%Y') ) ) ) ) );
      

      10.0 4b8cd4536a2c ASAN

      ==5964==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d00000d590 at pc 0xd87a68 bp 0x7ff274465450 sp 0x7ff274465448
      READ of size 1 at 0x60d00000d590 thread T5
          #0 0xd87a67 in make_date_time /data/src/10.0/sql/item_timefunc.cc:471
          #1 0xd87a67 in Item_func_date_format::val_str(String*) /data/src/10.0/sql/item_timefunc.cc:1975
          #2 0xb91f5b in Item::val_str_ascii(String*) /data/src/10.0/sql/item.cc:278
          #3 0xf7ffe6 in Item_func_inet_aton::val_int() /data/src/10.0/sql/item_inetfunc.cc:43
          #4 0xb91822 in Item::send(Protocol*, String*) /data/src/10.0/sql/item.cc:6651
          #5 0x547221 in Protocol::send_result_set_row(List<Item>*) /data/src/10.0/sql/protocol.cc:912
          #6 0x64407a in select_send::send_data(List<Item>&) /data/src/10.0/sql/sql_class.cc:2572
          #7 0x7d454f in JOIN::exec_inner() /data/src/10.0/sql/sql_select.cc:2465
          #8 0x7dd343 in JOIN::exec() /data/src/10.0/sql/sql_select.cc:2379
          #9 0x7d24a6 in mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.0/sql/sql_select.cc:3318
          #10 0x7d2ad6 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.0/sql/sql_select.cc:373
          #11 0x6b566c in execute_sqlcom_select /data/src/10.0/sql/sql_parse.cc:5293
          #12 0x6ccea8 in mysql_execute_command(THD*) /data/src/10.0/sql/sql_parse.cc:2553
          #13 0x6e19f7 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.0/sql/sql_parse.cc:6569
          #14 0x6e5616 in dispatch_command(enum_server_command, THD*, char*, unsigned int) /data/src/10.0/sql/sql_parse.cc:1296
          #15 0x6e9f0f in do_command(THD*) /data/src/10.0/sql/sql_parse.cc:999
          #16 0x975c3b in do_handle_one_connection(THD*) /data/src/10.0/sql/sql_connect.cc:1377
          #17 0x975ea2 in handle_one_connection /data/src/10.0/sql/sql_connect.cc:1292
          #18 0x11a95d4 in pfs_spawn_thread /data/src/10.0/storage/perfschema/pfs.cc:1861
          #19 0x7ff27ea78493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #20 0x7ff27ce3193e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x60d00000d590 is located 112 bytes inside of 132-byte region [0x60d00000d520,0x60d00000d5a4)
      freed by thread T5 here:
          #0 0x7ff27ece2527 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54527)
          #1 0x18e68b3 in free_memory /data/src/10.0/mysys/safemalloc.c:276
       
      previously allocated by thread T5 here:
          #0 0x7ff27ece273f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x18e6986 in sf_malloc /data/src/10.0/mysys/safemalloc.c:115
          #2 0x19c964a (/data/bld/10.0-asan/bin/mysqld+0x19c964a)
       
      Thread T5 created by T0 here:
          #0 0x7ff27ecb1bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x11b4e2b in spawn_thread_v1 /data/src/10.0/storage/perfschema/pfs.cc:1911
       
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.0/sql/item_timefunc.cc:471 make_date_time
      Shadow bytes around the buggy address:
        0x0c1a7fff9a60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fff9a70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fff9a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fff9a90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fff9aa0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
      =>0x0c1a7fff9ab0: fd fd[fd]fd fd fa fa fa fa fa fa fa fa fa 00 00
        0x0c1a7fff9ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04
        0x0c1a7fff9ae0: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
        0x0c1a7fff9af0: fa fa fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1a7fff9b00: fd fd fd fd fa fa fa fa fa fa fa fa fd fd fd fd
      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
        Heap right redzone:      fb
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack partial redzone:   f4
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Contiguous container OOB:fc
        ASan internal:           fe
      ==5964==ABORTING
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: