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

Crash or ASAN heap-buffer-overflow in mach_read_from_n_little_endian upon ALTER TABLE with blob

    XMLWordPrintable

    Details

      Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB;
      ALTER TABLE t1 ADD PRIMARY KEY(b), MODIFY COLUMN IF EXISTS x INT;
       
      # Cleanup
      DROP TABLE t1;
      

      10.3 1d30a23fcc38

      #3  <signal handler called>
      #4  0x00005583eda8bd72 in mach_read_from_n_little_endian (buf=0x7f79e8077dcd "", buf_size=18446744073709551612) at /data/src/10.3/storage/innobase/include/mach0data.ic:701
      #5  0x00005583eda8fe44 in row_mysql_read_blob_ref (len=0x7f7a39ee6448, ref=0x7f79e8077dcd "", col_len=4) at /data/src/10.3/storage/innobase/row/row0mysql.cc:265
      #6  0x00005583eda9050c in row_mysql_store_col_in_innobase_format (dfield=0x7f79e8179680, buf=0x7f79e8179730 '\217' <repeats 40 times>, "\025\003", row_format_col=1, mysql_data=0x7f79e8077dcd "", col_len=4, comp=1) at /data/src/10.3/storage/innobase/row/row0mysql.cc:550
      #7  0x00005583ed96f25e in innobase_build_col_map_add (heap=0x7f79e81792d0, dfield=0x7f79e8179680, field=0x7f79e8077fc8, comp=1) at /data/src/10.3/storage/innobase/handler/handler0alter.cc:3276
      #8  0x00005583ed96f89b in innobase_build_col_map (ha_alter_info=0x7f7a39ee7400, altered_table=0x7f79e8076980, table=0x7f79e800c380, new_table=0x7f79e81797e8, old_table=0x7f79e800dee8, defaults=0x7f79e8179608, heap=0x7f79e81792d0) at /data/src/10.3/storage/innobase/handler/handler0alter.cc:3367
      #9  0x00005583ed975122 in prepare_inplace_alter_table_dict (ha_alter_info=0x7f7a39ee7400, altered_table=0x7f79e8076980, old_table=0x7f79e800c380, table_name=0x7f79e807a045 "t1", flags=33, flags2=80, fts_doc_id_col=18446744073709551615, add_fts_doc_id=false, add_fts_doc_id_idx=false) at /data/src/10.3/storage/innobase/handler/handler0alter.cc:5224
      #10 0x00005583ed97b255 in ha_innobase::prepare_inplace_alter_table (this=0x7f79e800cfc8, altered_table=0x7f79e8076980, ha_alter_info=0x7f7a39ee7400) at /data/src/10.3/storage/innobase/handler/handler0alter.cc:6959
      #11 0x00005583ed625605 in handler::ha_prepare_inplace_alter_table (this=0x7f79e800cfc8, altered_table=0x7f79e8076980, ha_alter_info=0x7f7a39ee7400) at /data/src/10.3/sql/handler.cc:4387
      #12 0x00005583ed407967 in mysql_inplace_alter_table (thd=0x7f79e8000b00, table_list=0x7f79e8014ea8, table=0x7f79e800c380, altered_table=0x7f79e8076980, ha_alter_info=0x7f7a39ee7400, inplace_supported=HA_ALTER_INPLACE_COPY_NO_LOCK, target_mdl_request=0x7f7a39ee7470, alter_ctx=0x7f7a39ee8070) at /data/src/10.3/sql/sql_table.cc:7470
      #13 0x00005583ed40dbc6 in mysql_alter_table (thd=0x7f79e8000b00, new_db=0x7f79e8005170, new_name=0x7f79e8005520, create_info=0x7f7a39ee8c60, table_list=0x7f79e8014ea8, alter_info=0x7f7a39ee8ba0, order_num=0, order=0x0, ignore=false) at /data/src/10.3/sql/sql_table.cc:9644
      #14 0x00005583ed493f26 in Sql_cmd_alter_table::execute (this=0x7f79e80156e0, thd=0x7f79e8000b00) at /data/src/10.3/sql/sql_alter.cc:463
      #15 0x00005583ed338f63 in mysql_execute_command (thd=0x7f79e8000b00) at /data/src/10.3/sql/sql_parse.cc:6283
      #16 0x00005583ed33da9a in mysql_parse (thd=0x7f79e8000b00, rawbuf=0x7f79e8014d78 "ALTER TABLE t1 ADD PRIMARY KEY(b), MODIFY COLUMN IF EXISTS x INT", length=64, parser_state=0x7f7a39eea5e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8003
      #17 0x00005583ed32b19f in dispatch_command (command=COM_QUERY, thd=0x7f79e8000b00, packet=0x7f79e8125ea1 "ALTER TABLE t1 ADD PRIMARY KEY(b), MODIFY COLUMN IF EXISTS x INT", packet_length=64, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1846
      #18 0x00005583ed329bc3 in do_command (thd=0x7f79e8000b00) at /data/src/10.3/sql/sql_parse.cc:1391
      #19 0x00005583ed48e5df in do_handle_one_connection (connect=0x5583f02962b0) at /data/src/10.3/sql/sql_connect.cc:1402
      #20 0x00005583ed48e363 in handle_one_connection (arg=0x5583f02962b0) at /data/src/10.3/sql/sql_connect.cc:1308
      #21 0x00005583ed91d471 in pfs_spawn_thread (arg=0x5583f029e730) at /data/src/10.3/storage/perfschema/pfs.cc:1862
      #22 0x00007f7a46889494 in start_thread (arg=0x7f7a39eeb700) at pthread_create.c:333
      #23 0x00007f7a44c6f93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      10.3 ASAN 2deb17fd542

      ==26768==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900002ad7f at pc 0x55d0b753767d bp 0x7f905c77f440 sp 0x7f905c77f438
      READ of size 1 at 0x61900002ad7f thread T27
          #0 0x55d0b753767c in mach_read_from_n_little_endian /data/src/10.3/storage/innobase/include/mach0data.ic:701
          #1 0x55d0b753f56d in row_mysql_read_blob_ref(unsigned long*, unsigned char const*, unsigned long) /data/src/10.3/storage/innobase/row/row0mysql.cc:265
          #2 0x55d0b7540525 in row_mysql_store_col_in_innobase_format(dfield_t*, unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned long) /data/src/10.3/storage/innobase/row/row0mysql.cc:550
          #3 0x55d0b73252e7 in innobase_build_col_map_add /data/src/10.3/storage/innobase/handler/handler0alter.cc:3276
          #4 0x55d0b7325ea2 in innobase_build_col_map /data/src/10.3/storage/innobase/handler/handler0alter.cc:3367
          #5 0x55d0b7332495 in prepare_inplace_alter_table_dict /data/src/10.3/storage/innobase/handler/handler0alter.cc:5224
          #6 0x55d0b734083a in ha_innobase::prepare_inplace_alter_table(TABLE*, Alter_inplace_info*) /data/src/10.3/storage/innobase/handler/handler0alter.cc:6959
          #7 0x55d0b6b09e78 in handler::ha_prepare_inplace_alter_table(TABLE*, Alter_inplace_info*) /data/src/10.3/sql/handler.cc:4387
          #8 0x55d0b6616d97 in mysql_inplace_alter_table /data/src/10.3/sql/sql_table.cc:7470
          #9 0x55d0b662435f in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) /data/src/10.3/sql/sql_table.cc:9644
          #10 0x55d0b676aa25 in Sql_cmd_alter_table::execute(THD*) /data/src/10.3/sql/sql_alter.cc:463
          #11 0x55d0b640e78b in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:6283
          #12 0x55d0b6418d64 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8003
          #13 0x55d0b63f3534 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1846
          #14 0x55d0b63f05bc in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1391
          #15 0x55d0b675be61 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #16 0x55d0b675b86d in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #17 0x55d0b726f19d in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #18 0x7f90680a6493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #19 0x7f906648c93e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x61900002ad7f is located 1 bytes to the left of 1100-byte region [0x61900002ad80,0x61900002b1cc)
      allocated by thread T27 here:
          #0 0x7f906831073f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x55d0b7c25a7e in sf_malloc /data/src/10.3/mysys/safemalloc.c:118
          #2 0x55d0b7bf60d6 in my_malloc /data/src/10.3/mysys/my_malloc.c:101
          #3 0x55d0b7bd5ac3 in alloc_root /data/src/10.3/mysys/my_alloc.c:249
          #4 0x55d0b66a1bb4 in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /data/src/10.3/sql/table.cc:3198
          #5 0x55d0b6911a7f in THD::open_temporary_table(TMP_TABLE_SHARE*, char const*, bool) /data/src/10.3/sql/temporary_tables.cc:1119
          #6 0x55d0b690c4b1 in THD::create_and_open_tmp_table(handlerton*, st_mysql_const_unsigned_lex_string*, char const*, char const*, char const*, bool, bool) /data/src/10.3/sql/temporary_tables.cc:79
          #7 0x55d0b6623ca9 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) /data/src/10.3/sql/sql_table.cc:9586
          #8 0x55d0b676aa25 in Sql_cmd_alter_table::execute(THD*) /data/src/10.3/sql/sql_alter.cc:463
          #9 0x55d0b640e78b in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:6283
          #10 0x55d0b6418d64 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8003
          #11 0x55d0b63f3534 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1846
          #12 0x55d0b63f05bc in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1391
          #13 0x55d0b675be61 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #14 0x55d0b675b86d in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #15 0x55d0b726f19d in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #16 0x7f90680a6493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T27 created by T0 here:
          #0 0x7f90682dfbba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x55d0b726f765 in spawn_thread_v1 /data/src/10.3/storage/perfschema/pfs.cc:1912
          #2 0x55d0b615f28a in inline_mysql_thread_create /data/src/10.3/include/mysql/psi/mysql_thread.h:1268
          #3 0x55d0b617534f in create_thread_to_handle_connection(CONNECT*) /data/src/10.3/sql/mysqld.cc:6556
          #4 0x55d0b6175a54 in create_new_thread /data/src/10.3/sql/mysqld.cc:6626
          #5 0x55d0b6176a65 in handle_connections_sockets() /data/src/10.3/sql/mysqld.cc:6901
          #6 0x55d0b617480c in mysqld_main(int, char**) /data/src/10.3/sql/mysqld.cc:6178
          #7 0x55d0b615d32f in main /data/src/10.3/sql/main.cc:25
          #8 0x7f90663c42b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: heap-buffer-overflow /data/src/10.3/storage/innobase/include/mach0data.ic:701 mach_read_from_n_little_endian
      Shadow bytes around the buggy address:
        0x0c327fffd550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd580: 00 00 00 00 00 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c327fffd590: f7 f7 f7 f7 f7 f7 f7 f7 f7 04 fa fa fa fa fa fa
      =>0x0c327fffd5a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
        0x0c327fffd5b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd5c0: 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd5d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd5e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c327fffd5f0: 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
        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
      ==26768==ABORTING
      

      Not reproducible on 10.2

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              thiru Thirunarayanan Balathandayuthapani
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: