OpenSBI mpxy: base_attr_id + attr_count can wrap and bypass range checks
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- c
調査の方向性
lib/sbi/sbi_mpxy.c の sbi_mpxy_read_attrs() と sbi_mpxy_write_attrs() における範囲処理を読み、lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c の対応するヘルパーと比較します。呼び出し元が制御する base_attr_id と attr_count の値について、u32 の上限付近をテストします。属性のインデックス処理やコピーが行われる前に、無効なラップアラウンド範囲が拒否されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Title: OpenSBI mpxy: base_attr_id + attr_count can wrap and bypass range checks
Current upstream OpenSBI master (checked in a local clone at 6d5b2b9 on 2026-03-21) still computes attribute end IDs in u32 and then uses the result for range checks:
- lib/sbi/sbi_mpxy.c: sbi_mpxy_read_attrs() and sbi_mpxy_write_attrs()
- lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c: mpxy_mbox_read_attributes() and mpxy_mbox_write_attributes()
The core pattern is:
u32 end_id = base_attr_id + attr_count - 1;
if (end_id >= MAX_ID)
return SBI_EBAD_RANGE;
or equivalent. The problem is that both base_attr_id and attr_count are caller-controlled u32 values. When base_attr_id is close to UINT32_MAX and attr_count is greater than 1, the addition wraps before the range check runs. That can make end_id look small even though the requested range is actually huge. In the mpxy helpers, the code then uses attr_id2index(base_attr_id) and copies attributes from or to the array starting at that wrapped index, so the overflowed range check can lead to out-of-bounds access in the message-protocol attribute array.
The current sanity check only validates that attr_count is non-zero and not larger than the shared-memory size in units of ATTR_SIZE. It does not prevent wraparound in base_attr_id + attr_count - 1, so the bug is still present in current head.
Expected behavior: the range calculation should use overflow-safe arithmetic, or the code should explicitly check base_attr_id > MAX - (attr_count - 1) before adding.
Actual behavior: the u32 addition can wrap and allow a bogus range to pass the bounds check, which then drives out-of-bounds attribute indexing/copying.
This looks like a security-relevant memory-safety bug in the OpenSBI mpxy path.
- 主要言語
- C
- スター
- 1.6k
- フォーク
- 734
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
riscv-software-src/opensbi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
riscv-software-src/opensbi#425 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
riscv-software-src/opensbi#424 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
riscv-software-src/opensbi#439 ·
-
sbi_trap_redirect() does not clear SPELP when the interrupted context had no landing pad expectedオープン
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
riscv-software-src/opensbi#438 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
riscv-software-src/opensbi#436 · コメント 3 件 ·
riscv-software-src/opensbi の issue をすべて見る
似ている issue
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yugabyte/yugabyte-db#39462 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
libreswan/libreswan#3185 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
category:port-update
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信