From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CEF5470426; Tue, 21 Jul 2026 19:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663865; cv=none; b=Sd3BB+TyiITWQx6XANO0X/v5xOGixxIcXslY9piGv/c30Ht86JxFa2gxNOuTuule+ykgVOB1NBcryftwXUaRM2ZW5/m91ulQ1cNqiQ9SK/79xeS53ZO23rRozt9H7M2H7dPc++msxSD9wGA2iA1FfUEm2PYlgRkDA2vZzbYNGXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663865; c=relaxed/simple; bh=EvmekEavsiX20kxaR3A+YrbOt6Sw6+j6TkBBnIFnYTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uDkgkYEog6y8wCjWn4Jk42n63EPfPjrnLSFh6NxIeg1BkTOeCzR6VcSWimqPAqGITy/g/MBqS+vyMXnQfGIrK1OeUX4VY2sE7ynAiQheZM5J1lQBLovDPwm5rmIiLPzBun2TcxcAdPVp3O+sFfOzJzFGfsD5/DTr4rSafujw+kg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aBiRtM8/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aBiRtM8/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7444C1F000E9; Tue, 21 Jul 2026 19:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663864; bh=3QeGoJYyvdVFJC+fq05flS253llZznXEJ8V4aAw7jsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aBiRtM8/rdY5FmkZ4Hpc8KBPKH/MT3jFitn0g4r0wgs/obKmRteFV+h9gfA3bwzmG /bdwIfHqlVenfjw/k8FazX3NYndK6E53g+75/xkV+k1DGzrjyX2rwgU6rj2GKTJbt5 PKt6E2Qc+AFQ4z5u97cKhiOFFZb8EVI1DsTw7TYw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wang Yan , Thomas Gleixner , Arnd Bergmann Subject: [PATCH 6.12 0985/1276] time: Fix off-by-one in compat settimeofday() usec validation Date: Tue, 21 Jul 2026 17:23:48 +0200 Message-ID: <20260721152508.058981436@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wang Yan commit 269f2b43fae692d1f3988c9f888a6301aa537b82 upstream. The compat version of settimeofday() uses '>' instead of '>=' when validating tv_usec against USEC_PER_SEC, allowing the value 1000000 to pass the check. After the subsequent conversion to nanoseconds (tv_nsec *= NSEC_PER_USEC), this results in tv_nsec == NSEC_PER_SEC, which violates the timespec invariant that tv_nsec must be strictly less than NSEC_PER_SEC. The native settimeofday() was already fixed in commit ce4abda5e126 ("time: Fix off-by-one in settimeofday() usec validation"), but the compat counterpart was missed. Fix it by using '>=' to reject tv_usec values outside the valid range [0, USEC_PER_SEC - 1]. Fixes: 5e0fb1b57bea ("y2038: time: avoid timespec usage in settimeofday()") Signed-off-by: Wang Yan Signed-off-by: Thomas Gleixner Acked-by: Arnd Bergmann Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260622103348.120255-1-wangyan01@kylinos.cn Signed-off-by: Greg Kroah-Hartman --- kernel/time/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -251,7 +251,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, str get_user(new_ts.tv_nsec, &tv->tv_usec)) return -EFAULT; - if (new_ts.tv_nsec > USEC_PER_SEC || new_ts.tv_nsec < 0) + if (new_ts.tv_nsec >= USEC_PER_SEC || new_ts.tv_nsec < 0) return -EINVAL; new_ts.tv_nsec *= NSEC_PER_USEC;