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 9BD60441035; Tue, 16 Jun 2026 15:51:28 +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=1781625089; cv=none; b=IXH6M+prcsPclIXf494iaUUR53hvFYuPhnZnalIig47tWomGTFMpa+b6NGmtttKXxk13Fbe/83X5unIq2iT+9J9UUd0L8QK3lxvjbnho1QHpJ/4Fl3SUWmNov0QtHou5yYLHYT56VPyu1ugafbFBjJuQt6tkNxGN6FhiMjE/TX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781625089; c=relaxed/simple; bh=kP1KXy0yS54mV5WCAgk4EDdNMzbC+EEB4J0WIsl1hn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RVy+f5uV0dFTyx7wBkJ3JZS0nEBZ35WD1NIoJVJCQpU5A9rbJQ4r7aMgnhllG0On6uvULMcpqiq/T2fOzWx/DC+6TNCYaEKbiF8/gIbZnDy+BpbsiGv5xwLpywpbmqB+Zf97+Rj804L91fVUFVuCRmOUTXuvW64NnqWiWPYrxrQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xa9QEQaM; 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="xa9QEQaM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C49D1F000E9; Tue, 16 Jun 2026 15:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781625088; bh=Rv7YdLkH7qfhH8hWPtiKWxynd69/5FnM8SjcJFRQVI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xa9QEQaM9Ix5IRBW5rIcsOvuMKko+3Y1e9wHPbCYNPyiJzMW8jyo4yfxpl72JdA2H TRhtnlpHBWs6FZx0n/Pj+z7GvywK9ltKiAEm2RjLopGPxef34Dk/KCLJzq7qw61pvb ZQTD0n2Hh4jeSpik1L0EWbETtCwoBpvpJsP/3MWk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Naveen Kumar Chaudhary , Thomas Gleixner , John Stultz , Sasha Levin Subject: [PATCH 6.18 074/325] time: Fix off-by-one in settimeofday() usec validation Date: Tue, 16 Jun 2026 20:27:50 +0530 Message-ID: <20260616145101.425175533@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145057.827196531@linuxfoundation.org> References: <20260616145057.827196531@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Naveen Kumar Chaudhary [ Upstream commit ce4abda5e12622f33450159e76c8f56d28d7f03d ] The validation check uses '>' instead of '>=' when comparing tv_usec against USEC_PER_SEC, allowing the value 1000000 through. After conversion to nanoseconds (*= 1000), this produces tv_nsec == NSEC_PER_SEC, violating the timespec invariant that tv_nsec must be less than NSEC_PER_SEC. Use '>=' to reject tv_usec values that are not in the valid range of 0 to 999999. Fixes: 5e0fb1b57bea ("y2038: time: avoid timespec usage in settimeofday()") Signed-off-by: Naveen Kumar Chaudhary Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://patch.msgid.link/4rikk44zew3s6577dugmx4jyblz7o5c57niuap6ct3td5yfm6w@gh7pcumg7qor Signed-off-by: Sasha Levin --- kernel/time/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/time.c b/kernel/time/time.c index 155cf7def9146d..3c1518a7a52652 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -207,7 +207,7 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval __user *, tv, 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; -- 2.53.0