From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA995334C05 for ; Sat, 23 May 2026 05:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779512822; cv=none; b=ToXZNcBShkOlnkNTCOBdN7Q3oq68LY4sxXCFtL/v2JVVvG2lMEgFzDdDwFCQ9HaP8/h83VDJq4b7IiS1lvqHunI8TmNOWhh5PhiTAmBAE2nVL6H2rIhwNl/6KC+OP7qJLP3m/+7EcFX1VJCP0Y72h/jtygEMBAd5RP0XGil6QIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779512822; c=relaxed/simple; bh=Vv+rBXMg+Icog16Aty71Q7I2UIjL+PEAOQ3S0oWuL+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fc0KroKj6FZm12RkqxMWRDY7f4K9ZlqHVPMBEYQTD/AyuDs+/ZDyJvE9zJ002lD2XFaBZSncIvZrtG3p7OeQmuNz6ZM1si94AqjbdO8e+R7xEqIxwDyJvP3xiWCWK20rFzOrSTxa9ZgYq7mEWus+u14i2q21ns2OSUIlQ0lrxeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GgrIcqG+; arc=none smtp.client-ip=74.125.82.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GgrIcqG+" Received: by mail-dy1-f169.google.com with SMTP id 5a478bee46e88-3045c195251so866398eec.1 for ; Fri, 22 May 2026 22:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779512820; x=1780117620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JJzf0QxClXhAIoPHFsXd6Vs6F+rAvHbI6FlA7maao6c=; b=GgrIcqG+jISmcVAp0K8lkOyscn8ul+BfMgcVG0jAeAwie2jDUPn6nTRi2/LQMsPSxn sDJZvwQ8q0lYng6Qam+wEVXdAlNy4rUXrDSotGosmwiZaBQ3JQQ4Kpj8ENbh+kx9ePUo vtjEZYtj3XSE5yA1KhpK9yp03VZ1ZJW4qn4BCEPlkFV9/kZMqym7HspMkdZcqM1V6R1K vLeiUZ/3HkdclYlJYwxzHbOYsONh5ic/pmsk5iUsdG6jsmG9XUHcG+EM/K1QROMTn2+n TsnevjkwhZ/M71tAzI0z8mrDuMs9IFMd/FycnRw8NggLuU74kNvK15uZh3HadU4e4NHM CKuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779512820; x=1780117620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JJzf0QxClXhAIoPHFsXd6Vs6F+rAvHbI6FlA7maao6c=; b=q+WY1s1xwCY0xyu8rQfIrXxa0zxUGM0lYK8gxhcxxoEZc5nzKnnYO1L3Ev660h45Gv SKVNjjnSjoKIFd3ffHDYbnLEj22VPOVGmdUHdldcf84nJz0j22AcpYYBnzdvcDSV6N7J 6MtP9g35xYKIMrq+4gCOEXjFNsu6g/TxNKYOsCNxWlXW54WjLtGUjeStwKn6+c+kibWF 1Xb4RYxftulsBkmO+cIP2ltbN8HzSLZWY3QUozKst/gJGxwYPNkpAl+Yrz4ajkXKCorU QKLijmlBoxDvZDATaIRRj9yG0XNsNnTnZ5HNxTmeqYrZOXroKFJG/se48mARPt2aIRGE sdDA== X-Forwarded-Encrypted: i=1; AFNElJ9BxNFg1PagQkZSqrSfGRGUHpsy/QoG6pXRlQe9Hf5kSuxYhXf7+UL2CbOFYXDFDnEtvIZhSDnKgvQEPd8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6oNtxY2aq9q9+UQejam7e26Odom51J0DSRvEMxQJVlOE+g13S +AeDRZiebXT4nVTwRHUsBz0bMdFTPVbwXE1cwnrHVlwUs4F1RQKJgJ1R X-Gm-Gg: Acq92OFFnvP14o0z5AcPKEOX5kXKltdl74ZZkx968U0Tdwu0jPtLdDN8ownt7Er4Z7w oGGVpjz8Th8Tu3vy5U576llWVlYoixojxEzDAZVHoP7FZELsbZjCC24bu0il/BsHCfLWjo2eppo xikFOtEgffJHqxJLI7oS+4+gEoMXX5DceZnpMATiyy0YMYM+4l87Zu24LJfj2KoVFlpy1LwDJw7 3oSIQcB6CDG+3DNiTOa6RV+CTpEmGZzfkIkS6bYeODOou0D+btDmnkLs8Q4Tu29UngqccXWvcPC D52u+I+9nEW556w7JWJIkWOcsz8+loi+HkoR5Edfw9ycPn2E4QA10Zw8+L8+nVL76pNzhR/tQ2I zw8urxRS7V2w9BFtq1wOcbaFXp7FRDM1Wz7nunGR3Vafs6b3PWq3kH52hc6qqGcu11QPIWIB0lk ucdrbDE/AiUEhjdAUdaczdX32E34CrwudzlqlpKcCtCfKa1O5PvNO+kwA4l9JMIMLeBtcX1a2E8 YCizAcaq6aDsA== X-Received: by 2002:a05:7300:b104:b0:2dd:6937:79d5 with SMTP id 5a478bee46e88-30448ffc85fmr3364295eec.8.1779512819705; Fri, 22 May 2026 22:06:59 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7e45:2bd:3c86:d34a]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30451f3feadsm3502583eec.13.2026.05.22.22.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 22:06:58 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Thomas Fourier , Seungjin Bae , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 11/11] Input: ims-pcu - fix potential infinite loop in CDC union descriptor parsing Date: Fri, 22 May 2026 22:06:29 -0700 Message-ID: <20260523050634.501509-11-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog In-Reply-To: <20260523050634.501509-1-dmitry.torokhov@gmail.com> References: <20260523050634.501509-1-dmitry.torokhov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The driver parses CDC union descriptors in ims_pcu_get_cdc_union_desc() by iterating through the extra descriptor data. However, it does not verify that the bLength of each descriptor is at least 2. A malicious device could provide a descriptor with bLength = 0, leading to an infinite loop in the driver. Add a check to ensure bLength is at least 2 before proceeding with parsing. Fixes: 628329d52474 (Input: add IMS Passenger Control Unit driver) Cc: stable@vger.kernel.org Assisted-by: Gemini:gemini-3.1-pro Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ims-pcu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 422b1be62303..a04dd3ea3a48 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -1678,8 +1678,9 @@ ims_pcu_get_cdc_union_desc(struct usb_interface *intf) while (buflen >= sizeof(*union_desc)) { union_desc = (struct usb_cdc_union_desc *)buf; - if (union_desc->bLength > buflen) { - dev_err(&intf->dev, "Too large descriptor\n"); + if (union_desc->bLength < 2 || union_desc->bLength > buflen) { + dev_err(&intf->dev, "Invalid descriptor length: %d\n", + union_desc->bLength); return NULL; } -- 2.54.0.746.g67dd491aae-goog