github / github/codeql

CodeQL C check for potential memset() removal by compiler dead store elimination is desired

オープン
#12,352 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
C++ question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

`memset()` is often used for data sanitization in security sensitive software to harden against information leaks. However, compiler dead store elimination passes can remove that hardening. Recently, I had been late in reviewing a PR against OpenZFS that was intended to harden against information leaks, but used memset() in a way vulnerable to dead store elimination. I caught it upon review, verified that GCC truly was eliminating 4 memset() calls that had been dead stores to stack memory and submitted the following now merged patch to fix it:

https://github.com/openzfs/zfs/commit/d634d20d1be31dfa8cf06ef2dc96285baf81a2fb

Every PR to OpenZFS is scanned by CodeQL. While we are not using the security-and-extended checks, I have skimmed through their reports in my fork and did not see any warnings about this. I run several static analyzers on the codebase and none of them reported this, although the documentation for the commercial static analyzer, PVS Studio, suggests that it is able to report such issues:

https://pvs-studio.com/en/docs/warnings/v570/

It would be nice if CodeQL at least had an optional check to catch this. Please l me know if it already has one that I missed.

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

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

評価

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

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

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