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

_ma_apply_redo_index: KEY_OP_MULTI_COPY memcpy uses unchecked to/from/full_length (page buffer OOB write)

    XMLWordPrintable

Details

    • Bug
    • Status: In Progress (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.0.1
    • 10.11
    • Storage Engine - Aria
    • None
    • MariaDB Server 13.0.1 (tag mariadb-13.0.1); also present on main tip. Confirmed by source review on macOS arm64.
    • Can result in hang or crash
    • Q3/2026 Server Development

    Description

      In storage/maria/ma_key_recover.c, _ma_apply_redo_index() handles KEY_OP_MULTI_COPY roughly as:

      case KEY_OP_MULTI_COPY:
        full_length= uint2korr(header);
        header+= 2;
        log_memcpy_length= uint2korr(header);
        header+= 2;
        log_memcpy_end= header + log_memcpy_length;
        while (header < log_memcpy_end)
        {
          to= uint2korr(header); header+= 2;
          from= uint2korr(header); header+= 2;
          DBUG_ASSERT(MY_MAX(from, to) < max_page_size);
          memcpy(buff + to, buff + from, full_length);
        }
      

      In release builds (DBUG_OFF), the asserts are no-ops. There is no runtime check that:

      • to + full_length / from + full_length stay inside the page buffer
      • log_memcpy_end stays inside the redo record (header_end)

      A corrupt LOGREC_REDO_INDEX applied during Aria recovery can therefore write past the page buffer.

      Impact

      Crash recovery / redo apply can crash or corrupt memory when processing a malformed MULTI_COPY redo record.

      Attachments

        Activity

          People

            Khaled.amr Khaled Amr
            sxt shixin tan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 3d
                3d
                Remaining:
                Time Spent - 1d 5h Remaining Estimate - 1d 3h
                1d 3h
                Logged:
                Time Spent - 1d 5h Remaining Estimate - 1d 3h
                1d 5h

                Git Integration

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