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=1796417492; b=iU+cf+alYrC7Fp8inmQkd1D72+s2xTEca7pMvPX6NFNu13usGf5RqRkz7CxUuh+OKI9Z zj4M4RD6Ju7QGeCUoW0tBrv3tMgccXamx/9SNxrtx6mLcKEZYiC86IdUBhyFaOWOpMjA6 t5ygY+6KGN5IZ0NNaDP7I2E4Horp3pkWlseXlFAI4LHGbs7tge3tS0sVWbpwSDQ13GfPJ kxPHwxJNlhHevWAoldiOxADY4f4s3R4hSY9jyT945jvTo3EGzHzxEAEdQgTbVz2m8lBEt ukphzeGtb/FleEu1DZHAEOy7tgC0JRE2EMVuNyIfZSG80Q18YIuYXshyGZG0+8ziH6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796417492; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zV1MF1s+pSJAzTuOmPIg37hJeiVUWV9+8rRjTHRjCgY=; b=pHRvKl8tGrzKf/p0OR3x0jwVkhmN9Wxm+dgq7a/sAgeV+/+w2zyfSV2rlxyehMXOtZLz Rs82CZZsTSsyK+i5tgQ1LBPsHp9ZtcOG7FE/KO83r2cVmJNCTLAhf26ohiu6kiyX76/QV oDfzEKZd8BX+fqpLs3fQoQ+oFlte5iQo9P8Wrr9yn6rGJSFa6kt1pUQBzmLOJff4WH8nZ msUoBrnYi2iuH7bstU1tkSzpIcwlSh3hu+ZirBBAwfNiKfrzT+MsUBeDxa5haFc24JZPg QSBi6cUcLv4PZUOJiyufA3GoUkWSHdS6ujvGF+yWsw8q1EuMVX48YYpCZ1NzyXxLDog== 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=JjTJXjX7; 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 55577606A322; Fri, 4 Dec 2026 20:51:32 +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=JjTJXjX7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD1901F00936; Fri, 4 Dec 2026 20:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796417492; bh=zV1MF1s+pSJAzTuOmPIg37hJeiVUWV9+8rRjTHRjCgY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JjTJXjX79Mp1/zb8oA7tGEvn582c/tofPZPqDoiJf9YEqAXaZppjz4rmH6nz+Nqfq Sx/723cS6IiuCBVHJ2fmzWD3n0ZqGU3Iz45K2HeCz25eBWsadKWadrC7QnpHiIrfO9 KB3R8D8nVJlcMKKv3LmKUCKUFUhAEvO6mHCDrOXoVp0qx1d4ADDB2inFK+H7Oetke4 GncTZ0lc/3+77Mbsalc8OwtKT7FnsxjNDIJAsc5HAv2swr0IwMYFDaiVtD6JWKEh0o przP+bxbxVJ+w2cJm71uovN03EQtrEc7i+B3QCmCe82vcNiDofdkEI8ozzf2/tmkiC RChb/R9hsFCIg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/4] HID: bpf: don't allocate an empty device event buffer Reply-To: sashiko-reviews@lists.linux.dev To: "Yassine Ouamer" Cc: linux-input@vger.kernel.org, bpf@vger.kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261204-hid-bpf-event-buffer-v2-1-188e8e960231@proton.me> References: <20261204-hid-bpf-event-buffer-v2-0-188e8e960231@proton.me> <20261204-hid-bpf-event-buffer-v2-1-188e8e960231@proton.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 20:51:31 +0000 X-Mailing-List: bpf@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 1 potential issue to consider: - [Medium] HID: bpf: race between hid_bpf_reg() and hid_bpf_connect_device() skips hooks -- commit 0479a84986d87f27a71dc589c8c74d25d8357acb Author: Yassine Ouamer HID: bpf: don't allocate an empty device event buffer This patch skips allocating the HID-BPF device event buffer in __hid_bpf_allocate_data() when the device currently has no parsed reports, leaving allocation to hid_bpf_connect_device() after a subsequent probe. > diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf= _dispatch.c > index 6b467c74601cb..714014560fb8d 100644 > --- a/drivers/hid/bpf/hid_bpf_dispatch.c > +++ b/drivers/hid/bpf/hid_bpf_dispatch.c > @@ -243,6 +243,15 @@ static int __hid_bpf_allocate_data(struct hid_device= *hdev, u8 **data, u32 *size > } > } > =20 > + /* > + * A device whose own report descriptor was refused has no reports > + * until a report descriptor fixup makes them and the device is probed > + * again: nothing to allocate before, hid_bpf_connect_device() does it > + * then. kzalloc(0) would give ZERO_SIZE_PTR, which looks allocated. > + */ > + if (!max_report_len) > + return 0; [Severity: Medium] Can this deferred allocation race with hid_bpf_connect_device() and leave hdev->bpf.device_data NULL even after a hid_device_event program is attached? hid_bpf_reg() calls hid_bpf_allocate_event_data() before adding ops to hdev->bpf.prog_list, while holding only hdev->bpf.prog_list_lock. hid_bpf_connect_device() scans hdev->bpf.prog_list under rcu_read_lock() without taking hdev->bpf.prog_list_lock. When a program attaches concurrently with device probing (for example triggered by KOBJ_ADD from device_add() before bus_probe_device() finishes), the two paths can interleave: CPU0 CPU1 hid_device_probe() hid_bpf_reg() mutex_lock(&hdev->bpf.prog_list_lock) hid_bpf_allocate_event_data(hdev) max_report_len =3D=3D 0 -> returns 0 hid_open_report() hid_hw_start() -> hid_connect() hid_bpf_connect_device() scans prog_list (empty) <-- misses ops, skips allocation list_add_rcu(&ops->list, ...prog_list) mutex_unlock(&hdev->bpf.prog_list_lock) The device ends up connected with ops on prog_list while hdev->bpf.device_data remains NULL. Every subsequent input report then hits the early NULL check in dispatch_hid_bpf_device_event() and silently skips all attached hid_device_event programs. Taking hdev->bpf.prog_list_lock in hid_bpf_connect_device() would serialize the list check against hid_bpf_reg(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-hid-bpf-ev= ent-buffer-v2-0-188e8e960231@proton.me?part=3D1