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

ASAN heap-buffer-overflow in check_key_in_list / Item_func_json_keys::val_str

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.5
    • JSON
    • None

    Description

      Run the test with --mysqld=--character-set-server=utf32 or start the server this way.
      On some reason, setting character_set_server to utf32 dynamically does not cause the same effect.

      call mtr.add_suppression("'utf32' can not be used as client character set");
       
      SELECT GROUP_CONCAT(JSON_KEYS('{"foo":"bar"}')) AS f;
      

      10.2 b22285e4

      ==614369==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61100000d5bc at pc 0x564b690b39c7 bp 0x7fdce190c2d0 sp 0x7fdce190c2c0
      READ of size 1 at 0x61100000d5bc thread T5
          #0 0x564b690b39c6 in check_key_in_list /data/src/10.2/sql/item_jsonfunc.cc:3203
          #1 0x564b690b4451 in Item_func_json_keys::val_str(String*) /data/src/10.2/sql/item_jsonfunc.cc:3282
          #2 0x564b68e28ce8 in dump_leaf_key /data/src/10.2/sql/item_sum.cc:3201
          #3 0x564b68e2d36e in Item_func_group_concat::add() /data/src/10.2/sql/item_sum.cc:3587
          #4 0x564b68e3168d in Aggregator_simple::add() /data/src/10.2/sql/item_sum.h:708
          #5 0x564b68717e65 in Item_sum::aggregator_add() /data/src/10.2/sql/item_sum.h:553
          #6 0x564b68717adb in Item_sum::reset_and_add() /data/src/10.2/sql/item_sum.h:440
          #7 0x564b686f955c in init_sum_functions /data/src/10.2/sql/sql_select.cc:23859
          #8 0x564b686deac0 in end_send_group(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:20235
          #9 0x564b686d1988 in do_select /data/src/10.2/sql/sql_select.cc:18359
          #10 0x564b6866c13a in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3641
          #11 0x564b68669c51 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3436
          #12 0x564b6866d459 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.2/sql/sql_select.cc:3836
          #13 0x564b68649efb in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
          #14 0x564b685c1132 in execute_sqlcom_select /data/src/10.2/sql/sql_parse.cc:6248
          #15 0x564b685ae0d7 in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:3559
          #16 0x564b685ca6af in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7763
          #17 0x564b685a36f4 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1827
          #18 0x564b685a04b3 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1381
          #19 0x564b6892866c in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #20 0x564b68927f2f in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #21 0x564b69cc414d in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #22 0x7fdcec65d608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
          #23 0x7fdcec237292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
       
      0x61100000d5bc is located 0 bytes to the right of 252-byte region [0x61100000d4c0,0x61100000d5bc)
      allocated by thread T5 here:
          #0 0x7fdcecbc4bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
          #1 0x564b69de0ca0 in sf_malloc /data/src/10.2/mysys/safemalloc.c:118
          #2 0x564b69dacc05 in my_malloc /data/src/10.2/mysys/my_malloc.c:101
          #3 0x564b687a5187 in String::realloc_raw(unsigned long) /data/src/10.2/sql/sql_string.cc:102
          #4 0x564b68392976 in String::realloc_with_extra(unsigned long) /data/src/10.2/sql/sql_string.h:376
          #5 0x564b687ab022 in String::realloc_with_extra_if_needed(unsigned long) /data/src/10.2/sql/sql_string.h:388
          #6 0x564b687a7241 in String::append(char const*, unsigned long) /data/src/10.2/sql/sql_string.cc:488
          #7 0x564b690b427b in Item_func_json_keys::val_str(String*) /data/src/10.2/sql/item_jsonfunc.cc:3262
          #8 0x564b68e28ce8 in dump_leaf_key /data/src/10.2/sql/item_sum.cc:3201
          #9 0x564b68e2d36e in Item_func_group_concat::add() /data/src/10.2/sql/item_sum.cc:3587
          #10 0x564b68e3168d in Aggregator_simple::add() /data/src/10.2/sql/item_sum.h:708
          #11 0x564b68717e65 in Item_sum::aggregator_add() /data/src/10.2/sql/item_sum.h:553
          #12 0x564b68717adb in Item_sum::reset_and_add() /data/src/10.2/sql/item_sum.h:440
          #13 0x564b686f955c in init_sum_functions /data/src/10.2/sql/sql_select.cc:23859
          #14 0x564b686deac0 in end_send_group(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:20235
          #15 0x564b686d1988 in do_select /data/src/10.2/sql/sql_select.cc:18359
          #16 0x564b6866c13a in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3641
          #17 0x564b68669c51 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3436
          #18 0x564b6866d459 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.2/sql/sql_select.cc:3836
          #19 0x564b68649efb in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
          #20 0x564b685c1132 in execute_sqlcom_select /data/src/10.2/sql/sql_parse.cc:6248
          #21 0x564b685ae0d7 in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:3559
          #22 0x564b685ca6af in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7763
          #23 0x564b685a36f4 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1827
          #24 0x564b685a04b3 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1381
          #25 0x564b6892866c in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #26 0x564b68927f2f in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #27 0x564b69cc414d in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #28 0x7fdcec65d608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
       
      Thread T5 created by T0 here:
          #0 0x7fdcecaf1805 in pthread_create (/lib/x86_64-linux-gnu/libasan.so.5+0x3a805)
          #1 0x564b69cc453e in spawn_thread_v1 /data/src/10.2/storage/perfschema/pfs.cc:1919
          #2 0x564b68345083 in inline_mysql_thread_create /data/src/10.2/include/mysql/psi/mysql_thread.h:1246
          #3 0x564b6835cc2b in create_thread_to_handle_connection(CONNECT*) /data/src/10.2/sql/mysqld.cc:6567
          #4 0x564b6835d3c6 in create_new_thread /data/src/10.2/sql/mysqld.cc:6637
          #5 0x564b6835e558 in handle_connections_sockets() /data/src/10.2/sql/mysqld.cc:6895
          #6 0x564b6835bf7c in mysqld_main(int, char**) /data/src/10.2/sql/mysqld.cc:6186
          #7 0x564b6834393c in main /data/src/10.2/sql/main.cc:25
          #8 0x7fdcec13c0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
       
      SUMMARY: AddressSanitizer: heap-buffer-overflow /data/src/10.2/sql/item_jsonfunc.cc:3203 in check_key_in_list
      Shadow bytes around the buggy address:
        0x0c227fff9a60: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
        0x0c227fff9a70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c227fff9a80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
        0x0c227fff9a90: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
        0x0c227fff9aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c227fff9ab0: 00 00 00 00 00 00 00[04]fa fa fa fa fa fa fa fa
        0x0c227fff9ac0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c227fff9ad0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c227fff9ae0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c227fff9af0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c227fff9b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      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
      ==614369==ABORTING
      

      No obvious immediate problem on a non-ASAN build.

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.