mariadb/storage/myisam
Aleksey Midenkov 5b940bdcfc MDEV-25060 Freeing overrun buffer, various crashes, ASAN
heap-buffer-overflow in _mi_put_key_in_record

Rec buffer size depends on vreclength like this:

  length= MY_MAX(length, info->s->vreclength);

The problem is rec buffer is allocated before vreclength is
calculated. The fix reallocates rec buffer if vreclength changed.

1. Rec buffer allocated

  f0  mi_alloc_rec_buff (...) at ../src/storage/myisam/mi_open.c:738
  f1  0x00005f4928244516 in mi_open (...) at ../src/storage/myisam/mi_open.c:671
  f2  0x00005f4928210b98 in ha_myisam::open (...)
      at ../src/storage/myisam/ha_myisam.cc:847
  f3  0x00005f49273aba41 in handler::ha_open (...) at ../src/sql/handler.cc:3105
  f4  0x00005f4927995a65 in open_table_from_share (...)
      at ../src/sql/table.cc:4320
  f5  0x00005f492769f084 in open_table (...) at ../src/sql/sql_base.cc:2024
  f6  0x00005f49276a3ea9 in open_and_process_table (...)
      at ../src/sql/sql_base.cc:3819
  f7  0x00005f49276a29b8 in open_tables (...) at ../src/sql/sql_base.cc:4303
  f8  0x00005f49276a6f3f in open_and_lock_tables (...)
      at ../src/sql/sql_base.cc:5250
  f9  0x00005f49275162de in open_and_lock_tables (...)
      at ../src/sql/sql_base.h:509
  f10 0x00005f4927a30d7a in open_only_one_table (...)
      at ../src/sql/sql_admin.cc:412
  f11 0x00005f4927a2c0c2 in mysql_admin_table (...)
      at ../src/sql/sql_admin.cc:603
  f12 0x00005f4927a2fda8 in Sql_cmd_optimize_table::execute (...)
      at ../src/sql/sql_admin.cc:1517
  f13 0x00005f49278102e3 in mysql_execute_command (...)
      at ../src/sql/sql_parse.cc:6180
  f14 0x00005f49278012d7 in mysql_parse (...) at ../src/sql/sql_parse.cc:8236

2. vreclength calculated

  f0  ha_myisam::setup_vcols_for_repair (...)
      at ../src/storage/myisam/ha_myisam.cc:1002
  f1  0x00005f49282138b4 in ha_myisam::optimize (...)
      at ../src/storage/myisam/ha_myisam.cc:1250
  f2  0x00005f49273b4961 in handler::ha_optimize (...)
      at ../src/sql/handler.cc:4896
  f3  0x00005f4927a2d254 in mysql_admin_table (...)
      at ../src/sql/sql_admin.cc:875
  f4  0x00005f4927a2fda8 in Sql_cmd_optimize_table::execute (...)
      at ../src/sql/sql_admin.cc:1517
  f5  0x00005f49278102e3 in mysql_execute_command (...)
      at ../src/sql/sql_parse.cc:6180
  f6  0x00005f49278012d7 in mysql_parse (...) at ../src/sql/sql_parse.cc:8236

FYI backtrace was done with

  set print frame-info location
  set print frame-arguments presence
  set width 80
