From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796077296; b=JbVQGLyN5Sp9nBbexDgl9Jo5HB57+fyBORZqGRmbFRzd0HNxKv7S1d+3wnC+coLtkMd+ 6LdG/f1zyI7N7ZfAr7mqY+avMqQJcqzKaX1uE0lRtx7p+OqU2YSuRRgFBJc3ja82Hawtw 7quBhNBjUVXxacsB5yNm/GggNdfw2tHP/y1T3D1NqX0mU6bqfST5OF5zFCm6QxH+BcQCR renAa1AZguVc491X+U/VVCVmM5xUx0jHHXMlCT19CQwiNpOW+cuQFhW8P/b5BfkpTRpzY 3QzJ9hVuDfLupnxJxd+9P7GPnU5619aTwsoVw82hoeNHmLo6psPl54rwh1w+O6UiZEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796077296; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=SKX0Yd8XPAoTClG+8qXVQucpFJRBP1HYKT2bP1GEdKk=; b=h7qWvLs40NOKrRbMp4xoz5Te1xXFd5PQfmj3Ix3BgWU6zYdl3dfeW0ZleAw2vv9EfPKt RA2BptMXrrh6rIzsk1dA7wv6HWlq0C8xyqcf8jQmcsX4p9neKlCIgEVN6P8CFIFyh390A QTmnaoKhCUanFziY/myl43vJhcdZb4Xr/17iaP/9lDsBzEi051K/bD6eEVg641dwKm5Y1 lF9GuuGIrC7W/SbBcmTqE7ye4S9Kne8tLH6y+fUCHeDzYK89CVe9q0eStmf6EvfWTx7J7 CA31uiqtNjx9xOnYvOeJNlpES1VZKfp2VPV+f3KcpOH5FUshwB3sa8n/mSL4OLvi2Vg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lv20FQRW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D10A606A320; Mon, 30 Nov 2026 22:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lv20FQRW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 885801F0089A; Mon, 30 Nov 2026 22:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796077295; bh=SKX0Yd8XPAoTClG+8qXVQucpFJRBP1HYKT2bP1GEdKk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Lv20FQRWGdnMXbzj6J8RdLm/vdUuc5svRPW8WtB5fQqQmhKjzwYmjIawDk+9djqGz TLgjZLAsTpuY46eGQxl92oFogVUWXyh93899iWFD8BnsKy/nfVShw3P5VT1bYaBu0a eLsCMJYfvjGulkfah4anLLG84j+zAYl6r34GP4xtoiWsBGJmfpn/57Bxprc9iQnO0R NExTWuZa8gtuaBH26O6QWZraLKwUj4d/72Mog0eDVrxQW+hP/P0ENHaEwZuknVuAfp T5Ij4Yly38z8vmq39kN0jRjp7cDLIzfRy/lAn2qRnAIL3CtW+ec712s7inumyrNso0 DGvExIUiy2Z0g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/2] HID: core: release the HID-BPF event buffer on hid_connect()'s no-listeners exit Reply-To: sashiko-reviews@lists.linux.dev To: "Xiang Mei" Cc: linux-input@vger.kernel.org, bpf@vger.kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261130220315.659533-2-xmei5@asu.edu> References: <20261130220315.659533-1-xmei5@asu.edu> <20261130220315.659533-2-xmei5@asu.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 22:21:35 +0000 X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] HID: bpf: out-of-bounds read in dispatch_hid_bpf_device_event() [1] -- commit c402dbbc172b7dd281582dc06c3550cedb6797b3 Author: Xiang Mei HID: core: release the HID-BPF event buffer on hid_connect()'s no-listeners= exit This commit calls hid_bpf_disconnect_device() on hid_connect()'s no-listeners error path so that a stale hdev->bpf.device_data buffer is not retained across a subsequent reprobe. > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c > index 4a47deb9d833f..3f93b0d485376 100644 > --- a/drivers/hid/hid-core.c > +++ b/drivers/hid/hid-core.c > @@ -2339,6 +2339,7 @@ int hid_connect(struct hid_device *hdev, unsigned i= nt connect_mask) > * to any other listener. */ > if (!hdev->claimed && !hdev->driver->raw_event) { > hid_err(hdev, "device has no listeners, quitting\n"); > + hid_bpf_disconnect_device(hdev); > return -ENODEV; > } [Severity: Critical] This problem wasn't introduced by this patch, but can dispatch_hid_bpf_device_event() still read past the end of data (or write past the end of ctx_kern.data) [1] when *size exceeds *buf_size or hdev->bpf.allocated_data? __hid_input_report() calls dispatch_hid_bpf_device_event() before hid_report_raw_event() checks the report length against bufsize: drivers/hid/bpf/hid_bpf_dispatch.c:dispatch_hid_bpf_device_event() { ... if (!hdev->bpf.device_data) return data; memset(ctx_kern.data, 0, hdev->bpf.allocated_data); memcpy(ctx_kern.data, data, *size); ... *buf_size =3D ctx_kern.ctx.allocated_size; return ctx_kern.data; } When hdev->bpf.device_data is allocated, memcpy() copies *size bytes from data into ctx_kern.data without checking that *size fits within either *buf_size or hdev->bpf.allocated_data, and then overwrites *buf_size with ctx_kern.ctx.allocated_size so the later bounds check in hid_report_raw_event() cannot reject a report where *size exceeded the caller's source buffer. If a caller of hid_safe_input_report() passes a report length larger than its transport buffer capacity, memcpy() reads out of bounds from data into the BPF context buffer and downstream hidraw listeners, or overflows ctx_kern.data if *size also exceeds hdev->bpf.allocated_data. [1] https://sashiko.dev/#/bug/linux-5fe97c31-7531-4aca-913a-1d4f5712eb64 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130220315.6595= 33-1-xmei5@asu.edu?part=3D1