Skip to content

Commit 4e77339

Browse files
committed
4.18: add WACOM_HID_REPORT_RAW_EVENT_BUFSIZE flag for API update
In kernel ver 7.0.8, hid_report_raw_event() was updated to accept both the buffer size and the data size arguments to mitigate potential OOB issues. This commit adds a check and flag set in configure.ac for this change. It also adds #ifdef checks in 4.18/wacom_sys.c to handle the flag and safely pass the extra parameter on newer kernels, while preserving the legacy signature for older environments. Signed-off-by: Kori <pedarkasy@gmail.com>
1 parent ce6a46c commit 4e77339

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

4.18/wacom_sys.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
9696
kfree(buf);
9797
continue;
9898
}
99+
#ifdef WACOM_HID_REPORT_RAW_EVENT_BUFSIZE
99100
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, size, false);
101+
#else
102+
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);
103+
#endif
100104
if (err) {
101105
hid_warn(hdev, "%s: unable to flush event due to error %d\n",
102106
__func__, err);
@@ -339,8 +343,13 @@ static void wacom_feature_mapping(struct hid_device *hdev,
339343
ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
340344
data, n, WAC_CMD_RETRIES);
341345
if (ret == n && features->type == HID_GENERIC) {
346+
#ifdef WACOM_HID_REPORT_RAW_EVENT_BUFSIZE
342347
ret = hid_report_raw_event(hdev,
343348
HID_FEATURE_REPORT, data, n, n, 0);
349+
#else
350+
ret = hid_report_raw_event(hdev,
351+
HID_FEATURE_REPORT, data, n, 0);
352+
#endif
344353
} else if (ret == 2 && features->type != HID_GENERIC) {
345354
features->touch_max = data[1];
346355
} else {
@@ -400,8 +409,13 @@ static void wacom_feature_mapping(struct hid_device *hdev,
400409
ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
401410
data, n, WAC_CMD_RETRIES);
402411
if (ret == n) {
412+
#ifdef WACOM_HID_REPORT_RAW_EVENT_BUFSIZE
403413
ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT,
404414
data, n, n, 0);
415+
#else
416+
ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT,
417+
data, n, 0);
418+
#endif
405419
} else {
406420
hid_warn(hdev, "%s: could not retrieve sensor offsets\n",
407421
__func__);

configure.ac

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,35 @@ bool timer_delete_sync(struct timer_list *timer) { return true; }
303303
AC_DEFINE([WACOM_TIMER_DELETE_SYNC], [], [kernel defines timer_delete_sync from v6.1.84+])
304304
])
305305

306+
307+
dnl Check if hid_report_raw_event takes a bufsize parameter or not.
308+
dnl This is the case in Linux 7.0.8 and later.
309+
AC_MSG_CHECKING(hid_report_raw_event bufsize parameter)
310+
WACOM_LINUX_TRY_COMPILE([
311+
#include <linux/hid.h>
312+
static int (*test_fn)(
313+
struct hid_device *,
314+
enum hid_report_type,
315+
u8 *,
316+
size_t,
317+
u32,
318+
int
319+
) = hid_report_raw_event;
320+
int test(void)
321+
{
322+
return test_fn != NULL;
323+
}
324+
],[
325+
],[
326+
HAVE_HID_REPORT_RAW_EVENT_BUFSIZE=yes
327+
AC_MSG_RESULT([yes])
328+
AC_DEFINE([WACOM_HID_REPORT_RAW_EVENT_BUFSIZE], [],
329+
[kernel hid_report_raw_event() takes a bufsize parameter])
330+
],[
331+
HAVE_HID_REPORT_RAW_EVENT_BUFSIZE=no
332+
AC_MSG_RESULT([no])
333+
])
334+
306335
dnl Check if from_timer has been renamed to timer_container_of or
307336
dnl not. This is the case in Linux 6.16 and later.
308337
AC_MSG_CHECKING(timer_container_of)

0 commit comments

Comments
 (0)