From nobody Mon Mar 11 21:23:24 2024 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 4TtqWd041Jz5DlHp; Mon, 11 Mar 2024 21:23:25 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TtqWc66F0z41PH; Mon, 11 Mar 2024 21:23:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710192204; 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=MdEELzIMXpUVb7gsmXc1Ce11t8PDhdhwErscbM/ZjZE=; b=UXeM2sExIYdm40C0OLTdVnQN3llT4nWftS0z3URPq42f3mVt1npvNaHNDIczMI1I3Loaat jXTFx6OChMRmnDF20w8bDlY3wQrqOyAbh873CuVzahgGW+cF/pRRZz9NzQt/MlcELmadeN M1CTRWnXG8FaIUyfeISqBqfo7Y9PgWdrw98aK11N9fM/TXV4J6ewO/4FZRqHxCin8ztrbI /CNehnI+Xjs7kxGKNJioVq5Z2YbuZFTDvt5OBFpDMrJFbrWaQgnPXmGe1G44rcQq6gNmtQ qyZV1EpzJG1YaJZ01xBFUsuNerhJbsecY9QojY5aIehAXtTjlGkDDD4FxYYcRw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710192204; a=rsa-sha256; cv=none; b=wcHh9kwU2wm4+7gRvRt0Q5lnAfo95qQR2A+lsDvADiilSUlW4FM6aDUg478nxOV1xwZ8YW 02U7ibNR0HViGFihpyPgKBfe55AiJTl4RTdLY57Z/qcbtKMQPiKVnNMxgPYhutp1YapK1v ilsyIOLmqckkXTbh9osSvFiRBEr8arGW6+popjywUQSeFxAm3ZVdJgSsqkiLmMJhqbmWOs +0KRHLox+jjJeWHglOb7FmwMrJN8P2DsHWON8McDU13AMqTIDomB7thZnAZ93Kr5ZUdc49 SYxTG0SblZ+S+G4wwtbNx3qRIBe6od7dBnMHhwZlFjH16l/DbkZbtk9uuLUccQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710192204; 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=MdEELzIMXpUVb7gsmXc1Ce11t8PDhdhwErscbM/ZjZE=; b=kzFk8iGkFq45rgLN3UH/xy7GMTf6N63UIOxvgedIcRupMZgEgUYuF2Z8TxwjFVlBeuMvOG 9j5Wo11sb3nLumJv8QfVjQnyJf3JegPDLDEd28nS60Fh1BPTQIBud3qCM2QN77BT6nQdna qVpxgWQyBAwrWFhLSgYSbeC7CfewVa6uF6fbNtO6EFGrpuGIXN2iW2+ozbabdUgcei+Gd3 4xIiAsFBVnItX1IZ7gmB6hAIgWYA4fNL9NpjlwsntBMAyE2c1uKqSfR2ZGf6q70kjLqSeg nTCJr29U6toE9sviXA0taJ8VkGhLjO6aXjTMM8uv3eGnIvGhEL/8RW7FyALg9g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TtqWc5jkXzlql; Mon, 11 Mar 2024 21:23:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42BLNOxA025527; Mon, 11 Mar 2024 21:23:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42BLNOFi025524; Mon, 11 Mar 2024 21:23:24 GMT (envelope-from git) Date: Mon, 11 Mar 2024 21:23:24 GMT Message-Id: <202403112123.42BLNOFi025524@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8b1925f29c54 - main - kboot: Avoid UB in signed shift 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 8b1925f29c54f5791db3c8dcdf2b67541bb8ab32 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8b1925f29c54f5791db3c8dcdf2b67541bb8ab32 commit 8b1925f29c54f5791db3c8dcdf2b67541bb8ab32 Author: Warner Losh AuthorDate: 2024-03-11 20:15:10 +0000 Commit: Warner Losh CommitDate: 2024-03-11 21:21:51 +0000 kboot: Avoid UB in signed shift offset is signed. Copy it to the unsigned res before shifting. This avoids any possible undefined behavior for right shifting signed numbers. No functional change intended (and the code generated is the nearly same for aarch64). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44285 --- stand/kboot/kboot/hostfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stand/kboot/kboot/hostfs.c b/stand/kboot/kboot/hostfs.c index 02afa885d833..7c0600fc35a0 100644 --- a/stand/kboot/kboot/hostfs.c +++ b/stand/kboot/kboot/hostfs.c @@ -133,8 +133,9 @@ hostfs_seek(struct open_file *f, off_t offset, int whence) * from V7 later ISO-C). Also assumes we have to support powerpc still, * it's interface is weird for legacy reasons.... */ - offl = offset & 0xffffffff; - offh = (offset >> 32) & 0xffffffff; + res = (uint64_t)offset; + offl = res & 0xfffffffful; + offh = (res >> 32) & 0xfffffffful; err = host_llseek(hf->hf_fd, offh, offl, &res, whence); if (err < 0) return (err);