From nobody Tue Apr 16 20:13:32 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 4VJwGN3rj4z5H0Yb; Tue, 16 Apr 2024 20:13:32 +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 4VJwGN28hVz4vP8; Tue, 16 Apr 2024 20:13:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298412; 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=6pcePTREE2jXNk4RgJ9bx7uFhstgJnN1sj5htmZ67hA=; b=XTTweNB1+SNf0k57AMJXbPZ+GMnowNy+tawtEXWUqsVv0pt7WGl6NyShKpIXLI2nKqIkdW GG7j4IOSR3At8H2FvNKioQl+pIvTYALe2vQI21HuNPihwjArNpjhZzeTkDvgb/0BpGNVL1 lF/T/NqaKlajV/DDjkWlNzlddQo0Qog4vUtePFhz4EYRxSxiTb8yc0GGQDN/5VflVCkCoJ xCzhdHvaGRY5Zta6wPenlQiC9+x6WgLLE7Gp2qxh5Cd1MYLObmcLbDgxqadRnuBgDAiQ7D 69fhRBSim9cd5QAYld+CtPLIK6NPnf75QnVTdJE8htO+30csQRfSUrND6K3/xw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298412; a=rsa-sha256; cv=none; b=PdeTB/gk7DPMQ7MGt2814Wi3SPh48V4aaiDFWafUMRM3aKpBdtAKa/yZ3mDJ5eoUajdACr uPMpiU1QHwPn4PQsIaHHi2kPsc+GVtXDQ3i6g4cSPD0hMPq21YNi59uxfqd3ZjVQHbBqpz ckHSJmA0ufYc3d66RSmi5JY8lp0kzPpmKRvKamXaCKcYMr6SENj1kZL7tMGxWKlBAOzAjs CiRSQXtIbxy5hgI2BSWp95lLWqVHuLncdEhfLnvJzGFiN5UYqXyrGf5iAt0nm3aMBBqneG BZFXZwxH8E7rWNW4upySdQMiAACOCZYv1w7UV3jSHK1aCDp78JMnr/x+VO8ehA== 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=1713298412; 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=6pcePTREE2jXNk4RgJ9bx7uFhstgJnN1sj5htmZ67hA=; b=sv/CdrnP1s+tJ2/eBkfhIl8NdwORvPGkGly+Nl4OV8FEkLBouX4P91ugihKvnKuKL3J0xD Xl8VrgVgd9ehQk/IXr1LqiuyIAW91BLsbBYEPaqze6B8CAin+dznE5QXnZ2kDkZxK3dyZK i4RarftDFJyT2jJCjHTawItxNV9EP9Uxb54C4vMMT5Cg5l1B9ibPlErHdpssdW2UN2m0ZJ vBAPXjZu1OIJF3Q17Cga7lkpiHQt/tNbK47yTC+Y00p0tUXRaUKCC7tQmrVBjXxoFGLZ8Y 5WQvpV8BQDeEL1RgW1MRqHSgD3XqzROpX+1vok4FXXwLaeYkvkQi8IxQNi/62g== 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 4VJwGN1nD5zxWZ; Tue, 16 Apr 2024 20:13:32 +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 43GKDWwJ039800; Tue, 16 Apr 2024 20:13:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKDWlP039797; Tue, 16 Apr 2024 20:13:32 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:13:32 GMT Message-Id: <202404162013.43GKDWlP039797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: d18377cbb723 - stable/14 - 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/14 X-Git-Reftype: branch X-Git-Commit: d18377cbb7233ca9a468728596718884c64d6cb1 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d18377cbb7233ca9a468728596718884c64d6cb1 commit d18377cbb7233ca9a468728596718884c64d6cb1 Author: Warner Losh AuthorDate: 2024-03-11 20:15:10 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:29 +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 (cherry picked from commit 8b1925f29c54f5791db3c8dcdf2b67541bb8ab32) --- 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);