From nobody Wed Feb 11 19:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5282DC7EE22 for ; Tue, 9 May 2023 03:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234675AbjEID4z (ORCPT ); Mon, 8 May 2023 23:56:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234637AbjEID4F (ORCPT ); Mon, 8 May 2023 23:56:05 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78FE0D2C9; Mon, 8 May 2023 20:55:35 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ab0c697c84so40647485ad.3; Mon, 08 May 2023 20:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683604531; x=1686196531; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=/LScAQLvLy2KJzZIX1XiMv58IwV2dMEiIzwcsMUn1A4=; b=TpEG5YCu4WuU4Td8kK/b8hkh408J24waDjpTj9REXrzkvXVOo5lts6nwF7SE3r2TFA XkbNYgYFxLtp2jcmPQov7SyiXF599dJT6TvL1SNB7bLlrR6pSaUgsDK0jE+cRU2dznWp XjBsCI/i6IBp/KD0EBs4nPL/YzYKopkxqBmr1E+tGGhRvTx+f6EKEfVaL3ftmKsG66kV +wXgHgvBoenQU7mOAmCERvQRJXcfV3gs5Zw7HsCMJASD8tv+sedGBKg/F9RIlSms2cMI 42wjEE6kSjJIazH7MDFdSFoeJTEnM9fl8chwVqjJW3IwwyyEuCxhOqG+r695lxnpy4gM IetA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683604531; x=1686196531; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/LScAQLvLy2KJzZIX1XiMv58IwV2dMEiIzwcsMUn1A4=; b=P1YE745rPC89vhf66BAYjCqmoOYKKU3I1+s5tFaD8Hjo+aXvzbcTGlrZdKWNzrbK/5 wf0eS66TUl+pxHXe8UY9NVnAaHhxOoFFOr4BZ52AloU5XSYfqObF9v/qplIyucSJkSJa KFNHILGaAsofGaJ+SNuimk7nQv5zetqT1Zicly5SjHbXIm4j5CIn0vfbr4ibJCU8j68Q Vhcr003wOjLxGz2qe0dtwcP7wUOL4YvukaEWye37Mlrl9R1gI47k8otTEuYrLzk1SyHW tnBqQp6sWv0sawVXdwCKbPB+qkgdV7bU0PgXy59laC8zf5R72pGW7MJHo1FiL38nFQRA 5mwQ== X-Gm-Message-State: AC+VfDzg+MBjSHlA8crtUfHpk3XqIoUE5v5xgr87QMJSnFsYTjfZKNnL HcPx6fRbZDP6TUspuZ7Rn+4ngMslyDs= X-Google-Smtp-Source: ACHHUZ6gyVdwymP9pMNCfo73/YvExpRL6tps3rAPkxcaQd7AmxbpXJ1MU02ACUKY+OXHIEEvdq7Hxw== X-Received: by 2002:a17:902:e748:b0:1a9:a478:66c5 with SMTP id p8-20020a170902e74800b001a9a47866c5mr16689358plf.63.1683604530927; Mon, 08 May 2023 20:55:30 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:d72f:84b8:c441:6a95]) by smtp.gmail.com with ESMTPSA id p17-20020a170902ead100b001a1faed8707sm306760pld.63.2023.05.08.20.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:55:30 -0700 (PDT) Date: Mon, 8 May 2023 20:55:27 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jondaniel879@gmail.com Subject: [PATCH] Input: psmouse - fix OOB access in Elantech protocol Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The kernel only allocate 5 MT slots; check that transmitted slot ID falls within the acceptable range. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D217417 Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elantech.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index ece97f8c6a3e..2118b2075f43 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -674,10 +674,11 @@ static void process_packet_head_v4(struct psmouse *ps= mouse) struct input_dev *dev =3D psmouse->dev; struct elantech_data *etd =3D psmouse->private; unsigned char *packet =3D psmouse->packet; - int id =3D ((packet[3] & 0xe0) >> 5) - 1; + int id; int pres, traces; =20 - if (id < 0) + id =3D ((packet[3] & 0xe0) >> 5) - 1; + if (id < 0 || id >=3D ETP_MAX_FINGERS) return; =20 etd->mt[id].x =3D ((packet[1] & 0x0f) << 8) | packet[2]; @@ -707,7 +708,7 @@ static void process_packet_motion_v4(struct psmouse *ps= mouse) int id, sid; =20 id =3D ((packet[0] & 0xe0) >> 5) - 1; - if (id < 0) + if (id < 0 || id >=3D ETP_MAX_FINGERS) return; =20 sid =3D ((packet[3] & 0xe0) >> 5) - 1; @@ -728,7 +729,7 @@ static void process_packet_motion_v4(struct psmouse *ps= mouse) input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x); input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y); =20 - if (sid >=3D 0) { + if (sid >=3D 0 && sid < ETP_MAX_FINGERS) { etd->mt[sid].x +=3D delta_x2 * weight; etd->mt[sid].y -=3D delta_y2 * weight; input_mt_slot(dev, sid); --=20 2.40.1.521.gf1e218fcd8-goog --=20 Dmitry