Date: Fri, 11 Nov 2022 01:48:22 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 454601155778 - stable/13 - cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns. Message-ID: <202211110148.2AB1mMr6056504@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=454601155778939f81ebcbfb4a876ddb793a2604 commit 454601155778939f81ebcbfb4a876ddb793a2604 Author: Navdeep Parhar <np@FreeBSD.org> AuthorDate: 2022-09-22 15:57:25 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-11-11 01:26:17 +0000 cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns. Coverity flagged this in its latest run but it is not a problem in practice as the card's core clock would have to be > 4.2GHz for any overflow to occur. CID 1498303: Integer handling issues (OVERFLOW_BEFORE_WIDEN) Potentially overflowing expression "sc->params.vpd.cclk * 1000U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned). Reported by: Coverity Scan (CID 1498303) Sponsored by: Chelsio Communications (cherry picked from commit 02fac928ab687607786801cdf33f100c70cc6a2e) --- sys/dev/cxgbe/t4_sge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index dd3d22020651..48d87be4e0b6 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -1552,7 +1552,7 @@ t4_tstmp_to_ns(struct adapter *sc, uint64_t lf) * Note that vpd.cclk is in khz, we need it in raw hz so * convert to hz. */ - cclk = sc->params.vpd.cclk * 1000; + cclk = (uint64_t)sc->params.vpd.cclk * 1000; hw_clocks = hw_tstmp - dcur.hw_prev; tstmp_sec = hw_clocks / cclk; tstmp_nsec = hw_clocks % cclk;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211110148.2AB1mMr6056504>