From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796017372; b=0CB5kzCQKDlkroz5f4ozG0taIRoADXualB5VQU+cL/QDh01XRepaO40PVyxYmbc/Ijex VZXVPBvlHaQRtGGf3vYGyq8zWCUI62GUr0TS/mVXqOLbIIVDwomtyfo5cKN9zbYNG/ICr h8ZDerUGeEU7rSSTT/c8QBdhrfTMejMA+lwrMlDBjCeY/DsBOfnQsUY2I1iU20u9TIu95 Zf1tEgFWd6zWrptjlaFCQ9ZWa7APuF9cZMPukjAs5El4Gpxw/qow9ym2iP4NAnxid0T29 fjPW6/dxNxUyZTuVaCAnT4rnnYpYeucHdmqsH568c9rx/NqAyrV7eSNHfJHOMchiTNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796017372; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=RjSuaQtbCjYXvVI9VQub7/KjudjuXpXK4KPMMsOzAWw=; b=JFFQjIeJGze/dLe5pZCsQQS5+jeL6vVxhjh3tVHh+2E0QauBfQrs00jSUqm+szmDr5mT PClOhl4tYCNfGXrYg5SWMDtKmHDbBIbv2w6dWVhpUqHO4ItTVDjnOEtLpoTQPJrzK0ca6 G+SO9w/+uWSaBfjYJ1sxgFez86UU0Q22iPAuDRzu9NVNihysO3msfraWTRnLZSOjAZ+Bj tCQTePkh0WwB/EFru67IPh1JKCWkNoj/XAT+GAP9kzTUo/AS9ofUrp1tkDk5Jzisi7+9B fGFUJ3x4T1PZRBxW1eZWEJbslb+ZD6OGOVxHgFKsJvBxIr8vF2qupLxZ32PWGrTbNGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vMUEruvP; arc=none smtp.remote-ip=209.85.215.174 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C30AE606A332 for ; Mon, 30 Nov 2026 05:42:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C30AE606A332 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.a=rsa-sha256 header.s=20260707 header.b=vMUEruvP Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-cdb1199bfd8so4606540a12.1 for ; Sun, 29 Nov 2026 21:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796017371; x=1796622171; 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:content-type; bh=RjSuaQtbCjYXvVI9VQub7/KjudjuXpXK4KPMMsOzAWw=; b=vMUEruvPL+I5a4QYQZCpEZoVwNGLloEwnEiMhL8D8rdKy9kR4G1N9CXJ7Ce2nhEMxN TFR3uh1/cApXUW35yDB9rhUIfgzpr1jRnlEYxfg4th/VrwSan2ehLmkp25rduUq53lkW /lq7qN1d0u1InchAKe/X45NUGQtZfU9H6T2V4KtxbQli0P+LxWAh4bZ/IX/DNoEmHbff U5Uj+aHbFSVafcFZ3jXQHjPXJLc2bOywGJxI2ghFM/ATD3iGgWiAQ/RpdHaJoJ/DfGxK Pub+tpdF4ommQUXfez1Aa+aGB5W5BNaN0hv9oBnyUzlqWkzdrF4orQ9wZkCBTmXwCKQO bs7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796017371; x=1796622171; 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:content-type; bh=RjSuaQtbCjYXvVI9VQub7/KjudjuXpXK4KPMMsOzAWw=; b=Sh1ONoGfCUy+FwKnYohgjeGZwQXg+QFETTrCwtZZUdhrK35NstuK6mdHgdMcjBIPjJ 5Liz3lDDAv+E4SyVlahp7l1a9GP5eLq2xVh/A4Q8H3tMYcbV1psMCatlg8tnhnCy1ev4 +fxJJuXSDZSTmKyOOAclWXY1ElMaVQz9ZMluHkeOETuX6FqPT+hWOXn+pNjhZYlEeGP/ XtPKE9mQjmXgqcPfn6Lw5d4zfOaNHiaF1klnh7iL5F9Kr1QlkzRWKvysv6if0HHRc/fH l1yUVim1pSHW39fGbjcJ/+sd8souT6bleQTWWfKwTEjTX6WahdLcliXvjfyUgvSlz20g E+FQ== X-Gm-Message-State: APuU4Z8Kmw79L2WIq36ozwmh5PWxiR5r/t2/ermWuiDI2kGKUj3LoVQ1 Jsh0hIt+rBx9iUq9fYd7GYR1fV9Jg5aAHXyYP4DewfqYBAbN61V1Vxso9MqfTA== X-Gm-Gg: AZFdTZfk2mHXcR8RA6m8j+AYYsj4QCBhWUGUOvw6d7CSySKwzK7HqEdGDsx2oizvvAo OrNKRPQDp+COQM8rCV9xYhjlVPkpuye6CBxXjbWRkKM3b5oqOCNAceOcJ6Z1LP2bb0ldQCDiXXC Qvwu0mDNUGmmScYz8l+OIpCX5zWkXuiloRU36tG8Q26sx3yJ+ew1n7KehxdgTWd3YzNPoHyFuWX 31OoKS0ENogu4bwpLxjhszm9NbY9peSnxZu4vUiCDZ0A8NPVepOojaWQJXcHkjhdWbRfStVvsUB X9rg1OMzdD3bDbOooJc++tUcD48Er2DXxncQzmwKtYpIkRb52fhpBquW7r64S5FOoHTzdYljAww vA+mvnDo5hxPQT2BnWSCRh7A2SxzKc8ubqV13Q28Z5tzexfI1BCsfGxyXvrNxJnW8NopTJBvAz9 l12pGrXArm7lQTPLtOvu/o5WbBzvhC5BkNrwDPW3ODWK1+qzDjbqOsMsVf3GCTALedeO7H+M0OD GzaX9thJ3MfcWMpKhrcTQ53ehBUZBalW/MN0oq94ZbMevau/SOVZPo4k3o1vBH8Nm9i2cvrco6z HcPmaM5LbFSRSdm7nD/+0yUkw9y2tNUifxQyxJcFwETeaYw1N6OT6HgcmRCTZIKZn3tIA8mo03e aVgb0xj9PaXA7/fFj X-Received: by 2002:a17:90b:5109:b0:3ac:97bc:4c98 with SMTP id 98e67ed59e1d1-3b41c9bc501mr30397110a91.64.1796017371029; Sun, 29 Nov 2026 21:42:51 -0800 (PST) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:ba7e:5b43:81b2:edf]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b405d63728sm57059306a91.8.2026.11.29.21.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 21:42:50 -0800 (PST) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Lee Jones , Vojtech Pavlik , Guanglei Zhu , linux-kernel@vger.kernel.org, sashiko-bot@kernel.org Subject: [PATCH 1/8] Input: adi - fix out-of-bounds write in adi_read_packet() Date: Sun, 29 Nov 2026 21:42:38 -0800 Message-ID: <20261130054245.2215181-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog In-Reply-To: <20261130054245.2215181-1-dmitry.torokhov@gmail.com> References: <20261130054245.2215181-1-dmitry.torokhov@gmail.com> X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit adi_read_packet() initializes the per-stream packet counter to -1 and pre-increments it before storing each sample into the fixed-size data buffer, while checking the upper bound against the full buffer length. When the buffer already holds 256 samples, another strobe passes the check and writes one byte past the end of the buffer into adjacent fields of struct adi_port, and leaves the counter out of bounds for subsequent packet reads. Bound the packet counter to one less than the buffer size so writes stay within the data buffer. Reported-by: sashiko-bot@kernel.org Closes: https://sashiko.dev/#/bug/linux-951334ec-a996-4dc4-a03b-d7e6f716e5de Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/adi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 0b60c8067faf..43c2e60fcb1c 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c @@ -141,7 +141,8 @@ static void adi_read_packet(struct adi_port *port) for (i = 0; i < 2; i++, w >>= 2, x >>= 2) { t[i]--; if ((w & 0x30) && s[i]) { - if ((w & 0x30) < 0x30 && adi[i].ret < ADI_MAX_LENGTH && t[i] > 0) { + if ((w & 0x30) < 0x30 && + adi[i].ret < ADI_MAX_LENGTH - 1 && t[i] > 0) { adi[i].data[++adi[i].ret] = w; t[i] = gameport_time(gameport, ADI_MAX_STROBE); } else t[i] = 0; -- 2.56.1.839.g22a8290db9-goog