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

ASAN use-after-poison in strend / get_one_variable with SESSION_TRACK_SYSTEM_VARIABLES

    XMLWordPrintable

    Details

      Description

      SET SESSION_TRACK_SYSTEM_VARIABLES= 'MYISAM_STATS_METHOD';
      SHOW VARIABLES;
      

      10.2 ASAN b0df247d

      ==10383==ERROR: AddressSanitizer: use-after-poison on address 0x62b0000060e4 at pc 0x56195b8be4bc bp 0x7f0353a231a0 sp 0x7f0353a23198
      READ of size 1 at 0x62b0000060e4 thread T5
          #0 0x56195b8be4bb in strend /data/src/10.2/strings/strend.c:45
          #1 0x56195a33b31b in get_one_variable(THD*, st_mysql_show_var const*, enum_var_type, enum_mysql_show_type, system_status_var*, charset_info_st const**, char*, unsigned long*) /data/src/10.2/sql/sql_show.cc:3437
          #2 0x56195a33c166 in show_status_array /data/src/10.2/sql/sql_show.cc:3580
          #3 0x56195a36d288 in fill_variables(THD*, TABLE_LIST*, Item*) /data/src/10.2/sql/sql_show.cc:7535
          #4 0x56195a3755bc in get_schema_tables_result(JOIN*, enum_schema_table_state) /data/src/10.2/sql/sql_show.cc:8461
          #5 0x56195a26c6c3 in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3602
          #6 0x56195a26aac1 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3433
          #7 0x56195a26dd33 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:3833
          #8 0x56195a24cfc7 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
          #9 0x56195a1d378a in execute_sqlcom_select /data/src/10.2/sql/sql_parse.cc:6218
          #10 0x56195a1c1a0e in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:3524
          #11 0x56195a1dc0e5 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7733
          #12 0x56195a1b81df in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1824
          #13 0x56195a1b5284 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1377
          #14 0x56195a4f2895 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #15 0x56195a4f2265 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #16 0x56195b6fac80 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #17 0x7f035f71a4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #18 0x7f035d84ed0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x62b0000060e4 is located 24292 bytes inside of 24716-byte region [0x62b000000200,0x62b00000628c)
      allocated by thread T5 here:
          #0 0x7f035f9f1d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x56195b8002dd in sf_malloc /data/src/10.2/mysys/safemalloc.c:118
          #2 0x56195b7d0b83 in my_malloc /data/src/10.2/mysys/my_malloc.c:101
          #3 0x56195b7b1b72 in reset_root_defaults /data/src/10.2/mysys/my_alloc.c:146
          #4 0x56195a10cecb in THD::init_for_queries() /data/src/10.2/sql/sql_class.cc:1314
          #5 0x56195a4f1c13 in prepare_new_connection_state(THD*) /data/src/10.2/sql/sql_connect.cc:1172
          #6 0x56195a4f22ab in thd_prepare_connection(THD*) /data/src/10.2/sql/sql_connect.cc:1256
          #7 0x56195a4f2848 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1326
          #8 0x56195a4f2265 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #9 0x56195b6fac80 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #10 0x7f035f71a4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
       
      Thread T5 created by T0 here:
          #0 0x7f035f960f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x56195b6fb0bc in spawn_thread_v1 /data/src/10.2/storage/perfschema/pfs.cc:1919
          #2 0x561959f92a32 in inline_mysql_thread_create /data/src/10.2/include/mysql/psi/mysql_thread.h:1246
          #3 0x561959fa7218 in create_thread_to_handle_connection(CONNECT*) /data/src/10.2/sql/mysqld.cc:6516
          #4 0x561959fa78fb in create_new_thread /data/src/10.2/sql/mysqld.cc:6586
          #5 0x561959fa8913 in handle_connections_sockets() /data/src/10.2/sql/mysqld.cc:6861
          #6 0x561959fa6757 in mysqld_main(int, char**) /data/src/10.2/sql/mysqld.cc:6135
          #7 0x561959f913bf in main /data/src/10.2/sql/main.cc:25
          #8 0x7f035d7862e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.2/strings/strend.c:45 in strend
      Shadow bytes around the buggy address:
        0x0c567fff8bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fff8bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c567fff8be0: 00 f7 00 05 f7 01 f7 01 f7 00 00 00 f7 07 f7 01
        0x0c567fff8bf0: f7 01 f7 01 f7 01 f7 01 f7 05 f7 00 00 00 00 00
        0x0c567fff8c00: 00 00 00 00 00 00 00 00 05 f7 00 05 f7 01 f7 01
      =>0x0c567fff8c10: f7 01 f7 01 f7 01 f7 01 f7 00 00 00[04]f7 f7 f7
        0x0c567fff8c20: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fff8c30: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fff8c40: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fff8c50: f7 04 fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c567fff8c60: 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
        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
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==10383==ABORTING
      

      It seems to be limited to engine-specific variables.
      Couldn't reproduce on 10.3+.
      No obvious problem on a non-ASAN build.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.