Skip to content

4.18: fix hid_report_raw_event arguments for kernel 7.0.8+#510

Merged
Pinglinux merged 2 commits into
linuxwacom:masterfrom
Korikashi:fix-kernel-7.0-hid-arguments
Jun 15, 2026
Merged

4.18: fix hid_report_raw_event arguments for kernel 7.0.8+#510
Pinglinux merged 2 commits into
linuxwacom:masterfrom
Korikashi:fix-kernel-7.0-hid-arguments

Conversation

@Korikashi

@Korikashi Korikashi commented May 17, 2026

Copy link
Copy Markdown
Contributor

The hid_report_raw_event() API changed in upstream commit 2c85c61d1332 ("HID: pass the buffer size to hid_report_raw_event"), adding a bufsize parameter to the function signature.

To maintain compatibility across kernels with both API variants, this patch adds a configure-time feature check using WACOM_LINUX_TRY_COMPILE. When the newer signature is detected, WACOM_HID_REPORT_RAW_EVENT_BUFSIZE is defined in config.h.

The driver code in 4.18/wacom_sys.c uses this macro to select the appropriate hid_report_raw_event() call signature at compile time, preserving compatibility with both older and newer kernels.

Problem / Error Log

When building against kernels that include the updated hid_report_raw_event() signature, compilation fails due to the missing bufsize argument:

error: too few arguments to function 'hid_report_raw_event'
  ... | err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);

How has this been tested?

  • New API path (WACOM_HID_REPORT_RAW_EVENT_BUFSIZE defined):
    Successfully configured, compiled, and tested on EndeavourOS with Linux 7.0.11-zen1-1-zen. The driver builds correctly and hardware functionality was verified using a Wacom Intuos CTH-480.

  • Legacy API path (WACOM_HID_REPORT_RAW_EVENT_BUFSIZE undefined):
    Successfully configured and compiled against Ubuntu 22.04 Linux 5.15.0-107-generic kernel headers. The feature detection correctly selected the legacy 5-argument signature and the driver built without errors.

@Pinglinux

Copy link
Copy Markdown
Member

@Korikashi Thank you for your contribution! Your patch is considered as an importing from upstream. Please follow this PR: #463 as an example to update your patch.

@Korikashi

Copy link
Copy Markdown
Contributor Author

@Korikashi Thank you for your contribution! Your patch is considered as an importing from upstream. Please follow this PR: #463 as an example to update your patch.

Hi, thanks for the feedback.

I reviewed PR #463 as suggested, but I want to make sure I'm interpreting your request correctly.

Are you asking me to update this PR to follow the same upstream-import workflow/format used there, or is there a specific upstream commit addressing this API change that should be imported instead?

Any clarification would be appreciated so I can update the patch accordingly.

@Pinglinux

Copy link
Copy Markdown
Member

@Korikashi thanks for following up. I meant "follow the same upstream-import workflow/format used there". Basically, it means, you do a direct import from upstream to input-wacom, like this: patch:94b2292
Then, you do a backward compatible support like: 363ed5e. The actual kernel version number only shows in the configure.ac file, but not in the driver code.

Thanks again for your effort!
Ping

@Korikashi
Korikashi force-pushed the fix-kernel-7.0-hid-arguments branch 2 times, most recently from a1159f7 to 180ba8e Compare June 11, 2026 04:25
@Korikashi

Copy link
Copy Markdown
Contributor Author

@Pinglinux Hi! Sorry for the delay.

I have completely refactored the patch following the requested workflow and format.

Instead of checking the static kernel version number in the driver code, I updated configure.ac to use feature detection (WACOM_LINUX_TRY_COMPILE) to check whether hid_report_raw_event expects the bufsize parameter.

The driver code in wacom_sys.c now relies entirely on the newly introduced WACOM_HID_REPORT_RAW_EVENT_BUFSIZE macro to maintain clean, backward-compatible support for older kernels. I also tested the build environment locally on both an upstream modern kernel and an older 5.15 LTS environment via a container, and it compiles successfully on both.

