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 CB8CF3B2D00; Tue, 21 Jul 2026 20:56:00 +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=1784667361; cv=none; b=Zi/nGvZ0vrGDhrMD/tnqbEGuvdNPF/OVltzqJwsGZb5YBJsX3BR1C2Zp4AhItlE/ozK2RIGlX4l8OO2FEdoHuW46f934MUjkqWn29QEOuNOqMBBn3BNIzwOyH8/K0u9OpDUAJ6aa41+FiRoZIliNWQVA7oaT+8bZtsim8bh9lM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667361; c=relaxed/simple; bh=N8XRHWOBsYNRK7ch+r5e5OJ/6frIrNNpi3z3vgJecSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eE2GCqzTBo62neyHG/zbxviMbJJUd0dZ+YfALjtai5NNcJuhkQR/3JZpCf+80rBGu+MvjQOb80mFg8a1gA0NUyYXnT88ttQd1F7cQJ4Zt/GYXO27j2Hqe81sLeJZNQZe7iJZ2UhaiK3tm5Y3WVYDapl3AYVdH9H17t14GbH1X6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Aj2s/m0a; 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="Aj2s/m0a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 160B11F000E9; Tue, 21 Jul 2026 20:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784667360; bh=nl04SMFi2Dds5TC7B4EB+IIV6sRY9j3mI/9SoMxbplw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Aj2s/m0aIXYfRKfA5GclTTmynBG55N/sns/jsaizQTJsXIUsyGehAy5GTTqg2HoZt 3TUbpUUN98QityP1O5YDBiwUY7fAkSoAqktLIzjA9y++nxkmw6q3dQkAdR9WU+zah0 Xb5OHWCIylhNlgx6CeQf9JBvGzlnJT8zEF2NWNGY= 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.6 1032/1266] time: Fix off-by-one in compat settimeofday() usec validation Date: Tue, 21 Jul 2026 17:24:29 +0200 Message-ID: <20260721152504.917095037@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-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;