linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: bpf: return non NULL data pointer when CONFIG_HID_BPF is not set
@ 2022-11-16 10:31 Benjamin Tissoires
  2022-11-16 22:01 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Tissoires @ 2022-11-16 10:31 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, linux-kernel, Benjamin Tissoires

dispatch_hid_bpf_device_event() is supposed to return either an error,
or a valid pointer to memory containing the data.

Returning NULL simply makes a segfault when CONFIG_HID_BPF is not set
for any processed event.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

This was detected by my own CI. Yes, a little bit embarrassing...

It applies on top of for-6.2/hid-bpf in case it was not obvious

Cheers,
Benjamin

---

 include/linux/hid_bpf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/hid_bpf.h b/include/linux/hid_bpf.h
index 9b11f8f25ad5..3ca85ab91325 100644
--- a/include/linux/hid_bpf.h
+++ b/include/linux/hid_bpf.h
@@ -148,7 +148,7 @@ void hid_bpf_device_init(struct hid_device *hid);
 u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size);
 #else /* CONFIG_HID_BPF */
 static inline u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type,
-						u8 *data, u32 *size, int interrupt) { return NULL; }
+						u8 *data, u32 *size, int interrupt) { return data; }
 static inline int hid_bpf_connect_device(struct hid_device *hdev) { return 0; }
 static inline void hid_bpf_disconnect_device(struct hid_device *hdev) {}
 static inline void hid_bpf_destroy_device(struct hid_device *hid) {}
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: bpf: return non NULL data pointer when CONFIG_HID_BPF is not set
  2022-11-16 10:31 [PATCH] HID: bpf: return non NULL data pointer when CONFIG_HID_BPF is not set Benjamin Tissoires
@ 2022-11-16 22:01 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2022-11-16 22:01 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: linux-input, linux-kernel

On Wed, 16 Nov 2022, Benjamin Tissoires wrote:

> dispatch_hid_bpf_device_event() is supposed to return either an error,
> or a valid pointer to memory containing the data.
> 
> Returning NULL simply makes a segfault when CONFIG_HID_BPF is not set
> for any processed event.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

I have added

	Fixes: 658ee5a64fcfbbf ("HID: bpf: allocate data memory for device_event BPF program")

and applied on top of the HID-BPF pile. Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-16 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 10:31 [PATCH] HID: bpf: return non NULL data pointer when CONFIG_HID_BPF is not set Benjamin Tissoires
2022-11-16 22:01 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).