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 3EE032F617C; Sat, 12 Sep 2026 12:21:38 +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=1789215699; cv=none; b=lrsyeeD6Ri9aNz/IC247Vi5YaklE/Z1ISpT0ptvRtS+YKByesDccBFp/ZVdpVWRC/s8HeEmkAebe2++q0It3nqCcNlH8JhsdGQcOe6OSq6FQXGL6D+MafxLDtxI4CumJSq4ZQwrdm2rqvLmUUOQhicmIeGttazf+SNfAabXT4JE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789215699; c=relaxed/simple; bh=JUzDhrjXbAqXepg/19/vgat7LypJfxsyRxhFpxE1FLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LRPKmkce9Fye95IX16IrEf+0ORdLTxCi/tkeRouUVSmD37g9C7B/pOq1VG/+5bcD0WpAFZF9ozUukLBGnnvHgVsfaFaS4ygXfyIDkdnQH56bdmjalhgZz5OyDhKy4DhBCDSwN8e18x6wk/4WG2hqUo7FgXWoa0rR4E1qmMYG2VQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dMQEqQpo; 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="dMQEqQpo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D53731F000FF; Sat, 12 Sep 2026 12:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789215698; bh=C+T5svufULrthYlfU7VMNPZeWhew2ayVYV68Ryj7rEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dMQEqQpoJwMda4/iLWuR2lh46tpINcfeUKAlh4ibBQRc+9jC4pRfyCaS1hK72foxg 8Y9QwdDNjGM6JX4kJ32kRsdqa5WhT5SJbzY+rqy877637QtmxXe8ROYDJ2PSC4iXOT sstA1nOiucqm5PZH6kKiEDV2315bn6PVKEIhS4ko= 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 6.12 0585/1376] ppdev: prevent overflow when setting port timeout Date: Sat, 12 Sep 2026 08:50:11 +0200 Message-ID: <20260912065620.570634029@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@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: 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 d1dfbd8d4d426..3dec6516a5eb1 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