From nobody Sat Sep 12 18:19:09 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hj06k0T3Dz6sX28 for ; Sat, 12 Sep 2026 18:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hj06j5MC2z4qcq for ; Sat, 12 Sep 2026 18:19:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789237149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F76VvgsvNdnG4CId2fM0RFjHiPgS2BcfuQA/Akivqnw=; b=Bj6Es9h9BnOQZgnaQhEc4riZ9h2Url3a7EmXtyHmrprg5kR1zfpipmoBBKNxxbUr+Hp8n8 MRkOcy8rKlieZ0jO2rJmGNze1WFWiIWLIAJ4nnbmipuc86vLJbqDxgxW6t2BXH8KnXvFh5 WVPB99phCrYFlgDBV89OJ/LcqU29RoqrzyFFPMi4F/D2V2IMZLGUyzDkKautX7HTSbrYlu 7koDJ1mjIXK8qyVOe0QlL0RRwklGYpPwCuFG5mCvkoU7cezvpDzsyDpemZtKA4pmiF2BAr RpgGkSpAE0weOO5U/Oxcz23BBbTKkhPfqsrBObqZ6moVJBFeZHzyFMnHs5DXRg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789237149; b=KC5rgNOwTNZqtLzNJjb4+6JU9V112VtKW1HVMxyWfZBxs6hovpPuzdQxOGEOWH311mA+ll mMa09HaH2DwSSIk59UQv0jjWpiGhYyRKXtxIBuiOW3Bj/5h0Kr21XsOFU/+xSKo67q2/vi 9AZpSt4WBAyXLS20YgwAxrWYr1T7xhbXjIuzqK0eGIs/eLrVPxyesQtleSQ2NXHcGy1Njt rTwXv1Pg8ZxRFidXU6/VfImiz1f040e7vGgSNczLFsrhdM6H3z0FIiJhsETG1P+RQwd7JN bVk2X2h0nIBoWqPCubTScateMpP1jQ6zxMq+6m59bMLDJo3h0nd9nkvcpp4aFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789237149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F76VvgsvNdnG4CId2fM0RFjHiPgS2BcfuQA/Akivqnw=; b=I8njRckzl1fFsi5vJhAaw3EMY97V1B/mMT2DkYrXDXo4+p3w75Rien18AKCdt/ja/8hB66 UPUP6NaikoE0SeBzIHWW+aV7D2waJ6BQKJbClfUuTTQLT91MQcuQ2kAesr+oB1PCHoEfPs QSZByzzGGi5SHlmTcQ2RorzpMjI+svIEIjm+DVAOiHDye571Rkb+6lx5cvHS2vUvrHYEMO CBpDywReWB0VRpf2PTfO5NdNazI4cEW2GImX4u6/g2GMkDmqSJmTUhMiMxXfz2XQ1xWLka QqQSEFh2ZfswSZLVpWXOYUk+1k9gzo54PtzBKvkUMW4Kr4BAPTt7nuxeFhv6Eg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hj06j3c7Rz17LJ for ; Sat, 12 Sep 2026 18:19:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 457ad by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 12 Sep 2026 18:19:09 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: baa78c87eb07 - main - nvmecontrol: Minor correctness issues List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: baa78c87eb074fa8d9ee5625a6440d35f617e67f Auto-Submitted: auto-generated Date: Sat, 12 Sep 2026 18:19:09 +0000 Message-Id: <6aa5979d.457ad.304e7ec9@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=baa78c87eb074fa8d9ee5625a6440d35f617e67f commit baa78c87eb074fa8d9ee5625a6440d35f617e67f Author: Warner Losh AuthorDate: 2026-09-11 14:54:17 +0000 Commit: Warner Losh CommitDate: 2026-09-12 16:59:16 +0000 nvmecontrol: Minor correctness issues Turn an assert into a bounds check to not overflow if the nvme drive reports too many power states (we validate the user input, but not the drive's identify data). Use a uint32_t instead of int for entry so right shift we do is defined. No functional changes. Fixes: 35793364d722 Noticed by: claude + Sonet 5 Sponsored by: Netflix --- sbin/nvmecontrol/power.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sbin/nvmecontrol/power.c b/sbin/nvmecontrol/power.c index 1ba28deb6c16..05187cd8dc51 100644 --- a/sbin/nvmecontrol/power.c +++ b/sbin/nvmecontrol/power.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -158,7 +157,8 @@ power_apst_data_generate(struct nvme_controller_data *cdata, { int i, itpt, latency; - assert(cdata->npss < num); + if (cdata->npss >= num) + errx(EX_UNAVAILABLE, "controller reports too many power states"); for (i = cdata->npss; i > 0; --i) { if (!NVMEV(NVME_PWR_ST_NOPS, @@ -207,7 +207,8 @@ power_apst_data_parse(struct nvme_controller_data *cdata, static void power_apst_show(uint64_t *data, int num, bool enabled) { - int entry, i; + uint32_t entry; + int i; while (num > 0 && data[num - 1] == 0) --num;