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

ASAN use-after-poison in my_strcasecmp_utf8 / Item::eq upon prepared statement with ORDER BY NAME_CONST

    Details

      Description

      PREPARE stmt FROM "SELECT 'x' ORDER BY NAME_CONST( 'f', 'foo' )";
      EXECUTE stmt;
      

      10.1 ASAN 1d56d875fe2

      ==17882==ERROR: AddressSanitizer: use-after-poison on address 0x62b0000239c8 at pc 0x558fa040b217 bp 0x7f6549739b10 sp 0x7f6549739b08
      READ of size 1 at 0x62b0000239c8 thread T6
          #0 0x558fa040b216 in my_strcasecmp_utf8 /data/src/10.1/strings/ctype-utf8.c:5224
          #1 0x558f9f592aaa in Item::eq(Item const*, bool) const /data/src/10.1/sql/item.cc:1102
          #2 0x558f9ef6a59d in find_item_in_list(Item*, List<Item>&, unsigned int*, find_item_error_report_type, enum_resolution_type*) /data/src/10.1/sql/sql_base.cc:7141
          #3 0x558f9f0cc7b7 in find_order_in_list /data/src/10.1/sql/sql_select.cc:22273
          #4 0x558f9f12a9de in setup_order(THD*, Item**, TABLE_LIST*, List<Item>&, List<Item>&, st_order*) /data/src/10.1/sql/sql_select.cc:22401
          #5 0x558f9f1353ea in setup_without_group /data/src/10.1/sql/sql_select.cc:663
          #6 0x558f9f1353ea in JOIN::prepare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.1/sql/sql_select.cc:811
          #7 0x558f9f1609c7 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:3477
          #8 0x558f9f161343 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.1/sql/sql_select.cc:388
          #9 0x558f9f03043b in execute_sqlcom_select /data/src/10.1/sql/sql_parse.cc:5950
          #10 0x558f9f04a64b in mysql_execute_command(THD*) /data/src/10.1/sql/sql_parse.cc:2995
          #11 0x558f9f09ab6c in Prepared_statement::execute(String*, bool) /data/src/10.1/sql/sql_prepare.cc:4322
          #12 0x558f9f09b71d in Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*) /data/src/10.1/sql/sql_prepare.cc:3954
          #13 0x558f9f09cb94 in mysql_sql_stmt_execute(THD*) /data/src/10.1/sql/sql_prepare.cc:3070
          #14 0x558f9f04a674 in mysql_execute_command(THD*) /data/src/10.1/sql/sql_parse.cc:3006
          #15 0x558f9f062877 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.1/sql/sql_parse.cc:7468
          #16 0x558f9f06965b in dispatch_command(enum_server_command, THD*, char*, unsigned int) /data/src/10.1/sql/sql_parse.cc:1496
          #17 0x558f9f06fde7 in do_command(THD*) /data/src/10.1/sql/sql_parse.cc:1124
          #18 0x558f9f317c69 in do_handle_one_connection(THD*) /data/src/10.1/sql/sql_connect.cc:1330
          #19 0x558f9f31817a in handle_one_connection /data/src/10.1/sql/sql_connect.cc:1242
          #20 0x558f9fbe6cb4 in pfs_spawn_thread /data/src/10.1/storage/perfschema/pfs.cc:1861
          #21 0x7f6555e70493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #22 0x7f655422993e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x62b0000239c8 is located 1992 bytes inside of 24716-byte region [0x62b000023200,0x62b00002928c)
      allocated by thread T6 here:
          #0 0x7f65560da73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x558fa03b068d in sf_malloc /data/src/10.1/mysys/safemalloc.c:115
          #2 0x558fa04a90da (/data/bld/10.1-asan/bin/mysqld+0x1d9b0da)
       
      Thread T6 created by T0 here:
          #0 0x7f65560a9bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x558f9fbf250b in spawn_thread_v1 /data/src/10.1/storage/perfschema/pfs.cc:1911
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.1/strings/ctype-utf8.c:5224 my_strcasecmp_utf8
      Shadow bytes around the buggy address:
        0x0c567fffc6e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fffc6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fffc700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fffc710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fffc720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c567fffc730: 00 00 00 00 00 00 00 00 00[f7]f7 f7 f7 f7 f7 f7
        0x0c567fffc740: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffc750: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffc760: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffc770: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffc780: 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
        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
      ==17882==ABORTING
      

      10.4 30da40bb8c3

      ==18839==ERROR: AddressSanitizer: use-after-poison on address 0x62b000062b68 at pc 0x5569486415ec bp 0x7f93887f07a0 sp 0x7f93887f0798
      READ of size 1 at 0x62b000062b68 thread T5
          #0 0x5569486415eb in my_strcasecmp_utf8 /data/src/10.4/strings/ctype-utf8.c:5109
          #1 0x55694745dd81 in lex_string_cmp /data/src/10.4/sql/lex_string.h:28
          #2 0x556947466cd7 in Item::eq(Item const*, bool) const /data/src/10.4/sql/item.cc:1122
          #3 0x556946b9dd33 in find_item_in_list(Item*, List<Item>&, unsigned int*, find_item_error_report_type, enum_resolution_type*, unsigned int) /data/src/10.4/sql/sql_base.cc:6616
          #4 0x556946e1f271 in find_order_in_list /data/src/10.4/sql/sql_select.cc:23040
          #5 0x556946e200bc in setup_order(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, st_order*, bool) /data/src/10.4/sql/sql_select.cc:23180
          #6 0x556946d7c2cd in setup_without_group /data/src/10.4/sql/sql_select.cc:666
          #7 0x556946d80f29 in JOIN::prepare(TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.4/sql/sql_select.cc:1113
          #8 0x556946da05f0 in mysql_select(THD*, 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.4/sql/sql_select.cc:4271
          #9 0x556946d7a213 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.4/sql/sql_select.cc:385
          #10 0x556946cfc3b9 in execute_sqlcom_select /data/src/10.4/sql/sql_parse.cc:6567
          #11 0x556946cea86e in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:3776
          #12 0x556946d4d93e in Prepared_statement::execute(String*, bool) /data/src/10.4/sql/sql_prepare.cc:4790
          #13 0x556946d490aa in Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*) /data/src/10.4/sql/sql_prepare.cc:4218
          #14 0x556946d43add in mysql_sql_stmt_execute(THD*) /data/src/10.4/sql/sql_prepare.cc:3326
          #15 0x556946cea8b3 in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:3792
          #16 0x556946d04d8e in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:8104
          #17 0x556946cdf2f4 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1851
          #18 0x556946cdc37c in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1396
          #19 0x5569470527e2 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1402
          #20 0x5569470521ee in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1308
          #21 0x556947bb88c7 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #22 0x7f9394c31493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #23 0x7f939323293e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x62b000062b68 is located 2408 bytes inside of 24716-byte region [0x62b000062200,0x62b00006828c)
      allocated by thread T5 here:
          #0 0x7f9394e9b73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x556948563284 in sf_malloc /data/src/10.4/mysys/safemalloc.c:118
          #2 0x556948533c01 in my_malloc /data/src/10.4/mysys/my_malloc.c:101
          #3 0x556948512df7 in reset_root_defaults /data/src/10.4/mysys/my_alloc.c:151
          #4 0x556946be85fb in THD::init_for_queries() /data/src/10.4/sql/sql_class.cc:1337
          #5 0x556947051ba2 in prepare_new_connection_state(THD*) /data/src/10.4/sql/sql_connect.cc:1239
          #6 0x556947052234 in thd_prepare_connection(THD*) /data/src/10.4/sql/sql_connect.cc:1323
          #7 0x5569470527b8 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1393
          #8 0x5569470521ee in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1308
          #9 0x556947bb88c7 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #10 0x7f9394c31493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T5 created by T0 here:
          #0 0x7f9394e6abba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x556947bb8e8f in spawn_thread_v1 /data/src/10.4/storage/perfschema/pfs.cc:1912
          #2 0x556946a36ea6 in inline_mysql_thread_create /data/src/10.4/include/mysql/psi/mysql_thread.h:1268
          #3 0x556946a4d0c4 in create_thread_to_handle_connection(CONNECT*) /data/src/10.4/sql/mysqld.cc:6436
          #4 0x556946a4d7c9 in create_new_thread(CONNECT*) /data/src/10.4/sql/mysqld.cc:6506
          #5 0x556946a4db59 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.4/sql/mysqld.cc:6623
          #6 0x556946a4e7a5 in handle_connections_sockets() /data/src/10.4/sql/mysqld.cc:6788
          #7 0x556946a4c581 in mysqld_main(int, char**) /data/src/10.4/sql/mysqld.cc:6058
          #8 0x556946a34d2f in main /data/src/10.4/sql/main.cc:25
          #9 0x7f939316a2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.4/strings/ctype-utf8.c:5109 my_strcasecmp_utf8
      Shadow bytes around the buggy address:
        0x0c5680004510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004530: 00 00 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004540: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004550: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      =>0x0c5680004560: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 f7
        0x0c5680004570: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004580: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004590: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800045a0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800045b0: 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
        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
      ==18839==ABORTING
      

      Not reproducible on 10.0.

        Attachments

          Activity

            People

            • Assignee:
              bar Alexander Barkov
              Reporter:
              elenst Elena Stepanova
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: