Two cleanup/parsing nits: nvc_cfg NULL deref on OOM paths, sscanf %x into int
まだ誰も着手していません。
評価
調査の方向性
Read the cleanup paths in src/cli/configure.c and src/cli/list.c, then inspect matches_pci_format in src/cli/common.c. Guard the nvc_cfg cleanup when it is NULL and use unsigned variables for the %x conversions; done means both issues are corrected and the project builds cleanly.
索引モデルが issue の本文から書いたものです。
説明
Two smaller hardening notes from the same audit pass that reported #408 — bundling them in one issue since neither is urgent on its own.
1. nvc_cfg can be NULL on the OOM cleanup paths
src/cli/configure.c:481 and src/cli/list.c:293 both do:
if ((nvc = libnvc.context_new()) == NULL || (nvc_cfg = libnvc.config_new()) == NULL) { warn(...); goto fail; }
...
fail:
free(nvc_cfg->imex.chans); /* nvc_cfg may be NULL here */
If context_new() fails (calloc returns NULL under memory pressure — runc hooks do run under container memory limits), the fail: path dereferences nvc_cfg->imex.chans with nvc_cfg == NULL. The sibling cleanups all guard their NULLs (libnvc.shutdown(nvc) etc. handle it); these two spots don't. Fix is the obvious guard:
- free(nvc_cfg->imex.chans);
+ if (nvc_cfg != NULL) {
+ free(nvc_cfg->imex.chans);
+ }
Haven't reproduced at runtime (would need calloc failure injection), but the deref is clear from the code.
2. sscanf("%x") into int in matches_pci_format
src/cli/common.c:18:
sscanf(gpu, "%x:%02x:%02x.0", &domainid, &busid, &deviceid);
with int domainid, busid, deviceid. The upstream build log itself carries the gcc warning — %x wants unsigned int *, not int *. Input is attacker-controlled (NVIDIA_VISIBLE_DEVICES → --device=), and values ≥ INT_MAX are undefined per the C standard. In practice glibc's scanf just folds the value, and sanitized runs with ffffffff:99:99.0, ffffffffffffffff:99:99.0, etc. all produced clean "unknown device" rejections — no UBSan/ASan report, so this is paper UB rather than a live fault on glibc. Fix is to make the three variables unsigned int.
Both spotted during a full make debug (ASan/UBSan) audit pass of v1.20.2 (c7727e5); the sanitized end-to-end configure run itself was clean, so these are the only cleanup/parsing nits left standing from that pass besides #408.
- 主要言語
- C
- スター
- 1.1k
- フォーク
- 278
- 平均マージ
- 3日 7時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/libnvidia-container のほかの issue
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
NVIDIA/libnvidia-container#408 ·
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/libnvidia-container#406 ·
-
question
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
NVIDIA/libnvidia-container#404 ·
-
OpenSuSE Leap 15.2 is missing対応中かも @gusraggio が 44 日前に担当しました。 オープンquestion
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
NVIDIA/libnvidia-container#100 · コメント 9 件 · リアクション 1 件 ·
NVIDIA/libnvidia-container の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition root対応中かも @tuhaihe が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/cloudberry#2356 ·
メンテナーはふだん 2 日以内に返信
-
windows-artifacts: the win-arm64 job uses a Visual Studio generator missing from windows-11-armオープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
crosspoint-reader/crosspoint-reader#4535 ·
メンテナーはふだん 1 日以内に返信
-
[core] Clients never advertise RNS_UD_CS_SUPPORT_ERRINFO_PDU, so a conforming server can't send them Set Error Info対応中かも @akallabeth が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
FreeRDP/FreeRDP#14230 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信