0xMiden / 0xMiden/miden-vm

Detect invalid stack access by child procedure

オープン
#1,356 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
772
フォーク
352
平均マージ
1日 12時間
マージ済み PR(30日)
93

説明

Here is an example of a subtle bug:

```
#! Input: [idx]
#! Output: [addr]
proc.compute_address
push.BASE_ADDR movup.2 add
end

#! Input: [idx]
#! Output: []
proc.save_index
dup exec.compute_address memstore
end
```

The issue above is that `movup.2` touches part of the stack it shouldn't, the code works because the expected value happened to be duplicated by the parent, and the final stack state matched the expected state, even though the instruction used was "incorrect". The issue above won't be caught by tests unless `compute_address` is carefully tested.

The example above happened in the kernel:

- [here](https://github.com/0xPolygonMiden/miden-base/blob/6184966b87f26c0a30b79b277e760d291ae6f493/miden-lib/asm/miden/kernels/tx/prologue.masm#L843) the parent procedure duplicates the top of the stack
- [here](https://github.com/0xPolygonMiden/miden-base/blob/6184966b87f26c0a30b79b277e760d291ae6f493/miden-lib/asm/miden/kernels/tx/prologue.masm#L615-L617) the child procedure uses the value saved in the stack as part of the parent state

The tests didn't caught the issue, because `process_input_note` is not tested directly, only via the `prepare_transaction`. The code doesn't contain an error, but it is confusing.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

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

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