The PR has been updated with the clean history. Thanks again for the guidance!

@Pinglinux Pinglinux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Korikashi, thank you so much for your effort. There are a few places where more details are needed.

First, we want to use the same patch title as the upstream one. We also need to preserve the whole commit message and SoB history for future reference. You need to add your SoB at the end of the commit message too.

So, it would be like:

HID: pass the buffer size to hid_report_raw_event

commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing
bogus memset()") enforced the provided data to be at least the size of
the declared buffer in the report descriptor to prevent a buffer
overflow. However, we can try to be smarter by providing both the buffer
size and the data size, meaning that hid_report_raw_event() can make
better decision whether we should plaining reject the buffer (buffer
overflow attempt) or if we can safely memset it to 0 and pass it to the
rest of the stack.

Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires bentiss@kernel.org
Acked-by: Johan Hovold johan@kernel.org
Reviewed-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Signed-off-by: Jiri Kosina jkosina@suse.com
[your-email-address@sth.com: Imported into input-wacom (2c85c61d1332)]
Signed-off-by: Your name <your email@sth.com>


The 12-hex attached to your imported line above is the first 12 hex number from the kernel upstream patch's sha1 ID. You can find it here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/hid/wacom_sys.c?h=v7.1&id=2c85c61d1332e1e16f020d76951baf167dcb6f7a

Comment thread 4.18/wacom_sys.c
MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably accidently touched this line, which should not happen.

Comment thread 4.18/wacom_sys.c Outdated
@Pinglinux

Copy link
Copy Markdown
Member

@Korikashi Thank you again for your effort. Your patches look great. The reason that we enforce the importing and backporting process is to make it easy for anyone who needs to troubleshoot the code and follow the change logic in the future.

The commit comments in your second patch can be more explicit about what it does and why. Please refer to Josh's commit comments for example: 363ed5e.

commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing
bogus memset()") enforced the provided data to be at least the size of
the declared buffer in the report descriptor to prevent a buffer
overflow. However, we can try to be smarter by providing both the buffer
size and the data size, meaning that hid_report_raw_event() can make
better decision whether we should plaining reject the buffer (buffer
overflow attempt) or if we can safely memset it to 0 and pass it to the
rest of the stack.

Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
[pedarkasy@gmail.com: Imported into input-wacom (2c85c61d1332)]
Signed-off-by: Kori <pedarkasy@gmail.com>
@Korikashi
Korikashi force-pushed the fix-kernel-7.0-hid-arguments branch from 180ba8e to 657548b Compare June 14, 2026 23:52
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>
@Korikashi
Korikashi force-pushed the fix-kernel-7.0-hid-arguments branch from 657548b to 4e77339 Compare June 14, 2026 23:55
@Korikashi

Copy link
Copy Markdown
Contributor Author

@Pinglinux Thank you so much for your guidance and patience throughout this process! Since this is my very first contribution to an open-source project of this scale, I deeply appreciate you taking the time to explain the backporting standards and logic.

I have force-pushed the updates following your instructions:

First commit: Restored the clean original file to eradicate the accidental trailing whitespace/newline changes. Updated the commit title and full message to match the upstream history exactly, adding the explicit import tracking line and my Signed-off-by at the end.

Second commit: Removed the indentation from all #ifdef, #else, and #endif directives in wacom_sys.c so they start at the beginning of the line. Also, rewritten the commit description following Joshua's style to be much more explicit about the configure.ac check and what the patch achieves.

Everything should be clean and compliant now. Please let me know if any further changes or adjustments are needed, and I will gladly fix them.

Thanks again for the warm welcome to the project

@Pinglinux
Pinglinux merged commit 44cea06 into linuxwacom:master Jun 15, 2026
8 of 9 checks passed
@Pinglinux

Copy link
Copy Markdown
Member

Hi @Korikashi! Welcome to LinuxWacom project! Your first contribution looks very good. If you are interested in contributing more, we have a few upstream patches to import :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants