What should the ABI compatibility rules be for `repr($int)` enums?
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
調査の方向性
Start by reading the ABI compatibility documentation linked in the issue and compare it with the CFI behavior described in the discussion. The issue presents several possible rules for repr($int) enums, but does not choose a final direction. Done means reaching agreement on a rule that accounts for Rust and C interoperability and CFI behavior.
索引モデルが issue の本文から書いたものです。
説明
Currently we do not declare that repr($int) enums are ABI-compatible with $int, at least not in the ABI compatibility docs. We do however say or at least heavily imply that it's fine to use a repr($int) enum on the Rust side together with a C enum on the other side whose underlying type matches $int.
The C standard says that such an enum is compatible with $int. However, CFI implementations violate the C standard and do not allow function signatures to type-pun between enums and their underlying $int. IMO that's quite rude of them, standards exist for a reason. But we can't just ignore that fact, or at least if we do we should be aware of the consequences. If we say that in Rust, repr($int) enums are ABI-compatible with $int, then we must give them the same CFI tag, or else CFI would trigger on entirely well-defined Rust code. That would make such an enum not CFI-compatible with the same enum on the C side. (This is why https://github.com/rust-lang/rust/pull/128600 did not make it.)
(The same question also arises for repr(C) enums where the underlying integer type is left implicit. However, there it would probably be less surprising to say that those are not ABI-compatible with that implicit underlying integer type.)
So, what could we do?
- Convince clang that integer normalization should also normalize enums to their underlying integer type. (Either for all enums, or only for enums with an explicit underlying type.) We already require integer normalization for CFI to work with Rust, and it seems reasonable to include enums in that, at least those with an explicitly declared underlying integer type.
- Declare it EB to do function signature type punning between
repr($int)enums and $int. That would at least avoid nasal demons. Miri currently makes this UB and we haven't gotten reports about this, so making them fully ABI-compatible does not seem to be in high demand. - Make
repr($int)enums are ABI-compatible with $int unless they have a#[cfi_encoding]attribute, in which case a mismatch becomes EB. That would make such enums not CFI-compatible with the corresponding C enum by default: the enums would get an integer CFI tag by default, and FFI code would have to explicitly declare the CFI encoding to be CFI-compatible with the corresponding C code. - Anything else?
My preferred option is 1. CFI should not interfere with well-defined C programs. But I don't know if there is any chance that clang might do that, or if this would have a serious impact on CFI's ability to prevent exploits. Option 2 also seems acceptable, albeit somewhat unfortunate.
Cc @CAD97 @Jules-Bertholet @Darksonn @rcvalle
- 主要言語
- 言語のデータがありません
- スター
- 760
- フォーク
- 68
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/unsafe-code-guidelines のほかの issue
-
I-opsem-nominated
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rust-lang/unsafe-code-guidelines#634 · コメント 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
rust-lang/unsafe-code-guidelines#632 · コメント 8 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
rust-lang/unsafe-code-guidelines#631 · コメント 7 件 ·
-
I-opsem-nominated
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
rust-lang/unsafe-code-guidelines#630 · リアクション 1 件 ·
rust-lang/unsafe-code-guidelines の issue をすべて見る
似ている issue
-
bug core-lang
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Call-argument syntax diagnostic needs example spacing and removal of confusing trailing sentenceオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mw00/project-maya#1368 ·
メンテナーはふだん 2 日以内に返信
-
test(bind-json): legacy Solidity fixture requires an unavailable solc on Linux ARM64対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
foundry-rs/foundry#18828 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信