From nobody Sat Jul 25 16:53:45 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 E78C7334C08 for ; Thu, 16 Jul 2026 01:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784165981; cv=none; b=HrdIQ2boeUnRqwC9OihGfQgfnMyI9JIfZLhR2vLX+6td0LRK5ZPr/KIOcoFwBr3CMcou/geI6gHfXAqwYifGIqJej46Q/SaQpyEkp/0EbY4pHbvlJWjaW7lMZE4V+2vvp0Upaw0WmsWj9xSm+6+j2lfITZLona90dZzv4xmL7gw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784165981; c=relaxed/simple; bh=0coyO3o8cNPCDh3TPU1t/rY0p1NdTpLv02PU+GY1VSI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VlLR0u7PJxLQfWzjv+xe0MHGBxiednIqt2YyCgyWFFj6M3UwUf5CUkoZ+m+FJnDN+QUXCiXtSsvgaYLbSTioATN9INp8KWiR+C/wFOZPlLcZExStJGxl+7wEN95en7v85108JmWWB/XeG2SEUDrb9HarwbHKyELAvsgS2goCEgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 2f02611a80b711f1aa26b74ffac11d73-20260716 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:87f34da8-333f-4249-af9d-28a0680f5a15,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:903267edc4d7c3ec80201e49bb5caf5c,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|865|898,TC:nil,Content:0|15|50,E DM:-3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA :0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 2f02611a80b711f1aa26b74ffac11d73-20260716 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 275715793; Thu, 16 Jul 2026 09:39:28 +0800 From: Linmao Li To: Sudip Mukherjee , Greg Kroah-Hartman Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Linmao Li Subject: [PATCH] ppdev: prevent overflow when setting port timeout Date: Thu, 16 Jul 2026 09:39:23 +0800 Message-Id: <20260716013923.19494-1-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 >=3D 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 --- 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 6da817b9849f..8803268b4cdc 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; } =20 -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; =20 - if ((tv_sec < 0) || (tv_usec < 0)) + if (tv_sec < 0 || tv_usec < 0 || tv_usec >=3D USEC_PER_SEC) return -EINVAL; =20 - to_jiffies =3D usecs_to_jiffies(tv_usec); - to_jiffies +=3D tv_sec * HZ; + ts.tv_sec =3D tv_sec; + ts.tv_nsec =3D tv_usec * NSEC_PER_USEC; + to_jiffies =3D timespec64_to_jiffies(&ts); if (to_jiffies <=3D 0) return -EINVAL; =20 --=20 2.25.1