[Bug] rpmi_shmem_mailbox_controller_init() copies FDT queue names into 16-byte qctx->name without checking length

オープン
#414 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c

調査の方向性

rpmi_shmem_mailbox_controller_init() から始め、reg-names の長さがどのように返され、qctx->name にコピーされるかを調べます。周辺の RPMI mailbox コードで、長すぎる名前がどのように扱われることを想定しているかを確認し、そのうえで、長すぎる FDT キュー名によって固定長フィールドがオーバーフローしないことを確認します。リポジトリに関連する parser テストがある場合は、長すぎるキュー名の入力で動作を検証します。

索引モデルが issue の本文から書いたものです。

説明



Hello,

I reviewed current upstream head and found a real missing length check in the RPMI shared-memory mailbox FDT parser.

The queue context stores the name in a fixed field:

```c
#define RPMI_NAME_CHARS_MAX (16)

struct rpmi_mbox_queue_context {
    ...
    char name[RPMI_NAME_CHARS_MAX];
};
```

The initialization code later does:

```c
count = fdt_stringlist_count(fdt, nodeoff, "reg-names");
if (count < 0 || count > (RPMI_QUEUE_IDX_MAX_COUNT + RPMI_REG_IDX_MAX_COUNT))
    return SBI_EINVAL;

...
name = fdt_stringlist_get(fdt, nodeoff, "reg-names", qid, &len);
if (!name || (name && len < 0))
    return len;

sbi_memcpy(qctx->name, name, len);
```

The important point is that the existing check only validates the number of strings, not the length of each string. `fdt_stringlist_get(..., &len)` returns the actual string length, and current head copies that length directly into `qctx->name[16]` with no `len <= RPMI_NAME_CHARS_MAX` check.

So the current-head claim is narrow and concrete:

- queue names are stored in a fixed 16-byte field,
- the FDT parser obtains an arbitrary string length for each entry,
- and the copy uses that length directly.

A straightforward fix would be to reject any queue name with `len >= RPMI_NAME_CHARS_MAX`, or clamp and explicitly terminate if truncation is acceptable.

Best regards
Pengpeng Hou
主要言語
C
スター
1.6k
フォーク
734
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

riscv-software-src/opensbi のほかの issue

riscv-software-src/opensbi の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。