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

ASAN use-after-poison when complex conversion is involved in blob

    XMLWordPrintable

Details

    Description

      step to reproduce:

       
      CREATE TEMPORARY TABLE v0 ( v2 TINYBLOB AS ( CURRENT_USER IS NULL IS UNKNOWN ) VIRTUAL , v1 TINYINT ZEROFILL , MEDIUM NCHAR BINARY GENERATED ALWAYS AS ( CONVERT ( v1 IN ( FALSE , CURRENT_USER ( ) IS NULL IS NULL , 34 ) , BINARY ( 97015438.000000 ) ) IS NOT UNKNOWN ) ) ;
       
      ALTER TABLE v0 ADD COLUMN v0 MEDIUMINT ZEROFILL KEY UNIQUE COMMENT 'x' ;
       
      INSERT IGNORE INTO v0 VALUES ( CONVERT ( 'x' LIKE v1 IS UNKNOWN , TIME ) , 'x' , v2 IN ( v2 SOUNDS LIKE v1 IS FALSE ) IS UNKNOWN , CONVERT ( 'x' REGEXP 'x' IS NOT FALSE USING BINARY ) IN ( TRUE LIKE v1 IS NOT UNKNOWN ) ) ;
       
      drop table v0;
      
      

      asan report:

       
      ===================================================================3652686==ERROR: AddressSanitizer: use-after-poison on address 0x62b00007a760 at pc 0x55b5f9bdde1e bp 0x7f20a06bc570 sp 0x7f20a06bc560
      READ of size 8 at 0x62b00007a760 thread T18
          #0 0x55b5f9bdde1d in Item_func_in::cleanup() /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/item_cmpfunc.h:2566
          #1 0x55b5f8b42d30 in Item::delete_self() /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/item.h:2514
          #2 0x55b5f8b42d30 in Query_arena::free_items() /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_class.cc:3823
          #3 0x55b5f908c814 in closefrm(TABLE*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/table.cc:4414
          #4 0x55b5f93e8b98 in THD::close_temporary_table(TABLE*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/temporary_tables.cc:1238
          #5 0x55b5f93ee75d in THD::drop_temporary_table(TABLE*, bool*, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/temporary_tables.cc:660
          #6 0x55b5f8f6f876 in mysql_rm_table_no_locks(THD*, TABLE_LIST*, st_mysql_const_lex_string const*, st_ddl_log_state*, bool, bool, bool, bool, bool, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_table.cc:1298
          #7 0x55b5f8f78e7b in mysql_rm_table(THD*, TABLE_LIST*, bool, bool, bool, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_table.cc:1044
          #8 0x55b5f8ccb268 in mysql_execute_command(THD*, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_parse.cc:4952
          #9 0x55b5f8c888dc in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_parse.cc:8028
          #10 0x55b5f8cbe2a3 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_parse.cc:1898
          #11 0x55b5f8cc3703 in do_command(THD*, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_parse.cc:1406
          #12 0x55b5f918314c in do_handle_one_connection(CONNECT*, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1410
          #13 0x55b5f9184806 in handle_one_connection /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1312
          #14 0x55b5f9fcfeef in pfs_spawn_thread /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/storage/perfschema/pfs.cc:2201
          #15 0x7f20bfcea608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
          #16 0x7f20bf8be292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
       
      0x62b00007a760 is located 13664 bytes inside of 24624-byte region [0x62b000077200,0x62b00007d230)
      allocated by thread T18 here:
          #0 0x7f20c0275bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
          #1 0x55b5fab5cafc in my_malloc /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/mysys/my_malloc.c:90
          #2 0x55b5fab437a8 in reset_root_defaults /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/mysys/my_alloc.c:148
          #3 0x55b5f8b36383 in THD::init_for_queries() /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_class.cc:1405
          #4 0x55b5f9180d3a in prepare_new_connection_state(THD*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1240
          #5 0x55b5f9181a4a in thd_prepare_connection(THD*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1333
          #6 0x55b5f9181a4a in thd_prepare_connection(THD*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1322
          #7 0x55b5f91830b2 in do_handle_one_connection(CONNECT*, bool) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1400
          #8 0x55b5f9184806 in handle_one_connection /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/sql_connect.cc:1312
          #9 0x55b5f9fcfeef in pfs_spawn_thread /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/storage/perfschema/pfs.cc:2201
          #10 0x7f20bfcea608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
       
      Thread T18 created by T0 here:
          #0 0x7f20c01a2805 in pthread_create (/lib/x86_64-linux-gnu/libasan.so.5+0x3a805)
          #1 0x55b5f9fd01a2 in my_thread_create /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/storage/perfschema/my_thread.h:48
          #2 0x55b5f9fd01a2 in pfs_spawn_thread_v1 /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/storage/perfschema/pfs.cc:2252
          #3 0x55b5f8958098 in inline_mysql_thread_create /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/include/mysql/psi/mysql_thread.h:1139
          #4 0x55b5f8958098 in create_thread_to_handle_connection(CONNECT*) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/mysqld.cc:5919
          #5 0x55b5f89676b2 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/mysqld.cc:6040
          #6 0x55b5f896847e in handle_connections_sockets() /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/mysqld.cc:6164
          #7 0x55b5f896a60b in mysqld_main(int, char**) /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/mysqld.cc:5814
          #8 0x7f20bf7c30b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
       
      SUMMARY: AddressSanitizer: use-after-poison /home/supersix/fuzz/security/MariaDB/mariadb-10.6.2/sql/item_cmpfunc.h:2566 in Item_func_in::cleanup()
      Shadow bytes around the buggy address:
        0x0c5680007490: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800074a0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800074b0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800074c0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800074d0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      =>0x0c56800074e0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 f7 f7
        0x0c56800074f0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680007500: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680007510: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680007520: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680007530: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      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
      ==3652686==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              yaoguang yaoguang
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.