From owner-svn-src-all@freebsd.org Fri Dec 4 18:57:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 99B854A895E; Fri, 4 Dec 2020 18:57:59 +0000 (UTC) (envelope-from kib@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CnhmR429Yz3Mvw; Fri, 4 Dec 2020 18:57:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 72A3B107DB; Fri, 4 Dec 2020 18:57:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B4Ivx0m080205; Fri, 4 Dec 2020 18:57:59 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B4IvweG080202; Fri, 4 Dec 2020 18:57:58 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202012041857.0B4IvweG080202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 4 Dec 2020 18:57:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368343 - head/sys/compat/freebsd32 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/compat/freebsd32 X-SVN-Commit-Revision: 368343 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2020 18:57:59 -0000 Author: kib Date: Fri Dec 4 18:57:58 2020 New Revision: 368343 URL: https://svnweb.freebsd.org/changeset/base/368343 Log: Fix compat32 for ntp_adjtime(2). struct timex is not 32-bit safe, it uses longs for members. Provide translation. Reviewed by: brooks, cy Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27471 Modified: head/sys/compat/freebsd32/freebsd32.h head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master Modified: head/sys/compat/freebsd32/freebsd32.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32.h Fri Dec 4 18:56:44 2020 (r368342) +++ head/sys/compat/freebsd32/freebsd32.h Fri Dec 4 18:57:58 2020 (r368343) @@ -409,4 +409,24 @@ struct procctl_reaper_pids32 { uint32_t rp_pids; }; +struct timex32 { + unsigned int modes; + int32_t offset; + int32_t freq; + int32_t maxerror; + int32_t esterror; + int status; + int32_t constant; + int32_t precision; + int32_t tolerance; + int32_t ppsfreq; + int32_t jitter; + int shift; + int32_t stabil; + int32_t jitcnt; + int32_t calcnt; + int32_t errcnt; + int32_t stbcnt; +}; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Dec 4 18:56:44 2020 (r368342) +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Dec 4 18:57:58 2020 (r368343) @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3763,6 +3764,71 @@ freebsd32_sched_rr_get_interval(struct thread *td, CP(ts, ts32, tv_sec); CP(ts, ts32, tv_nsec); error = copyout(&ts32, uap->interval, sizeof(ts32)); + } + return (error); +} + +static void +timex_to_32(struct timex32 *dst, struct timex *src) +{ + CP(*src, *dst, modes); + CP(*src, *dst, offset); + CP(*src, *dst, freq); + CP(*src, *dst, maxerror); + CP(*src, *dst, esterror); + CP(*src, *dst, status); + CP(*src, *dst, constant); + CP(*src, *dst, precision); + CP(*src, *dst, tolerance); + CP(*src, *dst, ppsfreq); + CP(*src, *dst, jitter); + CP(*src, *dst, shift); + CP(*src, *dst, stabil); + CP(*src, *dst, jitcnt); + CP(*src, *dst, calcnt); + CP(*src, *dst, errcnt); + CP(*src, *dst, stbcnt); +} + +static void +timex_from_32(struct timex *dst, struct timex32 *src) +{ + CP(*src, *dst, modes); + CP(*src, *dst, offset); + CP(*src, *dst, freq); + CP(*src, *dst, maxerror); + CP(*src, *dst, esterror); + CP(*src, *dst, status); + CP(*src, *dst, constant); + CP(*src, *dst, precision); + CP(*src, *dst, tolerance); + CP(*src, *dst, ppsfreq); + CP(*src, *dst, jitter); + CP(*src, *dst, shift); + CP(*src, *dst, stabil); + CP(*src, *dst, jitcnt); + CP(*src, *dst, calcnt); + CP(*src, *dst, errcnt); + CP(*src, *dst, stbcnt); +} + +int +freebsd32_ntp_adjtime(struct thread *td, struct freebsd32_ntp_adjtime_args *uap) +{ + struct timex tx; + struct timex32 tx32; + int error, retval; + + error = copyin(uap->tp, &tx32, sizeof(tx32)); + if (error == 0) { + timex_from_32(&tx, &tx32); + error = kern_ntp_adjtime(td, &tx, &retval); + if (error == 0) { + timex_to_32(&tx32, &tx); + error = copyout(&tx32, uap->tp, sizeof(tx32)); + if (error == 0) + td->td_retval[0] = retval; + } } return (error); } Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Fri Dec 4 18:56:44 2020 (r368342) +++ head/sys/compat/freebsd32/syscalls.master Fri Dec 4 18:57:58 2020 (r368343) @@ -343,7 +343,8 @@ const void *buf, size_t nbyte, int pad, \ uint32_t offset1, uint32_t offset2); } 175 AUE_NULL UNIMPL nosys -176 AUE_NTP_ADJTIME NOPROTO { int ntp_adjtime(struct timex *tp); } +176 AUE_NTP_ADJTIME STD { int freebsd32_ntp_adjtime( \ + struct timex32 *tp); } 177 AUE_NULL UNIMPL sfork (BSD/OS 2.x) 178 AUE_NULL UNIMPL getdescriptor (BSD/OS 2.x) 179 AUE_NULL UNIMPL setdescriptor (BSD/OS 2.x)