From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (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 AA88F481255; Thu, 24 Sep 2026 14:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790261090; cv=none; b=Y0o348jWigx4b8KBoauE0goUUIjnUGspolnCY04/jeLfk89g8E0v80CwjL4KsL4Wh/u1yP2ctBFQAVT+olKu22e4Ibp/ZITmCPPh/a31Ag5b8+dvHy4etX8s23Yxe+mLGt9YbXpkFNz753vKOvqtwj4B5KyiESL+3v6VNFP1dO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790261090; c=relaxed/simple; bh=B8hVzjIIeFEIT3s8OsymYvSH9nBBah61MIi7JDClqpE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BJVwo3B6HL6HtqSDXqmmql2tk6AnA7ol8sL2QXeg1oPvqlbR4BhcJ8sayxBm75WMRxTscHTQod+GCZEo4QxqhdC3SGSfQyiGh0B2GiZhWSebTXjz38buP61bslY02GAWeYnt8j7VfPm8/r/zwCx/KPKPsx3eKOeDG4jxAuZj7sg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=k7ezhexF; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="k7ezhexF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=MO WH0Vxv02bgZyLOaScalkxEhV5/qrIuKTys05vj4rQ=; b=k7ezhexF1SRiAo6Wj6 f5FS/Przh9H/lILlLDohwaEXYy+PUcVLu3Dnvv7bDdf37A2+5aIJ7W66xA51c/TU 2M/ktpZdP5Cl7t58l7BWdtehtVQUJfMoK8PSWIvuSjAF2u6yy4RAgVyC+SlfGbqA BfMPffpcResLJBXM8IMzsDSNg= Received: from pc.localdomain (unknown []) by gzga-smtp-mtada-g1-1 (Coremail) with SMTP id _____wD330ZHN7VqyTtKAg--.25624S10; Thu, 24 Sep 2026 22:44:34 +0800 (CST) From: Jiale Yao To: Jiri Kosina , Benjamin Tissoires , Don Prince , Clemens Ladisch , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiale Yao , stable@vger.kernel.org Subject: [PATCH 08/10] HID: prodikeys: validate fixed-format MIDI reports Date: Thu, 24 Sep 2026 22:44:11 +0800 Message-Id: <20260924144414.1192037-9-yaojiale02@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260924144414.1192037-1-yaojiale02@163.com> References: <20260924144414.1192037-1-yaojiale02@163.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 X-CM-TRANSID:_____wD330ZHN7VqyTtKAg--.25624S10 X-Coremail-Antispam: 1Uf129KBjvJXoW7CF1UGFWrKF13Gw1UCFWfXwb_yoW8Xw18pF yDtF4q9rWDJr4fuw17CF18Xa4rtw1kGFsruFW0yas09w15u3WUGrW0gas0grZ5ZrWktrZa yw4kXrn3Ca1DZaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRFApnUUUUU= X-CM-SenderInfo: x1dryxhdohiji6rwjhhfrp/xtbC8BLpJGq1N1L3UAAA3y The HID core invokes raw_event callbacks before validating the report length. Prodikeys reports 0x01 and 0x04 are passed to handlers that always read bytes one through three, regardless of the supplied size. A truncated report can therefore cause an out-of-bounds read. Require four bytes for the two fixed-format reports. Keep report 0x03 on its existing variable-length path, which derives the number of note pairs from size and only accesses complete pairs. Commit 47669bec44fe ("HID: asus: refactor the two workqueues and init sequence") added the same kind of raw_event length validation to hid-asus. Fixes: 3a370ca1dcf8 ("HID: Prodikeys PC-MIDI HID Driver") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao --- drivers/hid/hid-prodikeys.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index fba01e4fcab1..bf5add40d3e1 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c @@ -772,8 +772,13 @@ static int pk_raw_event(struct hid_device *hdev, struct hid_report *report, if (report->id == data[0]) switch (report->id) { case 0x01: /* midi keys (qwerty)*/ - case 0x03: /* midi keyboard (musical)*/ case 0x04: /* extra/midi keys (qwerty)*/ + if (size < 4) + break; + ret = pcmidi_handle_report(pm, report->id, + data, size); + break; + case 0x03: /* midi keyboard (musical)*/ ret = pcmidi_handle_report(pm, report->id, data, size); break; -- 2.34.1