Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp814424pxb; Fri, 22 Apr 2022 11:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwwxHw6sc7TPIfpsqqJZ/2m9jcghDw+e8unYW+cGzSry+Ia/Jyr4ZUrOk4d29Iot2KbgL5 X-Received: by 2002:aa7:88d2:0:b0:50a:cf7d:6ff1 with SMTP id k18-20020aa788d2000000b0050acf7d6ff1mr6240325pff.67.1650653083097; Fri, 22 Apr 2022 11:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650653083; cv=none; d=google.com; s=arc-20160816; b=sbBRzU9CGx/vKuBeGZP3JtMURwF4t1nTXsatI0nYBXHC7VU7n2Ee15GnxAA8bSCTMc cv0hpyX6qVlpbYXZ+hI5ayceT+uqN+N45AFjKI4FgPO9c9DI9E43lUJmtOlRaEPJgCJv fSHFf/U+qWkcpdRcEykAumToagLpzpDF8Q1taRn8xidISc+gTUndA+HgqxYu/0za0b8z qxeZGMjBYLfbgOaiH5T13FHshqmTLUq0NjShC+5A8v5L1zbiKmn0bgLk5HipRQg9nY58 tmFQwNnHgLdcwSxxPOGH8MtB6SOjRB8LR0IMLskD+6UUuqyTuoGe16SepoetMbKhxw/q qa5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=prVzIo1GwtCwuoe6EtlDofBh6VTrEATes2v0MdzWadE=; b=A1AsZ7gq8v72x1F+LltoyxNLYGYmn3IB9nimmngViCNA0FvMM4XX9E2YIdYywVOi8J 4bRUCJM39yBeSjTrdcbI6A6tcK5RJY0hq5D0GzWcDbksvaawIMXTqv5w1oXq8ln8gZ5U w8p2R1LItf5qdsB9ajAqs9OQpyLF7EQ+DuyB/pabY9LQ+rSRRpvmvSIG2v3Rp515n2bN Hd0eL64kvsJ2B494BwLPGu4KhL+P2Xr0QK4XPsB1+mt1zXU5Y6TmhBt19oL4gWJLG26f GyYO0u0Fdss5hYm3ZkepyxzimpGbb4wQP5XMv95vj20VoYBvh+bYlvh+uUAGPAjFfVuZ Vv6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QbIT3sG+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l8-20020a170903120800b00153b2d16420si11122487plh.40.2022.04.22.11.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:44:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QbIT3sG+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 60B6C1611EB; Fri, 22 Apr 2022 11:12:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387503AbiDUOKo (ORCPT + 99 others); Thu, 21 Apr 2022 10:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388836AbiDUOKn (ORCPT ); Thu, 21 Apr 2022 10:10:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E721CEC for ; Thu, 21 Apr 2022 07:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=prVzIo1GwtCwuoe6EtlDofBh6VTrEATes2v0MdzWadE=; b=QbIT3sG+0c70rAKhh1TOlDXq8eyv/rLGsrKOWS52w8VxVtXi2+1cZAe84RKtGEXFWA0fJw Fa1lyM6JWOGkm/zA/GfFC4dVSJ4PRpytOU1ki1+AiwP/kj8XPgYnalk4NbQ0CWkKOh0LLj 9+8bpDE6MSgd+fl47N13NpnJeBw2SRA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-Yg_QxmqEPFStLVmqi_BH3g-1; Thu, 21 Apr 2022 10:07:46 -0400 X-MC-Unique: Yg_QxmqEPFStLVmqi_BH3g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA518185A7B2; Thu, 21 Apr 2022 14:07:45 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.194.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F79540EC002; Thu, 21 Apr 2022 14:07:43 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Cc: Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, bpf@vger.kernel.org, Benjamin Tissoires Subject: [RFC bpf-next v4 0/7] Introduce eBPF support for HID devices (new attempt) Date: Thu, 21 Apr 2022 16:07:33 +0200 Message-Id: <20220421140740.459558-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, so after the reviews from v3, and some discussion with Alexei, I am back with a new version of HID-BPF. This version is not complete (thus the RFC), but I'd like to share it now to get initial feedback, in case I am too far from the actual goal. FTR, the goal is to provide some changes in the core verifier/btf so that we can plug in HID-BPF independently from BPF core. This way we can extend it without having to care about bpf-next. The things I am not entirely sure are: - do we need only fentry/fexit/fmod_ret BPF program types or should programs that modify the data stream use a different kind? - patch 3/7 is probably not the correct approach (see comments in the patch itself) We are missing quite a few bits here: - selftests for patches 1 to 4 - add the ability to attach a program to a struct device, and run that program only for that struct device - when running through bpf_prog_test_run_opts, how can we ensure we are talking to the correct device? (I have a feeling this is linked to the previous point) - how can we reconnect the device when a report descriptor fixup BPF program is loaded (would it make sense to allow some notifications on when a BPF program is attached/detached to a device, and which function have been traced?) Cheers, Benjamin Benjamin Tissoires (7): bpf/btf: also allow kfunc in tracing programs bpf/verifier: allow kfunc to return an allocated mem error-inject: add new type that carries if the function is non sleepable btf: Add a new kfunc set which allows to mark a function to be sleepable HID: initial BPF new way implementation samples/bpf: add new hid_mouse example selftests/bpf: add tests for the HID-bpf initial implementation drivers/hid/hid-core.c | 115 +++++ include/asm-generic/error-injection.h | 1 + include/linux/btf.h | 8 + include/linux/hid_bpf.h | 29 ++ kernel/bpf/btf.c | 50 +- kernel/bpf/verifier.c | 76 ++- lib/error-inject.c | 2 + samples/bpf/.gitignore | 1 + samples/bpf/Makefile | 23 + samples/bpf/hid_mouse.bpf.c | 59 +++ samples/bpf/hid_mouse.c | 131 +++++ tools/testing/selftests/bpf/config | 3 + tools/testing/selftests/bpf/prog_tests/hid.c | 482 +++++++++++++++++++ tools/testing/selftests/bpf/progs/hid.c | 32 ++ 14 files changed, 987 insertions(+), 25 deletions(-) create mode 100644 include/linux/hid_bpf.h create mode 100644 samples/bpf/hid_mouse.bpf.c create mode 100644 samples/bpf/hid_mouse.c create mode 100644 tools/testing/selftests/bpf/prog_tests/hid.c create mode 100644 tools/testing/selftests/bpf/progs/hid.c -- 2.35.1