From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A51243C276D; Tue, 25 Aug 2026 13:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787665837; cv=none; b=bauONpbKUCE/nycuHVZDa9BOvWQUuXoQVBj87Xq87TNR6LoHqUuQFI3q6X2BYw+/sZGBUosWB2gJ5aWpSJkkBl3BETHQE3cr8/zypTcV+8mCkx/ZlGU80H30mfdOFHePRXPcLaFO42GTu9/Me7+yvMettSgnzZnDgqOMTbw0CYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787665837; c=relaxed/simple; bh=lv4TfOuhNIJcvNVB5Unodk6Diw2neHJrwUVTRrZtRzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RdDpPL6eQJXnKIzwIBvkr7tv5c9Qv3TjIyVg6PfCkfm7DwKPxK44hkU2k0GfQ+kjpbVogIR9jR5VrQfxSXRB2kYd9qvG9opsr5BsuFf/b18ogs6aDOF2+iZ6EvlgQEyWHCZaE8xOlNjlwve/w3L86gsh72qUMdcKkcMGSq8NoVY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZckjfTrt; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZckjfTrt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F092E1F000E9; Tue, 25 Aug 2026 13:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787665836; bh=oDvxny5l0lgqCg1jz4FBnFGjfce8Nk5cWyIuMddmoGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZckjfTrt1IsYSww2WPsYL0JkgcTEiTmYzn/ijLBoNMHV0zZsKdiNJkk5xBOO767mB eiJ+vDLwyTLs5GK4GghJHboWqct0f2qUVsrKL6adfWJaUBfxBunD1x+eWy8zlFSV8Z uCvYk/+zCjAOmJ2+nA6aZWwTJbteb0FHr6wMgTEk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ibrahim Hashimov , Silvan Jegen , Jiri Kosina Subject: [PATCH 6.6 82/87] HID: nintendo: fix out-of-bounds read in joycon_ctlr_read_handler() Date: Tue, 25 Aug 2026 15:26:45 +0200 Message-ID: <20260825132545.026197283@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825132541.813800447@linuxfoundation.org> References: <20260825132541.813800447@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ibrahim Hashimov commit 27b376b945c0aac46fcdfcc950b14a85b874b557 upstream. joycon_ctlr_read_handler() casts an incoming HID input report to struct joycon_input_report and parses it, guarding the cast only with a 12-byte length check: if (size >= 12) /* make sure it contains the input report */ joycon_parse_report(ctlr, (struct joycon_input_report *)data); struct joycon_input_report is 49 bytes: a 13-byte header followed by a union whose IMU arm is 36 bytes. For an IMU report joycon_parse_report() -> joycon_parse_imu_report() walks that union (struct offsets 13..48), so a report of exactly 12 bytes with data[0] == JC_INPUT_IMU_DATA passes the guard yet is read up to 37 bytes past its declared length. The over-read bytes are decoded into accelerometer/gyroscope values and forwarded to userspace through the "(IMU)" input device, leaking driver-internal memory. data[0] and size are fully controlled by a malicious or spoofed Joy-Con/Pro Controller. Receive buffers are sized to the maximum report length, so this is an over-read within the allocation rather than a slab OOB, but the decoded bytes still reach userspace. The sibling subcmd path in joycon_ctlr_handle_event() already bounds the same cast correctly: if (size < sizeof(struct joycon_input_report) || data[0] != JC_INPUT_SUBCMD_REPLY) break; Use the same sizeof(struct joycon_input_report) bound here. Fixes: 2af16c1f846b ("HID: nintendo: add nintendo switch controller driver") Cc: stable@vger.kernel.org Signed-off-by: Ibrahim Hashimov Assisted-by: AuditCode-AI:2026.07 Reviewed-by: Silvan Jegen Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-nintendo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/hid/hid-nintendo.c +++ b/drivers/hid/hid-nintendo.c @@ -2217,7 +2217,12 @@ static int joycon_ctlr_read_handler(stru { if (data[0] == JC_INPUT_SUBCMD_REPLY || data[0] == JC_INPUT_IMU_DATA || data[0] == JC_INPUT_MCU_DATA) { - if (size >= 12) /* make sure it contains the input report */ + /* + * The whole struct is cast and parsed below, including the + * IMU/subcmd union, not just the 12-byte partial header this + * used to check for. + */ + if (size >= sizeof(struct joycon_input_report)) joycon_parse_report(ctlr, (struct joycon_input_report *)data); }