From nobody Sun May 08 13:17:09 2022 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 C78981AD77A1; Sun, 8 May 2022 13:17:09 +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 4Kx4b94w23z4qLD; Sun, 8 May 2022 13:17:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652015829; 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=L0QdnZFLQCPb9OzGnePu/DEp25JREgLYU/rWj6uRPUc=; b=iNZqMiNA2Hn1g8mYBV6Rrs915DKkhEh1ErGdPdLu8vYf3xDHfJO3Q+EGtViij1H0VE+C6N eKbvkabPDDcFfbBJt5oD61mH0clpkw+D3EL6lKuD3QnXaWZoPH7fkN9OK0OB/EVJnoWhTc OaWkZ1NWISQ7tG6F8ZCdwqOCzy125VCvaEdS8Xelg0x9t0gCkuPHBSioWkpTLq258cd5Yi flz81dfZ96VrAVQlP+B6k0cVrExcI5K8T6RLPw+v6JyfmC3WpVz4gbF/U6RwLrIevSy/4V rPuoA7fP3hjuEopvBDhVpCCgSUrry8J/BeSgSphzrCfyaeyaf7ip5U8qJIRrRw== 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 78505250DF; Sun, 8 May 2022 13:17:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 248DH9EF044037; Sun, 8 May 2022 13:17:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 248DH9Zt044036; Sun, 8 May 2022 13:17:09 GMT (envelope-from git) Date: Sun, 8 May 2022 13:17:09 GMT Message-Id: <202205081317.248DH9Zt044036@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 1579b320f1a4 - main - linux(4): Zero out high order bits of nanoseconds in the compat mode. 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: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1579b320f1a4d555250b82fa74a391d963e7ae13 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652015829; 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=L0QdnZFLQCPb9OzGnePu/DEp25JREgLYU/rWj6uRPUc=; b=iCUBDdHEMHXdZsxsMXzPXLh7iNH4hi1FyiLoDTVya/GAsqrIPKtESXo6Yk2nz65i6VphAl RJtZCt10bRwici+k5mGoBsUZjwYtwvtWx+YWulPmOR8rZkFVKixutMyoouI1+OSJ6eVD0i nzMGudZjNR0GKqU6KtxfMiWDilwDCvgKxx6DQxoawTdyeNc91AG5Ofb7ahH4JUOjv9GPSz /Q18KvP97HIJSQ4FO0P+9nhKVKgzIdaov4CKSGsT63GXBAN5n16vR3x+bjVZyCtJDj+ZVK 3T2rzT1mh+dNqvZVTp0jfj/BgVDQ0Upar/9CeR5icP/TFZvRfX17vkDO0+vLjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652015829; a=rsa-sha256; cv=none; b=r0QRfunI23pmLVwnvsy+EtEuXnvZpk0nm8X5bRXMaTgzrDwPGigTsY38J8n0wiYIwe3pTA eIasTeGvmt9GBN0IjYUXxq3cv+c0RurMkDFygCf82X2aI5dOGhEFi+JiQqiE8bGBOQcjpq wGFQuHWuvzsM0ItECsq2dxob83lB3IhEEAce//N1vQyrSG2+WcHXJ61rfC4zYqyejDBSk/ Uphewy35uaxCCqmC4ZDo/lK3K9rC1EH5gNwG1aZruMDqENLs7jPiz+9smdIZxLDpRBNUYk PhuEcD9FUOCCkg2S7mbjdRmqrL+APjAddTVuyZOGnAwhCwKEC1KjwtnLpyRfaQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=1579b320f1a4d555250b82fa74a391d963e7ae13 commit 1579b320f1a4d555250b82fa74a391d963e7ae13 Author: Dmitry Chagin AuthorDate: 2022-05-08 12:38:19 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-08 12:38:19 +0000 linux(4): Zero out high order bits of nanoseconds in the compat mode. Assuming the kernel would use random data, the 64-bit Linux kernel ignores upper 32 bits of tv_nsec of struct timespec64 for 32-bit binaries. MFC after: 2 weeks --- sys/compat/linux/linux_misc.c | 3 +++ sys/compat/linux/linux_time.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 10f4f52ba500..81002540633e 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -910,6 +910,9 @@ static int linux_utimensat_lts64_to_ts(struct l_timespec64 *l_times, struct timespec *times) { + /* Zero out the padding in compat mode. */ + l_times->tv_nsec &= 0xFFFFFFFFUL; + if (l_times->tv_nsec != LINUX_UTIME_OMIT && l_times->tv_nsec != LINUX_UTIME_NOW && (l_times->tv_nsec < 0 || l_times->tv_nsec > 999999999)) diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index e97a1145d31b..d4f502eee7c6 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -177,10 +177,12 @@ int linux_to_native_timespec64(struct timespec *ntp, struct l_timespec64 *ltp64) { - if (!timespecvalid_interval(ltp64)) - return (EINVAL); + /* Zero out the padding in compat mode. */ + ntp->tv_nsec = ltp64->tv_nsec & 0xFFFFFFFFUL; ntp->tv_sec = ltp64->tv_sec; - ntp->tv_nsec = ltp64->tv_nsec; + + if (!timespecvalid_interval(ntp)) + return (EINVAL); return (0); }