From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D001B3F927B; Fri, 15 May 2026 16:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862332; cv=none; b=g24EjtiO2uHaOdsDTQReVk6Eh3rApPxLDhZVHzWaXw2z+f47hPtYqqiO+HAX6qm23Ox1wGJ92p5gHnB2YiPHunMdbrJlaCbEYxlkdWEWJ5/AeKZfJzhcNRJRMp8GTDsg+2CkbBdU2iSO3TvJqmle0sOeGH4lqalcmfvuY8QEjcU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862332; c=relaxed/simple; bh=nxrPzUegP8hOeCBL7nZOfL/1JZ6CkzgpeG0JE4Dae1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JgA1a/2oLYfdrmyoudJ0GbbU+b1i7zeIwGtDckhn47BxqlZm3BQWxeoDvU9E+faLnGdUFzdYFCtP5E30QBAQ9vZuImY5UfDq+J8tRPaviota8qKymlDqn9ghlOLiGX5ElUdplO+1ZxtjdeK4WbpkSPu/t/zJWxEZocUssgSO/Nc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=b7Gow0ke; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="b7Gow0ke" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62C0DC2BCB0; Fri, 15 May 2026 16:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778862332; bh=nxrPzUegP8hOeCBL7nZOfL/1JZ6CkzgpeG0JE4Dae1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b7Gow0kect2rFs4JN+iELXKIdW1uT1RndB51wAxEgLkr+AmfUZRkeB5Y7QGg7Y1+r SQ2h83BoEc0LHTx+18ur9Rr6vinKAp/pO4/hD0rU3rnIBUIqSByv0IPmHsenDqGIAn wMgqSVnfYi5zQgXtAZL5MkvQIB5TPl7GIlDqTyzY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xingyu Jin , "T.J. Mercier" , Jiri Kosina Subject: [PATCH 7.0 001/201] HID: playstation: Clamp num_touch_reports Date: Fri, 15 May 2026 17:46:59 +0200 Message-ID: <20260515154658.571690123@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154658.538039039@linuxfoundation.org> References: <20260515154658.538039039@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: T.J. Mercier commit cac61b58a3b6340c52afa06bb15eac033158db2f upstream. A device would never lie about the number of touch reports would it? If it does the loop in dualshock4_parse_report will read off the end of the touch_reports array, up to about 2 KiB for the maximum number of 256 loop iteraions. The data that is read is emitted via evdev if the DS4_TOUCH_POINT_INACTIVE bit happens to be set. Protect against this by clamping the num_touch_reports value provided by the device to the maximum size of the touch_reports array. Fixes: 752038248808 ("HID: playstation: add DualShock4 touchpad support.") Cc: stable@vger.kernel.org Reported-by: Xingyu Jin Signed-off-by: T.J. Mercier Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-playstation.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2378,7 +2378,8 @@ static int dualshock4_parse_report(struc (struct dualshock4_input_report_usb *)data; ds4_report = &usb->common; - num_touch_reports = usb->num_touch_reports; + num_touch_reports = min_t(u8, usb->num_touch_reports, + ARRAY_SIZE(usb->touch_reports)); touch_reports = usb->touch_reports; } else if (hdev->bus == BUS_BLUETOOTH && report->id == DS4_INPUT_REPORT_BT && size == DS4_INPUT_REPORT_BT_SIZE) { @@ -2392,7 +2393,8 @@ static int dualshock4_parse_report(struc } ds4_report = &bt->common; - num_touch_reports = bt->num_touch_reports; + num_touch_reports = min_t(u8, bt->num_touch_reports, + ARRAY_SIZE(bt->touch_reports)); touch_reports = bt->touch_reports; } else if (hdev->bus == BUS_BLUETOOTH && report->id == DS4_INPUT_REPORT_BT_MINIMAL &&