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

Aria recovery: KEY_OP_SHIFT adds signed redo length to unsigned page_length with only debug asserts

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (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
    • Q4/2026 Server Maintenance

    Description

      In `storage/maria/ma_key_recover.c`, `_ma_apply_redo_index()` ends every `KEY_OP_SHIFT` with:
      ```c
      case KEY_OP_SHIFT:
      int length= sint2korr(header);
      header+= 2;
      DBUG_ASSERT(page_offset != 0 && page_offset <= page_length &&
      page_length + length <= max_page_size);
      ...
      page_length+= length; /* length is signed; page_length is unsigned */
      ```
      In release builds (`DBUG_OFF`), the assert is a no-op. A crafted positive `length` can push `page_length` past `max_page_size`; a large negative `length` can wrap `page_length` through underflow. Later stores / cleans use that corrupted length (including `_ma_store_page_used` and the trailing `bzero` path).
      This is the page-length side of `KEY_OP_SHIFT` (related to, but distinct from, the negative-length `bmove` OOB issue).

        1. Impact
          Corrupt Aria `REDO_INDEX` during recovery can wrap/inflate `page_length` and lead to further buffer misuse or crash.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1d Original Estimate - 1d
                  1d
                  Remaining:
                  Time Spent - 10m Remaining Estimate - 1d
                  1d
                  Logged:
                  Time Spent - 10m Remaining Estimate - 1d
                  10m

                  Git Integration

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