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: Mon, 10 Jun 2024 11:34:37 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Benjamin Tissoires <bentiss@...nel.org>
Cc: Shuah Khan <shuah@...nel.org>, Jiri Kosina <jikos@...nel.org>, Jonathan Corbet <corbet@....net>, 
	Alexei Starovoitov <ast@...nel.org>, 
	"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>, 
	bpf <bpf@...r.kernel.org>, 
	"open list:HID CORE LAYER" <linux-input@...r.kernel.org>, 
	"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>
Subject: Re: [PATCH HID v3 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

On Sat, Jun 8, 2024 at 2:01 AM Benjamin Tissoires <bentiss@...nel.org> wrote:
>
> +
> +static int hid_bpf_ops_init_member(const struct btf_type *t,
> +                                const struct btf_member *member,
> +                                void *kdata, const void *udata)
> +{
> +       u32 moff = __btf_member_bit_offset(t, member) / 8;
> +       u32 flags;
> +
> +       switch (moff) {
> +       case offsetof(struct hid_bpf_ops, hid_id):
> +               /* For hid_id and flags fields, this function has to copy it
> +                * and return 1 to indicate that the data has been handled by
> +                * the struct_ops type, or the verifier will reject the map if
> +                * the value of those fields is not zero.
> +                */
> +               ((struct hid_bpf_ops *)kdata)->hid_id = ((struct hid_bpf_ops *)udata)->hid_id;
> +               return 1;
> +       case offsetof(struct hid_bpf_ops, flags):
> +               flags = ((struct hid_bpf_ops *)udata)->flags;
> +               if (flags & ~BPF_F_BEFORE)
> +                       return -EINVAL;
> +               ((struct hid_bpf_ops *)kdata)->flags = flags;

minor nit: I'd cast kdata/udate in the beginning of
the function to make the lines shorter and less verbose.
Similar to how bpf_tcp_ca_init_member() does it.

Acked-by: Alexei Starovoitov <ast@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