lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 21 Jun 2024 08:35:19 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Benjamin Tissoires <bentiss@...nel.org>
Cc: Jiri Kosina <jikos@...nel.org>, Alexei Starovoitov <ast@...nel.org>, Shuah Khan <shuah@...nel.org>, 
	Jonathan Corbet <corbet@....net>, "open list:HID CORE LAYER" <linux-input@...r.kernel.org>, 
	LKML <linux-kernel@...r.kernel.org>, bpf <bpf@...r.kernel.org>, 
	"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>, 
	"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>
Subject: Re: [PATCH HID 03/12] HID: bpf: add HID-BPF hooks for hid_hw_raw_requests

On Fri, Jun 21, 2024 at 1:56 AM Benjamin Tissoires <bentiss@...nel.org> wrote:
>
> This allows to intercept and prevent or change the behavior of
> hid_hw_raw_request() from a bpf program.
>
> The intent is to solve a couple of use case:
> - firewalling a HID device: a firewall can monitor who opens the hidraw
>   nodes and then prevent or allow access to write operations on that
>   hidraw node.
> - change the behavior of a device and emulate a new HID feature request
>
> The hook is allowed to be run as sleepable so it can itself call
> hid_bpf_hw_request(), which allows to "convert" one feature request into
> another or even call the feature request on a different HID device on the
> same physical device.
>
> Signed-off-by: Benjamin Tissoires <bentiss@...nel.org>
>
> ---
>
> Here checkpatch complains about:
> WARNING: use of RCU tasks trace is incorrect outside BPF or core RCU code
>
> However, we are jumping in BPF code, so I think this is correct, but I'd
> like to have the opinion on the BPF folks.
> ---
>  drivers/hid/bpf/hid_bpf_dispatch.c   | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/hid/bpf/hid_bpf_struct_ops.c |  1 +
>  drivers/hid/hid-core.c               |  6 ++++++
>  include/linux/hid_bpf.h              | 35 +++++++++++++++++++++++++++++++++++
>  4 files changed, 78 insertions(+)
>
> diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c
> index 2df31decaac3..813b53119b85 100644
> --- a/drivers/hid/bpf/hid_bpf_dispatch.c
> +++ b/drivers/hid/bpf/hid_bpf_dispatch.c
> @@ -74,6 +74,42 @@ dispatch_hid_bpf_device_event(struct hid_device *hdev, enum hid_report_type type
>  }
>  EXPORT_SYMBOL_GPL(dispatch_hid_bpf_device_event);
>
> +int dispatch_hid_bpf_raw_requests(struct hid_device *hdev,
> +                                 unsigned char reportnum, u8 *buf,
> +                                 u32 size, enum hid_report_type rtype,
> +                                 enum hid_class_request reqtype,
> +                                 u64 source)
> +{
> +       struct hid_bpf_ctx_kern ctx_kern = {
> +               .ctx = {
> +                       .hid = hdev,
> +                       .allocated_size = size,
> +                       .size = size,
> +               },
> +               .data = buf,
> +       };
> +       struct hid_bpf_ops *e;
> +       int ret;
> +
> +       if (rtype >= HID_REPORT_TYPES)
> +               return -EINVAL;
> +
> +       rcu_read_lock_trace();

checkpatch is correct.
What is this for?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