2024-10-08 13:08:10 +03:00
..
ftbench mtr: use env for perl 2020-06-23 03:24:46 +02:00
mysql-test MDEV-19236 Improve error message for ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE 2019-04-12 12:28:09 +03:00
ChangeLog
CMakeLists.txt Add build on AIX 2020-12-16 08:07:04 +11:00
ft_boolean_search.c MDEV-33478: Tests massively fail with clang-18 -fsanitize=memory 2024-03-18 16:01:29 +02:00
ft_myisam.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
ft_nlq_search.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
ft_parser.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
ft_static.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
ft_stopwords.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
ft_update.c MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB 2023-10-24 03:35:48 +04:00
ftdefs.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
fulltext.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
ha_myisam.cc MDEV-25060 Freeing overrun buffer, various crashes, ASAN 2024-10-08 13:08:10 +03:00
ha_myisam.h MDEV-25060 Freeing overrun buffer, various crashes, ASAN 2024-10-08 13:08:10 +03:00
mi_cache.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
mi_changed.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_check.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
mi_checksum.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
mi_close.c Merge 10.2 into 10.3 2020-04-22 14:45:55 +03:00
mi_create.c cleanup: remove unused keyinfo flag 2023-08-01 22:43:16 +02:00
mi_dbug.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_delete.c MDEV-27030 vcol.vcol_keys_myisam fails on Windows x64, with Visual Studio 2022 2021-11-12 00:32:39 +01:00
mi_delete_all.c Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
mi_delete_table.c MDEV-11412 Ensure that table is truly dropped when using DROP TABLE 2020-06-14 19:39:42 +03:00
mi_dynrec.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
mi_extra.c MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS 2024-05-06 17:16:10 +02:00
mi_extrafunc.h Update FSF Address 2019-05-11 21:29:06 +03:00
mi_info.c MDEV-24841: More workarounds 2022-03-14 10:37:39 +02:00
mi_key.c Merge 10.4 into 10.5 2020-11-03 16:24:47 +02:00
mi_keycache.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_locking.c Merge 10.4 into 10.5 2023-01-03 17:08:42 +02:00
mi_log.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_open.c MDEV-31083 ASAN use-after-poison in myrg_attach_children 2023-05-23 09:16:36 +03:00
mi_packrec.c Fixed access of undefined memory for compressed MyISAM and Aria tables 2020-06-14 19:39:42 +03:00
mi_page.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_panic.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_preload.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
mi_range.c Added page_range to records_in_range() to improve range statistics 2020-03-27 03:54:45 +02:00
mi_rename.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rfirst.c Fix spelling mistakes in MyISAM code comments 2019-09-20 07:21:21 +03:00
mi_rkey.c MDEV-21794: Optimizer flag rowid_filter leads to long query 2020-05-07 12:27:17 +02:00
mi_rlast.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rnext.c MDEV-21794: Optimizer flag rowid_filter leads to long query 2020-05-07 12:27:17 +02:00
mi_rnext_same.c MDEV-21794: Optimizer flag rowid_filter leads to long query 2020-05-07 12:27:17 +02:00
mi_rprev.c MDEV-21794: Optimizer flag rowid_filter leads to long query 2020-05-07 12:27:17 +02:00
mi_rrnd.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rsame.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rsamepos.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_scan.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_search.c Merge remote-tracking branch 'origin/10.1' into 10.2 2019-09-24 19:19:25 +04:00
mi_static.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
mi_statrec.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_test1.c Added 'const' to arguments in get_one_option and find_typeset() 2021-02-08 12:16:29 +02:00
mi_test2.c Added page_range to records_in_range() to improve range statistics 2020-03-27 03:54:45 +02:00
mi_test3.c Fix clang -Wunused-but-set-variable 2022-09-19 13:30:52 +03:00
mi_test_all.res
mi_test_all.sh Merge remote-tracking branch 'origin/5.5' into 10.1 2019-09-24 11:18:39 +04:00
mi_unique.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
mi_update.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
mi_write.c Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
myisam_ftdump.c Merge 10.4 into 10.5 2022-10-06 08:29:56 +03:00
myisamchk.c Fix various spelling errors still found in code 2021-03-22 18:10:39 +11:00
myisamdef.h MDEV-31083 ASAN use-after-poison in myrg_attach_children 2023-05-23 09:16:36 +03:00
myisamlog.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
myisampack.c Merge 10.4 into 10.5 2021-04-21 09:01:01 +03:00
NEWS Merge remote-tracking branch 'origin/10.1' into 10.2 2019-09-24 19:19:25 +04:00
rt_index.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
rt_index.h Update FSF Address 2019-05-11 21:29:06 +03:00
rt_key.c Update FSF Address 2019-05-11 21:29:06 +03:00
rt_key.h Update FSF Address 2019-05-11 21:29:06 +03:00
rt_mbr.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
rt_mbr.h Update FSF Address 2019-05-11 21:29:06 +03:00
rt_split.c Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
rt_test.c Merge 10.4 into 10.5 2021-08-25 07:53:23 +03:00
sort.c Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
sp_defs.h Update FSF Address 2019-05-11 21:29:06 +03:00
sp_key.c MDEV-21082: isnan/isinf compilation errors, isfinite warnings on MacOS 2019-11-19 16:28:15 +03:00
sp_test.c Added page_range to records_in_range() to improve range statistics 2020-03-27 03:54:45 +02:00
test_pack