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

ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT

    Details

      Description

      SELECT DATE_FORMAT(100000000000, '%j');
      

      10.1 ASAN 5b827511

      ==14138==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f80d293096f at pc 0x5582cf972804 bp 0x7f80d2930770 sp 0x7f80d2930768
      WRITE of size 1 at 0x7f80d293096f thread T6
          #0 0x5582cf972803 in int10_to_str /data/src/10.1/strings/int2str.c:174
          #1 0x5582cece9ffe in make_date_time /data/src/10.1/sql/item_timefunc.cc:584
          #2 0x5582cece9ffe in Item_func_date_format::val_str(String*) /data/src/10.1/sql/item_timefunc.cc:1986
          #3 0x5582ceae3198 in Item::send(Protocol*, String*) /data/src/10.1/sql/item.cc:6392
          #4 0x5582ce3f0a84 in Protocol::send_result_set_row(List<Item>*) /data/src/10.1/sql/protocol.cc:914
          #5 0x5582ce4faa39 in select_send::send_data(List<Item>&) /data/src/10.1/sql/sql_class.cc:2748
          #6 0x5582ce6a9429 in JOIN::exec_inner() /data/src/10.1/sql/sql_select.cc:2641
          #7 0x5582ce6b277c in JOIN::exec() /data/src/10.1/sql/sql_select.cc:2562
          #8 0x5582ce6a6fcf 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
          #9 0x5582ce6a77bd in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.1/sql/sql_select.cc:388
          #10 0x5582ce57699f in execute_sqlcom_select /data/src/10.1/sql/sql_parse.cc:5950
          #11 0x5582ce590baf in mysql_execute_command(THD*) /data/src/10.1/sql/sql_parse.cc:2995
          #12 0x5582ce5a8dc0 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.1/sql/sql_parse.cc:7468
          #13 0x5582ce5afba4 in dispatch_command(enum_server_command, THD*, char*, unsigned int) /data/src/10.1/sql/sql_parse.cc:1496
          #14 0x5582ce5b6330 in do_command(THD*) /data/src/10.1/sql/sql_parse.cc:1124
          #15 0x5582ce85e805 in do_handle_one_connection(THD*) /data/src/10.1/sql/sql_connect.cc:1330
          #16 0x5582ce85ed16 in handle_one_connection /data/src/10.1/sql/sql_connect.cc:1242
          #17 0x5582cf12dc68 in pfs_spawn_thread /data/src/10.1/storage/perfschema/pfs.cc:1861
          #18 0x7f80df062493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #19 0x7f80dd41b93e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      Address 0x7f80d293096f is located in stack of thread T6 at offset 207 in frame
          #0 0x5582cece8dd7 in Item_func_date_format::val_str(String*) /data/src/10.1/sql/item_timefunc.cc:1951
       
        This frame has 3 object(s):
          [32, 36) 'year'
          [96, 136) 'l_time'
          [192, 207) 'intbuff' <== Memory access at offset 207 overflows this variable
      HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
            (longjmp and C++ exceptions *are* supported)
      Thread T6 created by T0 here:
          #0 0x7f80df29bbba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x5582cf1394bf in spawn_thread_v1 /data/src/10.1/storage/perfschema/pfs.cc:1911
       
      SUMMARY: AddressSanitizer: stack-buffer-overflow /data/src/10.1/strings/int2str.c:174 int10_to_str
      Shadow bytes around the buggy address:
        0x0ff09a51e0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0ff09a51e0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0ff09a51e0f0: f1 f1 f1 f1 00 00 00 00 00 00 00 00 01 f4 f4 f4
        0x0ff09a51e100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0ff09a51e110: 00 00 00 00 f1 f1 f1 f1 04 f4 f4 f4 f2 f2 f2 f2
      =>0x0ff09a51e120: 00 00 00 00 00 f4 f4 f4 f2 f2 f2 f2 00[07]f4 f4
        0x0ff09a51e130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0ff09a51e140: f1 f1 f1 f1 00 00 00 00 00 f4 f4 f4 f3 f3 f3 f3
        0x0ff09a51e150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
        0x0ff09a51e160: f1 f1 00 00 00 00 f2 f2 f2 f2 00 00 00 00 f2 f2
        0x0ff09a51e170: f2 f2 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
        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
      ==14138==ABORTING
      

      No visible effect on a non-ASAN build.

        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: