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

ASAN heap-use-after-free in make_date_time / Arg_comparator::compare_string / Item_func_nullif::compare

    XMLWordPrintable

Details

    Description

      SELECT NULLIF( 'foo', FROM_UNIXTIME( '2012-12-12 12:12:12', TRIM( 0 ) ) );
      

      10.1 431da59f

      ==23977==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000032920 at pc 0x55619e1d755c bp 0x7fa61270d6a0 sp 0x7fa61270d698
      READ of size 1 at 0x60d000032920 thread T6
          #0 0x55619e1d755b in make_date_time /data/src/10.1/sql/item_timefunc.cc:475
          #1 0x55619e1d755b in Item_func_date_format::val_str(String*) /data/src/10.1/sql/item_timefunc.cc:1986
          #2 0x55619e04d7b6 in Arg_comparator::compare_string() /data/src/10.1/sql/item_cmpfunc.cc:850
          #3 0x55619e0564e2 in Arg_comparator::compare() /data/src/10.1/sql/item_cmpfunc.h:87
          #4 0x55619e0564e2 in Item_func_nullif::compare() /data/src/10.1/sql/item_cmpfunc.cc:2904
          #5 0x55619e0568a4 in Item_func_nullif::str_op(String*) /data/src/10.1/sql/item_cmpfunc.cc:2952
          #6 0x55619e0de517 in Item_func_hybrid_field_type::str_op_with_null_check(String*) /data/src/10.1/sql/item_func.h:453
          #7 0x55619e0de517 in Item_func_hybrid_field_type::val_str(String*) /data/src/10.1/sql/item_func.cc:878
          #8 0x55619dfd1228 in Item::send(Protocol*, String*) /data/src/10.1/sql/item.cc:6392
          #9 0x55619d8deb14 in Protocol::send_result_set_row(List<Item>*) /data/src/10.1/sql/protocol.cc:914
          #10 0x55619d9e8ac9 in select_send::send_data(List<Item>&) /data/src/10.1/sql/sql_class.cc:2748
          #11 0x55619db974b9 in JOIN::exec_inner() /data/src/10.1/sql/sql_select.cc:2641
          #12 0x55619dba080c in JOIN::exec() /data/src/10.1/sql/sql_select.cc:2562
          #13 0x55619db9505f 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.1/sql/sql_select.cc:3499
          #14 0x55619db9584d in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.1/sql/sql_select.cc:388
          #15 0x55619da64a2f in execute_sqlcom_select /data/src/10.1/sql/sql_parse.cc:5950
          #16 0x55619da7ec3f in mysql_execute_command(THD*) /data/src/10.1/sql/sql_parse.cc:2995
          #17 0x55619da96e50 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.1/sql/sql_parse.cc:7468
          #18 0x55619da9dc34 in dispatch_command(enum_server_command, THD*, char*, unsigned int) /data/src/10.1/sql/sql_parse.cc:1496
          #19 0x55619daa43c0 in do_command(THD*) /data/src/10.1/sql/sql_parse.cc:1124
          #20 0x55619dd4c895 in do_handle_one_connection(THD*) /data/src/10.1/sql/sql_connect.cc:1330
          #21 0x55619dd4cda6 in handle_one_connection /data/src/10.1/sql/sql_connect.cc:1242
          #22 0x55619e61bca2 in pfs_spawn_thread /data/src/10.1/storage/perfschema/pfs.cc:1861
          #23 0x7fa61ee6b493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #24 0x7fa61d22493e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x60d000032920 is located 112 bytes inside of 140-byte region [0x60d0000328b0,0x60d00003293c)
      freed by thread T6 here:
          #0 0x7fa61f0d5527 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54527)
          #1 0x55619ede7b2d in free_memory /data/src/10.1/mysys/safemalloc.c:276
       
      previously allocated by thread T6 here:
          #0 0x7fa61f0d573f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x55619ede7bfe in sf_malloc /data/src/10.1/mysys/safemalloc.c:115
          #2 0x55619eee065a (/data/bld/10.1-asan/bin/mysqld+0x1d9e65a)
       
      Thread T6 created by T0 here:
          #0 0x7fa61f0a4bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x55619e6274f9 in spawn_thread_v1 /data/src/10.1/storage/perfschema/pfs.cc:1911
       
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.1/sql/item_timefunc.cc:475 make_date_time
      Shadow bytes around the buggy address:
        0x0c1a7fffe4d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fffe4e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fffe4f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fffe500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c1a7fffe510: fa fa fa fa fa fa fd fd fd fd fd fd fd fd fd fd
      =>0x0c1a7fffe520: fd fd fd fd[fd]fd fd fd fa fa fa fa fa fa fa fa
        0x0c1a7fffe530: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1a7fffe540: fd fd fa fa fa fa fa fa fa fa fd fd fd fd fd fd
        0x0c1a7fffe550: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa
        0x0c1a7fffe560: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1a7fffe570: fd fd fd fd fd fd fa fa fa fa fa fa fa fa 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
      ==23977==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.