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

AddressSanitizer: stack-buffer-overflow in strxmov

    XMLWordPrintable

Details

    Description

      CREATE TABLE `##################################################_long`.`#################################################_long`(a SERIAL);
      

      Leads to:

      10.11.0 fe1f8f2c6b6f3b8e3383168225f9ae7853028947 (Debug, UBASAN)

      ==1279673==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x152ed05ed540 at pc 0x5646791af09a bp 0x152ed05ec090 sp 0x152ed05ec080
      WRITE of size 1 at 0x152ed05ed540 thread T14
          #0 0x5646791af099 in strxmov /test/10.11_dbg_san/strings/strxmov.c:53
          #1 0x56467549396f in deletefrm(char const*) /test/10.11_dbg_san/sql/discover.h:31
          #2 0x56467549396f in create_table_impl /test/10.11_dbg_san/sql/sql_table.cc:4600
          #3 0x564675494d4f in mysql_create_table_no_lock(THD*, st_ddl_log_state*, st_ddl_log_state*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*) /test/10.11_dbg_san/sql/sql_table.cc:4697
          #4 0x5646754a07cc in mysql_create_table /test/10.11_dbg_san/sql/sql_table.cc:4813
          #5 0x5646754a07cc in Sql_cmd_create_table_like::execute(THD*) /test/10.11_dbg_san/sql/sql_table.cc:12334
          #6 0x564674df5903 in mysql_execute_command(THD*, bool) /test/10.11_dbg_san/sql/sql_parse.cc:5997
          #7 0x564674d3bc88 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/10.11_dbg_san/sql/sql_parse.cc:8035
          #8 0x564674da885f in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/10.11_dbg_san/sql/sql_parse.cc:1894
          #9 0x564674dbaa70 in do_command(THD*, bool) /test/10.11_dbg_san/sql/sql_parse.cc:1407
          #10 0x56467582bb41 in do_handle_one_connection(CONNECT*, bool) /test/10.11_dbg_san/sql/sql_connect.cc:1418
          #11 0x56467582e32c in handle_one_connection /test/10.11_dbg_san/sql/sql_connect.cc:1312
          #12 0x152ef3730608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477
          #13 0x152ef29a5132 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f132)
       
      Address 0x152ed05ed540 is located in stack of thread T14 at offset 4704 in frame
          #0 0x56467548f5ba in create_table_impl /test/10.11_dbg_san/sql/sql_table.cc:4327
       
        This frame has 7 object(s):
          [48, 52) 'options' (line 4323)
          [64, 72) 'db_type' (line 4429)
          [96, 104) 'no_fields' (line 4519)
          [128, 1576) 'share' (line 4516)
          [1712, 3480) 'table_list' (line 4445)
          [3616, 4128) 'frm_name'
          [4192, 4704) 'frm_name' <== Memory access at offset 4704 overflows this variable
      HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
            (longjmp and C++ exceptions *are* supported)
      Thread T14 created by T0 here:
          #0 0x5646742f9295 in __interceptor_pthread_create (/test/UBASAN_MD010922-mariadb-10.11.0-linux-x86_64-dbg/bin/mariadbd+0x7e0f295)
          #1 0x5646744209d3 in create_thread_to_handle_connection(CONNECT*) /test/10.11_dbg_san/sql/mysqld.cc:6018
          #2 0x564674432d12 in create_new_thread(CONNECT*) /test/10.11_dbg_san/sql/mysqld.cc:6077
          #3 0x564674433660 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /test/10.11_dbg_san/sql/mysqld.cc:6139
          #4 0x564674434aef in handle_connections_sockets() /test/10.11_dbg_san/sql/mysqld.cc:6263
          #5 0x564674439463 in mysqld_main(int, char**) /test/10.11_dbg_san/sql/mysqld.cc:5913
          #6 0x56467440d81a in main /test/10.11_dbg_san/sql/main.cc:34
          #7 0x152ef28aa082 in __libc_start_main ../csu/libc-start.c:308
      SUMMARY: AddressSanitizer: stack-buffer-overflow /test/10.11_dbg_san/strings/strxmov.c:53 in strxmov
      Shadow bytes around the buggy address:
        0x02a65a0b5a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5a60: f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
        0x02a65a0b5a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x02a65a0b5aa0: 00 00 00 00 00 00 00 00[f3]f3 f3 f3 f3 f3 f3 f3
        0x02a65a0b5ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5ad0: f1 f1 f1 f1 00 00 00 f2 f2 f2 00 00 f2 f2 00 00
        0x02a65a0b5ae0: f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x02a65a0b5af0: 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
      

      Setup:

      Compiled with GCC >=7.5.0 (I use GCC 9.4.0) and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWITH_RAPID=OFF -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export ASAN_OPTIONS=quarantine_size_mb=512:atexit=1:detect_invalid_pointer_pairs=3:dump_instruction_bytes=1:abort_on_error=1
      

      Bug confirmed present in:
      MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (dbg), 10.4.27 (opt), 10.5.18 (dbg), 10.5.18 (opt), 10.6.10 (dbg), 10.6.10 (opt), 10.7.6 (dbg), 10.7.6 (opt), 10.8.5 (dbg), 10.8.5 (opt), 10.9.2 (dbg), 10.9.2 (opt), 10.10.2 (dbg), 10.10.2 (opt), 10.11.0 (dbg), 10.11.0 (opt)

      Attachments

        Activity

          People

            serg Sergei Golubchik
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.