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 766BD38AC72; Sat, 12 Sep 2026 19:50:19 +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=1789242621; cv=none; b=N52urdMaLgMqJ6CPtaaVxzEGFTfD2RpeIqEhnLnvDJlDFnxp1+EvcC760ozzq+jPWUFWzQ6pKkwweElwI436USW3p4gNXSX1pL7SPlBsDpMXrYhSwxytnUQtR6nAQLFRE1Kmel+XxgnZuG44z9b7/HoxbGyWMVffeDb+YYfG4TE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242621; c=relaxed/simple; bh=/XEagzvXFKOmE4pG9aSohZf2P9Goz6ZMoBv22gzxjO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQbdXWzkpBwr8neQ89NAHlG60+pfwiQru0iA3fydgB9aEj7rXHShxcnw+4UIFCxIo7F7uhtGDoXo1nrrrLpphhCulX0oMt6RpQfmJiNLITG5d2zf3PQUkEItdhH0c/fvPMUw5RMvwjSTMZ0yIuMtlU3kCmQh+y+YIb1L40dGzjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TDlh+wiK; 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="TDlh+wiK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 536FB1F00893; Sat, 12 Sep 2026 19:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789242617; bh=MT+vMvbyN4WMNLYtkcNOzmdIyDKwePIEcJvNl3443hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TDlh+wiKkI649UB3O2shi8B2w+P+q0ARRAnw4KT4j4vxwxWD5csD8oxJVYBugUuLM QqEm6iG0OW3TsTvRV1luXDouxJhp/BVFR3JMEFSgRO+Ggw3JWsL/TtSDAW1EkaNNZz wOkmwmlERUJ0c1H1rEkARO+TfpYJuIfaeX418Ufo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Linmao Li , Arnd Bergmann , Sasha Levin Subject: [PATCH 5.10 465/798] ppdev: prevent overflow when setting port timeout Date: Sat, 12 Sep 2026 09:01:33 +0200 Message-ID: <20260912065527.802054703@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linmao Li [ Upstream commit 3c0cf801ea2fa40daa5e7d1e6d32adca5ff75ad9 ] PPSETTIME64 supplies the timeval fields as s64 values, but pp_set_timeout() narrows tv_usec to int and calculates tv_sec * HZ in a signed long. Large positive values can therefore be truncated or overflow and install an unintended timeout. Keep both fields as s64, reject a non-canonical microsecond value, and use timespec64_to_jiffies() to cap excessively large timeouts at MAX_JIFFY_OFFSET. This is a behavior change because both PPSETTIME ioctls could previously accept values with tv_usec >= USEC_PER_SEC. The validation follows the precedent set by sock_set_timeout(). Fixes: 3b9ab374a1e6 ("ppdev: convert to y2038 safe") Signed-off-by: Linmao Li Reviewed-by: Arnd Bergmann Link: https://patch.msgid.link/20260716013923.19494-1-lilinmao@kylinos.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/char/ppdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index a97edbf7455a6..8ab4617592eab 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -340,15 +340,17 @@ static enum ieee1284_phase init_phase(int mode) return IEEE1284_PH_FWD_IDLE; } -static int pp_set_timeout(struct pardevice *pdev, long tv_sec, int tv_usec) +static int pp_set_timeout(struct pardevice *pdev, s64 tv_sec, s64 tv_usec) { + struct timespec64 ts; long to_jiffies; - if ((tv_sec < 0) || (tv_usec < 0)) + if (tv_sec < 0 || tv_usec < 0 || tv_usec >= USEC_PER_SEC) return -EINVAL; - to_jiffies = usecs_to_jiffies(tv_usec); - to_jiffies += tv_sec * HZ; + ts.tv_sec = tv_sec; + ts.tv_nsec = tv_usec * NSEC_PER_USEC; + to_jiffies = timespec64_to_jiffies(&ts); if (to_jiffies <= 0) return -EINVAL; -- 2.53.0