cpufeatures: aarch64 Linux reports aes, sha3 and sm4 when only one of their two HWCAPs is set
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
On aarch64 Linux, cpufeatures reports aes, sha3 and sm4 as present when only one of the two HWCAPs behind each is set.
The check! macro tests a mask with != 0 (cpufeatures/src/aarch64.rs:59):
(($hwcaps & $crate::aarch64::hwcaps::$hwcap) != 0)
Three of the masks hold two HWCAPs (src/aarch64.rs:87-91):
pub const AES: c_ulong = libc::HWCAP_AES | libc::HWCAP_PMULL;
pub const SHA3: c_ulong = libc::HWCAP_SHA3 | libc::HWCAP_SHA512;
pub const SM4: c_ulong = libc::HWCAP_SM3 | libc::HWCAP_SM4;
So either bit is enough. #456 grouped the HWCAPs to ensure "all of the relevant HWCAPs for a given target feature are available". In #395 the conclusion for sha3 was to "check for both". On Apple it looks like both are checked for sha3 (src/aarch64.rs:121-126).
The architecture allows each pair to be half present. The kernel's elf_hwcaps document sets:
HWCAP_AESfromID_AA64ISAR0_EL1.AES == 0b0001andHWCAP_PMULLfrom== 0b0010;HWCAP_SHA512from the SHA2 field, andHWCAP_SHA3from the separate SHA3 field;HWCAP_SM3andHWCAP_SM4from two separate fields.
On a CPU or VM that reports AES without PMULL, polyval runs vmull_p64 behind its aes check (polyval 0.6.2, src/backend/autodetect.rs:19). On one that reports only one of SHA3 and SHA512, sha2 0.11 runs its SHA-512 instructions behind its sha3 check. Either case ends in SIGILL. We do not know of shipped hardware like this so it might not actually be a problem in practice. We found it while reviewing sha2 0.11.
The same code is in 0.2.17, 0.3.0 and 0.3.1.
A possible fix is to require every bit of the mask:
{
let mask = $crate::aarch64::hwcaps::$hwcap;
($hwcaps & mask) == mask
}
- 主要言語
- Rust
- スター
- 695
- フォーク
- 185
- 平均マージ
- 10時間 40分
- マージ済み PR(30日)
- 24
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustCrypto/utils のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RustCrypto/utils#1555 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
RustCrypto/utils#1546 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
RustCrypto/utils#1621 · コメント 17 件 ·
メンテナーはふだん 1 日以内に返信
-
cpubits: promoting wasm32 to 64-bit makes k256 0.14 up to 3.3x slower in Wasm (p256 0.14 is faster)オープン
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
RustCrypto/utils#1620 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1時間未満 初心者へのやさしさ 15/100
RustCrypto/utils#1617 ·
メンテナーはふだん 1 日以内に返信
RustCrypto/utils の issue をすべて見る
似ている issue
-
The new tests repeat each other and one only checks a two-line helper再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンinfra
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
storytold/wordcraft#9405 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
in-progress
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
area: ai-assistants documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
BetaBots-LLC/latticegate#17 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
storytold/craft-libs#5594 ·
メンテナーはふだん 1 日以内に返信
-
available documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Nixitov/Riptide-Native#932 ·
メンテナーはふだん 1 日以内に返信