From nobody Sun Nov 22 17:41:27 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 4jXbwR5662z72K7w for ; Sun, 22 Nov 2026 17:41:27 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXbwR2QGPz3Gl4 for ; Sun, 22 Nov 2026 17:41:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795369287; 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=wgTPh1CTqHRcatcEIoDTw3HU2U94GhjUkcC0xRjEKhA=; b=vFd56pPlcCW1ZWM93/w+YOCQ2BSLJvaGSYdlQFAaWs+S1WgS9o151npVSmUKJA4a2a4eFN NGspZ7OwEHzLFvCDEU9+1nOncm7BlTIvjqQ8cKvrm3s7BS68PmopcOUzoIUlcgQk5YvSTS KeU7dqnC+6HkCQAS9sV5MYe9QOEEEypSOEgSAGeVgIfwpYYvsMnk9EWhisr1D+jxsyCZ9Z XBrtd5JWQtpbbQXQ+4ADeYzAdy/9wJ6qmfwxcS+K8kgOmtnMcKS+FplQGixPvTt/84pjg7 LvQaJm8wEHU/S0ZMMLtnjoPX8HBT69Q9gh5+Nd2W2ztOlVUxnp8TpYcZWN3L5A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795369287; b=gpvwnkIX8R5M/X+b7Ky7sIRglJw4fvopzTgXwqJfI6aHd8pWpY2GYxp04VfozUb5eIMOYM ITIG3J/NDxSMaf4+8MwJrQBPVCLVfE4Hm6ihUxQUPg7WXAuN18s8GWe/n4zJ0zPlQlsaWc 823SEvzrpD2yD9Julbs8+iXnff7rHUzO0bUbv5i+WQ2RqqxesB/epoxAtYPno+231QjvIu MpkjAd87gaRGbGi6OApo2SeyO7pzxdx4FXWQ8h805ddRFmRKWxxeaS7S6xxnD6vtSdXDmE i4aElZrZptVtHv766828vkePafJaOJWBHafYo1SApHbFk2re7lwpEYUmydQxaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795369287; 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=wgTPh1CTqHRcatcEIoDTw3HU2U94GhjUkcC0xRjEKhA=; b=tmifZ9FImePF+KBxubLxUx9sQZQNvDkCsGyZc8j3rl9v1FfEw7K4wXFefiF1AeW7X5r15V +SCo8cEq4mkzBwVj1jaa2QiBDGnJPyo7PxzSuL0mlf9w73NTo9RuNYrZookfh2cZnoyVrc xcYj1YWI7DED0ZycYbJ7s1ofDGBgCEu0SOnQX1eRpwUcIZWVwzPSZXye+XeMxsMXoZlpoC CLrmT+mbCCC295AJXYvEIBNThQsmxo0g+I+iHpo7216diL4qSlkNf6zZ/BK6aHDXBLJSY9 HnjDzAR2Cwz+kVGNiHgr5MrH/ZaWMHRugZjHiIgIcZxpXKlEOe07w3jMbHd7nQ== 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 4jXbwR25Frz1S5J for ; Sun, 22 Nov 2026 17:41:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19ba9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Nov 2026 17:41:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 6186fe5673bb - main - freebsd32: Fix the ffclock estimate conversions List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6186fe5673bb0352c5259fe9b69aff761f6da4e1 Auto-Submitted: auto-generated Date: Sun, 22 Nov 2026 17:41:27 +0000 Message-Id: <6b032947.19ba9.4cc2c77f@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6186fe5673bb0352c5259fe9b69aff761f6da4e1 commit 6186fe5673bb0352c5259fe9b69aff761f6da4e1 Author: Mark Johnston AuthorDate: 2026-11-22 15:30:14 +0000 Commit: Mark Johnston CommitDate: 2026-11-22 17:41:07 +0000 freebsd32: Fix the ffclock estimate conversions The CP() arguments were reversed in both directions, so ffclock_getestimate() copied out uninitialized stack memory and ffclock_setestimate() installed it as the system estimate. Add helper functions to do the conversion, implemented so as to make such mistakes harder to make. Fixes: e3e811a3f824 ("freebsd32: add feed foward clock syscalls") Reviewed by: brooks MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D61774 --- sys/compat/freebsd32/freebsd32_misc.c | 58 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 37a29878dfb3..59aee5e80b14 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -4134,6 +4134,42 @@ extern struct mtx ffclock_mtx; extern struct ffclock_estimate ffclock_estimate; extern int8_t ffclock_updated; +static void +ffclock_estimate_from_32(struct ffclock_estimate *dst, + const struct ffclock_estimate32 *src) +{ + memset(dst, 0, sizeof(*dst)); + CP(src->update_time, dst->update_time, sec); + memcpy(&dst->update_time.frac, &src->update_time.frac, + sizeof(uint64_t)); + FU64_CP(*src, *dst, update_ffcount); + FU64_CP(*src, *dst, leapsec_next); + FU64_CP(*src, *dst, period); + CP(*src, *dst, errb_abs); + CP(*src, *dst, errb_rate); + CP(*src, *dst, status); + CP(*src, *dst, leapsec_total); + CP(*src, *dst, leapsec); +} + +static void +ffclock_estimate_to_32(struct ffclock_estimate32 *dst, + const struct ffclock_estimate *src) +{ + memset(dst, 0, sizeof(*dst)); + CP(src->update_time, dst->update_time, sec); + memcpy(&dst->update_time.frac, &src->update_time.frac, + sizeof(uint64_t)); + FU64_CP(*src, *dst, update_ffcount); + FU64_CP(*src, *dst, leapsec_next); + FU64_CP(*src, *dst, period); + CP(*src, *dst, errb_abs); + CP(*src, *dst, errb_rate); + CP(*src, *dst, status); + CP(*src, *dst, leapsec_total); + CP(*src, *dst, leapsec); +} + int freebsd32_ffclock_setestimate(struct thread *td, struct freebsd32_ffclock_setestimate_args *uap) @@ -4150,16 +4186,7 @@ freebsd32_ffclock_setestimate(struct thread *td, sizeof(struct ffclock_estimate32))) != 0) return (error); - CP(cest.update_time, cest32.update_time, sec); - memcpy(&cest.update_time.frac, &cest32.update_time.frac, sizeof(uint64_t)); - FU64_CP(cest, cest32, update_ffcount); - FU64_CP(cest, cest32, leapsec_next); - FU64_CP(cest, cest32, period); - CP(cest, cest32, errb_abs); - CP(cest, cest32, errb_rate); - CP(cest, cest32, status); - CP(cest, cest32, leapsec_total); - CP(cest, cest32, leapsec); + ffclock_estimate_from_32(&cest, &cest32); mtx_lock(&ffclock_mtx); memcpy(&ffclock_estimate, &cest, sizeof(struct ffclock_estimate)); @@ -4180,16 +4207,7 @@ freebsd32_ffclock_getestimate(struct thread *td, memcpy(&cest, &ffclock_estimate, sizeof(struct ffclock_estimate)); mtx_unlock(&ffclock_mtx); - CP(cest32.update_time, cest.update_time, sec); - memcpy(&cest32.update_time.frac, &cest.update_time.frac, sizeof(uint64_t)); - FU64_CP(cest32, cest, update_ffcount); - FU64_CP(cest32, cest, leapsec_next); - FU64_CP(cest32, cest, period); - CP(cest32, cest, errb_abs); - CP(cest32, cest, errb_rate); - CP(cest32, cest, status); - CP(cest32, cest, leapsec_total); - CP(cest32, cest, leapsec); + ffclock_estimate_to_32(&cest32, &cest); error = copyout(&cest32, uap->cest, sizeof(struct ffclock_estimate32)); return (error);